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'];
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)
207 if ( $this->fiche_def == 0)
throw new Exception (
"FICHE.179 Invalid category",
EXC_INVALID);
208 if (
sizeof($this->attribut)==0 ) $this->
getAttribut();
212 if ( $this->attribut[
$e]->ad_id == $p_ad_id )
214 $this->attribut[
$e]->av_text=$p_value;
233 function seek($p_attribut,$p_value)
235 $sql=
"select jft_id,f_id,fd_id,ad_id,ad_value from fiche join fiche_detail using (f_id)
236 where ad_id=$1 and upper(ad_value)=upper($2)";
237 $res=$this->
cn->get_array(
$sql,array($p_attribut,$p_value));
254 $this->
cn->search_sql_inject($p_sql);
256 if ( $p_search !=
"" )
258 $result = $this->
cn->get_value(
"select count(*) from
262 and vw_name ilike '%'||$2||'%'",
263 [$p_frd_id,$p_search]);
266 $result = $this->
cn->get_value(
"select count(*)
268 fiche join fiche_Def using (fd_id)
269 where frd_id=$1 ".$p_sql
297 $this->attribut_value.
"</TD>".
299 $this->attribut_def.
"</TD></TR>";
313 if ( empty ($this->attribut) )
319 foreach ($this->attribut as
$e)
321 if (
$e->ad_id == $p_ad_id )
334 if ( empty ($this->attribut)) {
337 foreach ($this->attribut as
$attr)
339 $a_return[
'av_text'.$attr->ad_id]=
$attr->av_text;
359 $r.=
'<table style="width:98%;margin:1%">';
373 return print_r($this,
true);
382 $type_card=$this->
cn->get_value(
'select fd_label '
383 .
' from fiche_def join fiche using (fd_id) where f_id=$1',
399 $this->GetAttribut();
402 $ret.=
'<span style="margin-right:5px;float:right;font-size:80%">'.
403 _(
'id').
':'.$this->
id.
"</span>";
404 $ret.=
"<table style=\"width:98%;margin:1%\">";
416 $r->setDisplayMode($this->display_mode);
433 td(
_(
"Actif"),
'class="input_text"').
td($enable_is->input(),
'class="input_text"')
451 if ( $this->
id == 0 )
452 $this->
insert($p_fiche_def);
477 $this->fiche_def=$p_fiche_def;
486 $Ret=$this->
cn->exec_sql(
"insert into fiche(f_id,f_enable,fd_id) values ($1,$2,$3)",
491 $p_array[
'av_text'.ATTR_DEF_NAME]=
_(
"Nom vide");
494 $this->
cn->exec_sql(
"insert into fiche_detail (f_id,ad_id,ad_value) values ($1,$2,$3)",
500 $p_array[
"av_text".ATTR_DEF_QUICKCODE]=
"";
504 $this->
cn->exec_sql(
$sql);
510 if (empty($this->attribut))
512 throw new Exception(
"FICHE.UPDATE02".
_(
"Aucun attribut ").
"($p_fiche_def)",
EXC_INVALID);
515 foreach ($this->attribut as $property)
517 $key=
'av_text'.$property->ad_id;
532 $this->
cn->rollback();
557 $this->fiche_def = $this->
cn->get_value(
"select fd_id from fiche where f_id=$1",[$this->
id]);
559 if ( empty($this->fiche_def)) {
560 throw new Exception(
'FICHE.UPDATE524 category not found',
EXC_INVALID);
562 if ( $this->
cn->size()==0) {
563 throw new Exception(
"FICHE.UPDATE01".
_(
"Fiche n'existe pas"),
EXC_INVALID);
570 if ( empty ($this->attribut) ) {
571 throw new Exception(
"FICHE.UPDATE02".
_(
"Aucun attribut ").
"($this->fiche_def)",
EXC_INVALID);
574 foreach($this->attribut as $property) {
575 $key=
'av_text'.$property->ad_id;
592 function remove($silent=
false)
594 if ( $this->
id==0 )
return;
598 if ( $this->
is_used() == FALSE) {
604 alert(
_(
'Impossible cette fiche est utilisée dans un journal'));
615 $sql=
"select ad_value from fiche_detail
616 where ad_id=1 and f_id=$1";
617 $Res=$this->
cn->exec_sql(
$sql,array($this->
id));
620 throw new Exception (
_(
"Fiche n'existe pas"), 1000);
621 return $r[0][
'ad_value'];
629 $sql=
"select ad_value from fiche_detail where ad_id=23 and f_id=$1";
630 $Res=$this->
cn->exec_sql(
$sql,array($this->
id));
632 if (
$r == FALSE ||
sizeof(
$r) == 0 )
634 return $r[0][
'ad_value'];
668 if ( $p_offset == -1 )
672 fiche join fiche_Def using (fd_id) join vw_fiche_name using(f_id)
673 where frd_id=".$this->fiche_def_ref.
" $p_search ".
$order;
677 $limit=($_SESSION[SESSION_KEY.
'g_pagesize']!=-1)?
"limit ".$_SESSION[SESSION_KEY.
'g_pagesize']:
"";
680 fiche join fiche_Def using (fd_id) join vw_fiche_name using(f_id)
681 where frd_id=".$this->fiche_def_ref.
" $p_search $order "
682 .$limit.
" offset ".$p_offset;
686 $Ret=$this->
cn->exec_sql(
$sql);
707 $result=$this->
cn->get_array(
"select frd_id from fiche join fiche_Def using (fd_id) where f_id=$1",[$this->
id]);
724 if (
$Max == 0 )
return null;
756 if ( $this->
id == 0 )
761 $filter_sql=
$g_user->get_ledger_sql(
'ALL',3);
768 $sql_let=
' and j1.j_id in (select j_id from letter_cred union select j_id from letter_deb)';
771 $sql_let=
' and j1.j_id not in (select j_id from letter_cred union select j_id from letter_deb) ';
776 $this->row=$this->
cn->get_array(
"
778 (select j_id,jl_id from letter_cred union all select j_id , jl_id from letter_deb )
779 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,".
780 "case when j_debit='t' then j_montant else 0 end as deb_montant,".
781 "case when j_debit='f' then j_montant else 0 end as cred_montant,".
782 " jr_comment as description,jrn_def_name as jrn_name,j_poste,".
784 "j_debit, jr_internal,jr_id,(select distinct jl_id from sqlletter where sqlletter.j_id=j1.j_id ) as letter , ".
786 " jr_tech_per,p_exercice,jrn_def_name,
787 (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 ),
788 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 )
789 select amount_deb-amount_cred
792 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,
795 jrn.currency_rate_ref,
797 (select cr_code_iso from currency where id=jrn.currency_id) as cr_code_iso,
799 sum_oc_amount as oc_amount,
800 sum_oc_vat_amount as oc_vat_amount ,
801 case when exists(select 1 from operation_analytique oa where j1.j_id=oa.j_id) then 1 else 0 end as op_analytic
802 from jrnx as j1 left join jrn_def on jrn_def_id=j_jrn_def
803 left join (select j_id,
804 coalesce(oc_amount,0) as sum_oc_amount ,
805 coalesce(oc_vat_amount,0) as sum_oc_vat_amount
806 from jrnx left join operation_currency using (j_id)
807 ) as v1 on (v1.j_id=j1.j_id )
808 left join jrn on jr_grpt_id=j_grpt".
809 " left join parm_periode on (p_id=jr_tech_per) ".
810 " where j_qcode=$1 and ".
811 " ( to_date($2,'DD.MM.YYYY') <= j_date and ".
812 " to_date($3,'DD.MM.YYYY') >= j_date )".
813 " and $filter_sql $sql_let ".
814 " order by j_date,substring(jr_pj_number,'[0-9]+$')",array(
$qcode,$p_from,$p_to));
816 $res_saldo = $this->
cn->exec_sql(
"select sum(deb_montant),sum(cred_montant) from
817 (select case when j_debit='t' then j_montant else 0 end as deb_montant,
818 case when j_debit='f' then j_montant else 0 end as cred_montant
820 join jrn_def on (jrn_def_id=j_jrn_def )
821 join jrn on (jr_grpt_id=j_grpt)
822 join tmp_pcmn on (j_poste=pcm_val)
823 join parm_periode on (p_id=jr_tech_per)
825 ( to_date($2,'DD.MM.YYYY') <= j_date and
826 to_date($3,'DD.MM.YYYY') >= j_date )
827 and $filter_sql $sql_let ) as m",array($this->
id,$p_from,$p_to));
828 $this->tot_deb=$this->tot_cred=0;
849 if ( $this->
id == 0 )
857 $this->row=$this->
cn->get_array(
"select j_date,
858 to_char(j_date,'DD.MM.YYYY') as j_date_fmt,
860 case when j_debit='t' then j_montant else 0 end as deb_montant,
861 case when j_debit='f' then j_montant else 0 end as cred_montant,
862 jr_comment as description,
863 jrn_def_name as jrn_name,
868 left join jrn_def on jrn_def_id=j_jrn_def
869 left join jrn on jr_grpt_id=j_grpt
871 j_qcode=$1 and {$periode}
872 order by j_date::date",array(
875 $res_saldo = $this->
cn->exec_sql(
"select sum(deb_montant),sum(cred_montant) from
876 (select case when j_debit='t' then j_montant else 0 end as deb_montant,
877 case when j_debit='f' then j_montant else 0 end as cred_montant
879 left join jrn_def on jrn_def_id=j_jrn_def
880 left join jrn on jr_grpt_id=j_grpt
882 j_qcode=$1 and {$periode} ) as m",
884 $this->tot_deb=$this->tot_cred=0;
890 return array($this->row,$this->tot_deb,$this->tot_cred);
910 if ( count($this->row ) == 0 )
915 $already_seen=array();
916 echo
'<h2 class="info">'.$this->id.
" ".
$name.
'</h2>';
917 echo
"<TABLE class=\"result\" style=\"width:100%;border-collapse:separate;border-spacing:5px\">";
919 "<TH>"._(
"n° de pièce / Code interne").
" </TH>".
920 "<TH>"._(
"Date").
"</TH>".
921 "<TH>"._(
"Description").
" </TH>".
922 "<TH>"._(
'Montant').
" </TH>".
923 "<TH> "._(
'Débit/Crédit').
" </TH>".
926 foreach ( $this->row as
$op )
928 if ( in_array(
$op[
'jr_internal'],$already_seen) )
931 $already_seen[]=
$op[
'jr_internal'];
932 echo
"<TR style=\"text-align:center;background-color:lightgrey\">".
933 "<td>".$op[
'jr_pj_number'].
" / ".
$op[
'jr_internal'].
"</td>".
934 "<td>".$op[
'j_date'].
"</td>".
935 "<td>".h(
$op[
'description']).
"</td>".
942 echo
$ac->display_jrnx_detail(1);
952 "<TD>$tot_cred</TD>".
982 if ( count($this->row ) == 0 )
988 echo
"<TABLE id=\"tbpopup\" class=\"resultfooter\" style=\"margin:1%;width:98%;;border-collapse:collapse;border-spacing:0px 5px\">";
992 echo
"<TABLE id=\"tb" .
$from_div .
"\"class=\"result\" style=\"margin:1%;width:98%;border-collapse:collapse;border-spacing:0px 2px\">";
996 "<TH style=\"text-align:left\">"._(
'Date').
"</TH>".
997 "<TH style=\"text-align:left\">"._(
'Pièce').
" </TH>".
998 "<TH style=\"text-align:left\">"._(
'Poste').
" </TH>".
999 "<TH style=\"text-align:left\">"._(
'Interne').
" </TH>".
1000 "<TH style=\"text-align:left\">"._(
'Tiers').
" </TH>".
1001 "<TH style=\"text-align:left\">"._(
'Description').
" </TH>".
1002 "<TH style=\"text-align:left\">"._(
'Type').
"</TH>".
1003 "<TH style=\"text-align:left\">"._(
'ISO').
"</TH>".
1004 "<TH style=\"text-align:right\">"._(
'Dev.').
"</TH>".
1005 "<TH style=\"text-align:right\">"._(
'Débit').
" </TH>".
1006 "<TH style=\"text-align:right\">"._(
'Crédit').
" </TH>".
1007 th(
'Prog.',
'style="text-align:right"').
1008 th(
'Let.',
'style="text-align:right"');
1011 $old_exercice=
"";$sum_deb=0;$sum_cred=0;
1015 foreach ( $this->row as
$op )
1017 $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']);
1020 if (
$op[
'letter'] !=
"")
1022 $let = strtoupper(base_convert(
$op[
'letter'], 10, 36));
1024 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;
1026 $tmp_diff=bcsub($op['deb_montant'],$op['cred_montant']);
1029 * reset prog. balance to zero if we change of exercice
1031 if ( $old_exercice != $op['p_exercice'])
1033 if ($old_exercice != '' )
1035 $progress=bcsub($sum_deb,$sum_cred);
1036 $side="
".$this->get_amount_side($progress);
1037 echo "<TR
class=\
"highlight\">".
1038 "<TD>$old_exercice</TD>".
1046 "<TD style=\"text-align:right\">".nbm($sum_deb).
"</TD>".
1047 "<TD style=\"text-align:right\">".nbm($sum_cred).
"</TD>".
1058 $sum_cred=bcadd($sum_cred,
$op[
'cred_montant']);
1059 $sum_deb=bcadd($sum_deb,
$op[
'deb_montant']);
1064 $op_analytic=(
$op[
'op_analytic']==1)?
'<span style="float:right;background:black;color:white;">∋</span>':
'';
1065 echo
"<TR $class name=\"tr_" .
$let .
"_" .
$from_div .
"\">" .
1067 td(
h(
$op[
'jr_pj_number'])).
1069 "<TD>".$vw_operation.
"</TD>".
1071 "<TD>".h(
$op[
'description']).$op_analytic.
"</TD>".
1072 td(
$op[
'jr_optype']);
1075 if (
$op[
'currency_id'] > 0 &&
$op[
'oc_amount'] != 0)
1077 echo
td(
$op[
'cr_code_iso']).
1078 td(
nbm(
$op[
'oc_amount'],4),
'style="text-align:right;padding-left:10px;"');
1083 echo
"<TD style=\"text-align:right\">".nbm(
$op[
'deb_montant']).
"</TD>".
1084 "<TD style=\"text-align:right\">".nbm(
$op[
'cred_montant']).
"</TD>".
1086 td($html_let,
' style="text-align:right"') .
1088 $old_exercice=
$op[
'p_exercice'];
1091 $solde_type=
_(
"Année ").($sum_deb>$sum_cred)?
_(
"solde débiteur"):
_(
"solde créditeur");
1092 $solde_side=($sum_deb>$sum_cred)?
"D":
"C";
1093 $diff=abs(bcsub($sum_deb,$sum_cred));
1095 echo
"<TR class=\"highlight\">".
1096 td(
$op[
'p_exercice']).
1105 "<TD style=\"text-align:right\">".nbm($sum_deb).
"</TD>".
1106 "<TD style=\"text-align:right\">".nbm($sum_cred).
"</TD>".
1107 "<TD style=\"text-align:right\">".nbm(
$diff).
"</TD>".
1110 echo
"<TR style=\"font-weight:bold\">".
1111 "<TD>$solde_type</TD>".
1112 "<TD style=\"text-align:right\">".nbm(
$diff).
"</TD>".
1117 $solde_until_now=$this->
get_solde_detail(
" j_date <= to_date('{$p_array['to_periode']}','DD.MM.YYYY') ");
1118 echo
'<tr style="font-weight:bold;color:orangered">';
1119 echo
td(
_(
"Solde global"));
1120 echo
td(
"D : ".
nbm($solde_until_now[
'debit']),
'class="num"');
1121 echo
td(
"C : ".
nbm($solde_until_now[
'credit']),
'class="num"');
1122 echo
td(
"Delta : ".
nbm($solde_until_now[
'solde']).
" ".$this->
get_amount_side($solde_until_now[
'debit']-$solde_until_now[
'credit']),
'class="num"');
1144 echo
'<div class="noprint">';
1148 echo
'<TD><form method="GET" ACTION="">'.
1149 HtmlInput::submit(
'bt_other',
_(
"Autre poste")).
1150 HtmlInput::array_to_hidden(array(
'gDossier',
'ac'),
$_REQUEST).
1152 $hid->input(
"type",
"poste").$hid->input(
'p_action',
'impress').
"</form></TD>";
1155 echo
'<TD><form method="GET" ACTION="export.php" ';
1156 $id=uniqid(
"export_");
1157 printf(
'id="%s" onsubmit="download_document_form(\'%s\')">',
$id,
$id);
1159 HtmlInput::submit(
'bt_pdf',
_(
"Export PDF")).
1160 dossier::hidden().$str_ople.
1161 HtmlInput::hidden(
'act',
'PDF:fichedetail').
1162 $hid->input(
"type",
"poste").
1163 $hid->input(
'p_action',
'impress').
1164 $hid->input(
"f_id",$this->
id).
1168 if (isset(
$p_array[
'oper_detail']))
1169 echo
$hid->input(
'oper_detail',
'on');
1171 echo
"</form></TD>";
1173 echo
'<TD><form method="GET" ACTION="export.php" ';
1174 $id=uniqid(
"export_");
1175 printf(
'id="%s" onsubmit="download_document_form(\'%s\')">',
$id,
$id);
1177 echo HtmlInput::submit(
'bt_csv',
_(
"Export CSV")).
1178 HtmlInput::hidden(
'act',
'CSV:fichedetail').
1179 dossier::hidden().$str_ople.
1180 $hid->input(
"type",
"poste").
1181 $hid->input(
'p_action',
'impress').
1182 $hid->input(
"f_id",$this->
id).
1185 if (isset(
$p_array[
'oper_detail']))
1186 echo
$hid->input(
'oper_detail',
'on');
1188 echo
"</form></TD>";
1189 echo
"</form></TD>";
1190 echo
'<td style="vertical-align:top">';
1191 echo HtmlInput::print_window();
1205 if ( $this->
id == 0 )
return array(
'credit'=>0,
'debit'=>0,
'solde'=>0);
1208 if ( $p_cond !=
"") $p_cond=
" and ".$p_cond;
1209 $Res=$this->
cn->exec_sql(
"select coalesce(sum(deb),0) as sum_deb,
1210 coalesce(sum(cred),0) as sum_cred from
1212 case when j_debit='t' then j_montant else 0 end as deb,
1213 case when j_debit='f' then j_montant else 0 end as cred
1216 j_qcode = ('$qcode'::text)
1220 if (
$Max==0)
return 0;
1223 return array(
'debit'=>
$r[
'sum_deb'],
1224 'credit'=>
$r[
'sum_cred'],
1225 'solde'=>abs(
$r[
'sum_deb']-
$r[
'sum_cred']));
1235 if ( $this->
id == 0 )
throw new Exception(
'fiche->id est nul');
1237 if ( $p_cond !=
"") $p_cond=
" and ".$p_cond;
1240 select sum(sum_oc_amount)
1246 $val=$this->
cn->get_value(
$sql,[$this->
id]);
1257 if ( $this->
id == 0 )
throw new Exception(
'fiche->id est nul');
1260 if ( $p_cond !=
"") $p_cond=
" and ".$p_cond;
1261 $sql=
"select sum(deb) as sum_deb, sum(cred) as sum_cred from
1263 case when j_debit='t' then j_montant else 0 end as deb,
1264 case when j_debit='f' then j_montant else 0 end as cred
1266 join jrn on (jr_grpt_id=j_grpt)
1268 j_qcode = ('$qcode'::text)
1274 if (
$Max==0)
return 0;
1277 return array(
'debit'=>
$r[
'sum_deb'],
1278 'credit'=>
$r[
'sum_cred'],
1279 'solde'=>abs(
$r[
'sum_deb']-
$r[
'sum_cred']));
1288 $sql=
"select ad_value
1291 left join attr_def using (ad_id) where f_id=$1 ".
1294 $res=$this->
cn->exec_sql(
$sql,[$this->
id,$p_attr]);
1328 $filter_year=
" j_tech_per in (select p_id from parm_periode ".
1329 "where p_exercice='".$g_user->get_exercice().
"')";
1331 if ( $p_amount) $filter_amount=
' and f_id in (select f_id from jrnx where '.$filter_year.
')';
1333 $all_tiers=$this->
count_by_modele($this->fiche_def_ref,
"",$p_sql.$filter_amount);
1336 $page=
$http->request(
"page",
"number",1);
1344 $search.=
" and f_id in
1345 (select distinct f_id from fiche_detail
1347 ad_id in (1,32,30,23,18,13) and ad_value ilike '%$p_search%')";
1352 if ( $all_tiers == 0 || empty($step_tiers ) ) {
return ""; }
1356 $r.=
'<table id="tiers_tb" class="sortable" style="">
1358 <TH>'._(
'Quick Code').Icon_Action::infobulle(17).
'</TH>'.
1359 '<th>'._(
'Poste comptable').
'</th>'.
1360 '<th class="sorttable_sorted">'._(
'Nom').
'</span>'.
'</th>
1361 <th>'._(
'Adresse').
'</th>
1362 <th>'.
_(
'site web').
'</th>
1363 <th style="text-align:right">'.
_(
'Total débit').
'</th>
1364 <th style="text-align:right">'.
_(
'Total crédit').
'</th>
1365 <th style="text-align:right">'.
_(
'Solde').
'</th>';
1367 if (
sizeof ($step_tiers ) == 0 )
1372 foreach ($step_tiers as
$tiers )
1378 list($l_from,$l_to)=(
new Periode($this->
cn))->get_limit(
$g_user->get_exercice());
1379 $condition = sprintf (
" j_date <= to_date('%s','DD.MM.YYYY') ", $l_to->last_day());
1386 if ( $p_amount &&
$amount[
'debit']==0 &&
$amount[
'credit'] == 0 &&
$amount[
'solde'] == 0 )
continue;
1389 $odd = (
$i % 2 == 0 ) ?
' odd ':
' even ';
1395 (!empty ($bank->value) && strpos(
$accounting,$bank->p_value)===0 )
1396 || (!empty ($cash->value) && strpos(
$accounting,$cash->p_value)===0 )
1397 || ( !empty ($cc->value) && strpos(
$accounting,$cc->p_value)===0)
1405 $odd=
' class="'.$odd.
'"';
1409 $e=sprintf(
'<A HREF="%s" title="Détail" class="line"> ',
1413 $r.=
"<TD sorttable_customkey=\"text{$accounting}\"> $e".$accounting.
"</TD>";
1423 $r.=
'<TD sorttable_customkey="'.$amount[
'debit'].
'" align="right"> '.$str_deb.
'</TD>';
1424 $r.=
'<TD sorttable_customkey="'.$amount[
'credit'].
'" align="right"> '.$str_cred.
'</TD>';
1436 $r.=
'<TD class="'.$red.
'" sorttable_customkey="'.
$amount[
'solde'].
'" align="right"> '.$str_solde.
"$side </TD>";
1446 $r.=
'<tr class="highlight">';
1447 $r.=
td(
"").td(
"").td(
"").td(
"").td(
"Totaux").td(
nbm(
$deb),
'class="num"').td(
nbm(
$cred),
'class="num"').td(
" $side ".
nbm(
$solde),
'class="num"');
1460 if ( $this->
id == 0 )
throw new Exception(
'class_fiche : f_id = 0 ');
1461 $sql=
'select fd_id from fiche where f_id=$1';
1462 $R=$this->
cn->get_value(
$sql, array($this->
id));
1487 if (($this->quick_code==
null || $this->quick_code ==
"" )
1490 throw new Exception(
'erreur ni quick_code ni f_id ne sont donnes');
1494 if ( $this->quick_code==
"")
1498 if ( $this->quick_code==
null)
1501 if ( $this->
id == 0 )
1508 $get=
'jrn_def_fiche_deb';
1511 $get=
'jrn_def_fiche_cred';
1515 $Res=$this->
cn->exec_sql(
"select $get as fiche from jrn_def where jrn_def_id=$p_jrn");
1520 $Res=$this->
cn->exec_sql(
" select jrn_def_fiche_cred as fiche
1521 from jrn_def where jrn_def_id=$p_jrn
1523 select jrn_def_fiche_deb
1524 from jrn_def where jrn_def_id=$p_jrn"
1538 if (
$row[
'fiche'] !=
'' )
1540 $str_list.=$comma.$row[
'fiche'];
1554 fd_id in (".$str_list.
") and f_id= ".
$this->id;
1574 $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';
1577 $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';
1580 $sql=
'select f_id from fiche where fd_id=$1 ';
1582 $array=$p_cn->get_array(
$sql,array($pFd_id));
1593 $sql=
'select count(*) as c from jrnx where j_qcode=$1';
1595 if (
$count > 0 )
return TRUE;
1596 $count=$this->
cn->get_value(
"select count(*) from action_gestion where f_id_dest=$1 or ag_contact=$1 ",
1598 if (
$count > 0 )
return TRUE;
1599 $count=$this->
cn->get_value(
"select count(*) from action_person where f_id=$1 ",
1601 if (
$count > 0 )
return TRUE;
1606 join fiche_detail using (ad_id)
1607 where ad_type='card'
1611 if (
$count > 0 )
return TRUE;
1622 $Res=$this->
cn->exec_sql(
"delete from fiche_detail
1624 f_id= $1",[ $this->
id] );
1627 $Res=$this->
cn->exec_sql(
"delete from fiche where f_id=$1",[$this->
id]);
1629 $this->
cn->commit();
1648 extract(
$array, EXTR_SKIP);
1650 $filter_fd_id=
'true';
1660 throw Exception(
'Erreur pas de valeur pour jrn');
1661 $filter_jrn=$this->
cn->make_list(
"select jrn_def_fiche_cred from jrn_Def where jrn_def_id=$1",
1663 $filter_fd_id=(empty($filter_jrn))?
" fd_id in (-1) ":
" fd_id in (".$filter_jrn.
")";
1668 throw Exception(
'Erreur pas de valeur pour jrn');
1669 $filter_jrn=$this->
cn->make_list(
"select jrn_def_fiche_deb from jrn_Def where jrn_def_id=$1",
1671 $filter_fd_id=(empty($filter_jrn))?
"fd_id in (-1) ":
" fd_id in (".$filter_jrn.
")";
1676 throw Exception(
'Erreur pas de valeur pour jrn');
1677 $filter_jrn=$this->
cn->make_list(
"select jrn_def_fiche_deb from jrn_Def where jrn_def_id=$1",
1681 $fp1=
" fd_id in (".$filter_jrn.
")";
1685 $filter_jrn=$this->
cn->make_list(
"select jrn_def_fiche_cred from jrn_Def where jrn_def_id=$1",
1689 $fp2=
" fd_id in (".$filter_jrn.
")";
1693 $filter_fd_id=
'('.$fp1.
' or '.$fp2.
')';
1698 $filter_fd_id=
' true';
1702 $filter_fd_id=
' fd_id in ('.$typecard.
')';
1704 $filter_fd_id=
' fd_id < 0';
1721 $filter_query=$and.
"(vw_name ilike '%$query%' or quick_code ilike ('%$query%') "
1722 .
" or vw_description ilike '%$query%' or tva_num ilike '%$query%' or accounting like upper('$query%'))";
1729 $sql=
"select * from vw_fiche_attr where ".$filter_fd_id.$filter_query;
1741 $this->
cn->exec_sql(
'update fiche set fd_id=$1 where f_id=$2',array($p_fdid,$this->
id));
1743 $this->
cn->exec_sql(
'select fiche_attribut_synchro($1)',array($p_fdid));
1745 $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));
1746 $this->
cn->commit();
1764 $cn=Dossier::connect();
1766 echo
h1(
'Test select category');
1769 $select_cat->value=
$cn->make_array(
'select fd_id,fd_label from fiche_def where frd_id='.
1771 echo
'<FORM METHOD="GET"> ';
1772 echo dossier::hidden();
1773 echo HtmlInput::hidden(
'test_select',
$http->get(
'test_select',
"string",1));
1774 echo
'Choix de la catégorie';
1776 echo HtmlInput::submit(
'go_card',
'Afficher');
1778 if ( isset (
$_GET[
'go_card']))
1780 $empty=
$a->to_array(
$_GET[
'fd_id']);
1784 echo
h1(
"Insert new card");
1785 $name=
"test ".microtime();
1795 echo
p(print_r(
$fiche->to_array(),
false));
1803 echo
p(
"accounting id",$acc_accounting->get_parameter(
"id"));
1804 assert($acc_accounting->get_lib(
"pcm_lib") ==
$name,
"Cannot create a new accouting with
1825 $href=
"export.php?".http_build_query(
1827 "gDossier"=>Dossier::id(),
1831 "from_periode"=>$p_from,
1832 "to_periode"=>$p_to,
1833 "act"=>
"CSV:fichedetail"
1836 return '<a class="smallbutton" style="display:inline-block" href="'.$href.
'">'.
_(
"Export CSV").
'</a>';
1847 $href=
"export.php?".http_build_query(
1849 "gDossier"=>Dossier::id(),
1853 "from_periode"=>$p_from,
1854 "to_periode"=>$p_to,
1855 "act"=>
"PDF:fichedetail"
1858 return '<a class="smallbutton" style="display:inline-block" href="'.$href.
'">'.
_(
"Export PDF").
'</a>';
1868 return _(
'Cherche').
' '.HtmlInput::filter_table($p_table_id,
'0,1,2,3,4,5,6,7,8,9,10', 1);
1876 $id=$this->
cn->get_value(
"select jrn_def_id from jrn_def where jrn_def_bank = $1 ",[$this->
id]);
1877 if ($id ==
"") {
return NULL;}
1882 catch (Exception
$e) {
1897 foreach($this->attribut as
$attr) {
1900 if (
$attr->ad_type!=
'select')
1903 if (
$attr->ad_type==
"date") {
1905 $sort=
'sorttable_customkey="'.format_date(
$attr->av_text,
"DD.MM.YYYY",
"YYYYMMDD").
'"';
1908 $sort=
'sorttable_customkey="TEXT'.$attr->av_text.
'"';
1910 echo
td(
$attr->av_text,
'style="padding: 0 10 1 10;white-space:nowrap;" '.$sort);
1921 echo
td($row_content,
'style="padding: 0 10 1 10;white-space:nowrap;"');
1933 $cn=Dossier::connect();
1935 $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 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(isset( $_REQUEST[ 'show'])) if(isset($_REQUEST['del'])) $ac
_("actif, passif,charge,...")
if(! isset($_GET['submit_query'])) $p_action
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
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
$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
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)
!< 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 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...
const NOTFOUND(!defined("SYSINFO_DISPLAY"))
const ATTR_DEF_FIRST_NAME
foreach( $Fiche->row as $op) $solde_type
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