23 include_once(
"class/class_fiche_attr.php");
24 require_once NOALYSS_INCLUDE.
'/lib/class_ispan.php';
25 require_once NOALYSS_INCLUDE.
'/lib/class_itva_popup.php';
26 require_once NOALYSS_INCLUDE.
'/lib/class_itext.php';
27 require_once NOALYSS_INCLUDE.
'/lib/class_ihidden.php';
28 require_once NOALYSS_INCLUDE.
'/class/class_fiche_def.php';
29 require_once NOALYSS_INCLUDE.
'/lib/class_iposte.php';
74 $sql_ledger=$g_user->get_ledger_sql(
'FIN',3);
75 $avail=$this->
cn->get_array(
"select jrn_def_id,jrn_def_name,"
76 .
"jrn_def_bank,jrn_def_description from jrn_def where jrn_def_type='FIN' and $sql_ledger
77 order by jrn_def_name");
79 if ( count($avail) == 0 )
82 for ($i=0;$i<count($avail);$i++)
84 $t=
new Fiche($this->
cn,$avail[$i][
'jrn_def_bank']);
85 $t->ledger_name=$avail[$i][
'jrn_def_name'];
86 $t->ledger_description=$avail[$i][
'jrn_def_description'];
106 if ( $p_qcode == null )
108 $p_qcode=
trim($p_qcode);
109 $sql=
"select f_id from fiche_detail
110 where ad_id=23 and ad_value=upper($1)";
111 $this->
id=$this->
cn->get_value(
$sql,array($p_qcode));
112 if ( $this->
cn->count()==0)
132 if (
sizeof($this->attribut)==0 ) $this->
getAttribut();
135 if ( $this->attribut[
$e]->ad_id == $p_ad_id )
137 $this->attribut[
$e]->av_text=$p_value;
155 natural join fiche_detail
156 join jnt_fic_attr on (jnt_fic_attr.fd_id=fiche.fd_id and fiche_detail.ad_id=jnt_fic_attr.ad_id)
157 join attr_def on (attr_def.ad_id=fiche_detail.ad_id) where f_id=".$this->id.
158 " order by jnt_order";
163 for ($i=0;$i<
$Max;$i++)
166 $this->fiche_def=
$row[
'fd_id'];
168 $t->ad_id=
$row[
'ad_id'];
169 $t->ad_text=
$row[
'ad_text'];
170 $t->av_text=
$row[
'ad_value'];
171 $t->ad_type=
$row[
'ad_type'];
172 $t->ad_size=
$row[
'ad_size'];
173 $t->ad_extra=
$row[
'ad_extra'];
174 $t->jnt_order=
$row[
'jnt_order'];
175 $this->attribut[$i]=$t;
180 if (
sizeof($this->attribut) !=
sizeof(
$e->attribut ) )
186 foreach (
$e->attribut as
$f )
189 foreach ($this->attribut as $g )
191 if ( $g->ad_id == $f->ad_id )
199 $t->ad_text=$f->ad_text;
200 $t->jnt_order=$f->jnt_order;
201 $t->ad_type=$f->ad_type;
202 $t->ad_size=$f->ad_size;
204 $t->ad_extra=$f->ad_extra;
205 $this->attribut[
$Max]=$t;
220 function seek($p_attribut,$p_value)
222 $sql=
"select jft_id,f_id,fd_id,ad_id,ad_value from fiche join fiche_detail using (f_id)
223 where ad_id=$1 and upper(ad_value)=upper($2)";
224 $res=$this->
cn->get_array(
$sql,array($p_attribut,$p_value));
235 if ( isset ($this->ad_id))
236 return sizeof($this->ad_id);
256 fiche join fiche_Def using (fd_id)
257 where frd_id=".$p_frd_id;
258 if ( $p_search !=
"" )
261 $sql=
"select * from vw_fiche_attr where frd_id=".$p_frd_id.
262 " and vw_name ~* '$p_search'";
293 if ( $p_offset == -1 )
297 fiche join fiche_Def using (fd_id) join vw_fiche_name using(f_id)
298 where frd_id=".$p_frd_id.
" $p_search ".
$order;
302 $limit=($_SESSION[
'g_pagesize']!=-1)?
"limit ".$_SESSION[
'g_pagesize']:
"";
305 fiche join fiche_Def using (fd_id) join vw_fiche_name using(f_id)
306 where frd_id=".$p_frd_id.
" $p_search $order "
307 .$limit.
" offset ".$p_offset;
316 for ($i=0;$i<
$Max;$i++)
331 $this->attribut_value.
"</TD>".
333 $this->attribut_def.
"</TD></TR>";
346 if (
sizeof ($this->attribut) == 0 )
353 $sql=
"select ad_value from fiche_detail
354 where f_id= $1 and ad_id= $2 ";
355 $Res=$this->
cn->exec_sql(
$sql,array($this->
id,$p_ad_id));
361 return $row[0][
'ad_value'];
364 foreach ($this->attribut as
$e)
366 if ( $e->ad_id == $p_ad_id )
400 $sql=
"select 'av_text'||to_char(ad_id,'9999') as key,".
402 " from fiche_def join jnt_fic_attr using (fd_id)".
403 " join attr_def using (ad_id) ".
404 " where fd_id=$1 order by jnt_order";
405 $ret=$this->
cn->get_array(
$sql,array($pfd_id));
406 if ( empty(
$ret))
throw new Exception(_(
'Cette categorie de card n\'existe pas').
' '.$pfd_id,1);
410 $a=str_replace(
' ',
'',
$val[
'key']);
430 $r=
h2(_(
'Catégorie').
' '.
$f->label,
"");
431 $r.=
'<table style="width:98%;margin:1%">';
438 $w=
new IPoste(
"av_text".$attr->ad_id);
439 $w->set_attribute(
'ipopup',
'ipop_account');
440 $w->set_attribute(
'account',
"av_text".$attr->ad_id);
441 $w->dbl_click_history();
443 $sql=
"select account_auto($p_fiche_def)";
444 $ret_sql=$this->
cn->exec_sql(
$sql);
447 $label->name=
"av_text".$attr->ad_id.
"_label";
449 if (
$a[
'account_auto'] ==
't' )
450 $msg.=
$label->input().
" <span style=\"color:red\">".
451 _(
"Rappel: Poste créé automatiquement à partir de ")
452 .$f->class_base.
" </span> ";
457 if ( strlen(
trim(
$f->class_base)) != 0 )
459 $msg.=
"<TD>".$label->input().
" <span style=\"color:red\">"._(
"Rappel: Poste par défaut sera ").
462 $w->value=
$f->class_base;
466 $r.=
"<TR>".td(_(
"Poste Comptable"),
' class="input_text" ' ).td(
$w->input().$msg).
"</TR>";
477 switch ($attr->ad_type)
481 $w->css_size =
"100%";
485 $w->prec=($attr->ad_extra==
"")?2:$attr->ad_extra;
486 $w->size = $attr->ad_size;
492 $w =
new ITextArea();
493 $w->style=
' class="itextarea" style="margin:0px;width:100%"';
496 $w =
new IPoste(
"av_text" . $attr->ad_id);
497 $w->set_attribute(
'ipopup',
'ipop_account');
498 $w->set_attribute(
'account',
"av_text" . $attr->ad_id);
503 $w =
new ISelect(
"av_text" . $attr->ad_id);
504 $w->value = $this->
cn->make_array($attr->ad_extra);
505 $w->style=
'style="width:100%"';
508 $w =
new ICard(
"av_text" . $attr->ad_id);
510 $w->extra = $attr->ad_extra;
513 $label->name =
"av_text" . $attr->ad_id .
"_label";
514 $w->set_attribute(
'ipopup',
'ipopcard');
515 $w->set_attribute(
'typecard', $attr->ad_extra);
516 $w->set_attribute(
'inp',
"av_text" . $attr->ad_id);
517 $w->set_attribute(
'label',
"av_text" . $attr->ad_id .
"_label");
525 $w->label = $attr->ad_text;
526 $w->name =
"av_text" . $attr->ad_id;
527 if ($attr->ad_id == 21 || $attr->ad_id==22||$attr->ad_id==20||$attr->ad_id==31)
531 $r.=
"<TR>" .
td(_(
$w->label).
" $bulle",
' class="input_text" ') .
td(
$w->input().
" $msg").
" </TR>";
548 $this->GetAttribut();
551 $type_card=$this->
cn->get_value(
'select fd_label '
552 .
' from fiche_def join fiche using (fd_id) where f_id=$1',
555 $ret.=
h2(_(
"Catégorie").
" ".$type_card,
'style="display:inline"');
556 $ret.=
'<span style="margin-right:5px;float:right">'.
557 _(
'id fiche').
':'.$this->
id.
"</span>";
558 $ret.=
"<table style=\"width:98%;margin:1%\">";
565 foreach ($attr as
$r)
582 $w->set_attribute(
'ipopup',
'ipop_account');
583 $w->set_attribute(
'account',
"av_text".$r->ad_id);
584 $w->dbl_click_history();
587 $w->value=$r->av_text;
589 $sql=
"select account_auto($this->fiche_def)";
590 $ret_sql=$this->
cn->exec_sql(
$sql);
594 if (
$a[
'account_auto']==
't')
601 $w->value=$r->av_text;
608 $w=
new IText(
'av_text'.$r->ad_id);
610 $w->value=$r->av_text;
613 $w=
new INum(
'av_text'.$r->ad_id);
614 $w->size=$r->ad_size;
615 $w->prec=($r->ad_extra==
"")?2:$r->ad_extra;
616 $w->value=$r->av_text;
619 $w=
new IDate(
'av_text'.$r->ad_id);
620 $w->value=$r->av_text;
623 $w=
new ITextArea(
'av_text'.$r->ad_id);
624 $w->style=
' class="itextarea" style="margin:0px;width:100%"';
625 $w->value=$r->av_text;
629 $w->set_attribute(
'ipopup',
'ipop_account');
630 $w->set_attribute(
'account',
"av_text".$r->ad_id);
631 $w->dbl_click_history();
632 $w->width=$r->ad_size;
635 $w->value=$r->av_text;
639 $w=
new ICard(
"av_text".$r->ad_id);
640 $w->id=
"card_".$this->id.$uniq;
643 $filter=$r->ad_extra;
644 $w->width=$r->ad_size;
648 $label->name=
"av_text".$uniq.$r->ad_id.
"_label";
650 $fiche->get_by_qcode($r->av_text);
653 $label->value=(
trim($r->av_text)==
'')?
"":
" "._(
"Fiche non trouvée").
" ";
662 $w->set_attribute(
'ipopup',
'ipopcard');
663 $w->set_attribute(
'typecard', $filter);
664 $w->set_attribute(
'inp',
"av_text".$r->ad_id);
665 $w->set_attribute(
'label',
$label->name);
667 $w->dblclick=
"fill_ipopcard(this);";
670 $w->value=$r->av_text;
674 $w->value=$this->
cn->make_array($r->ad_extra);
675 $w->selected=$r->av_text;
676 $w->style=
' style="width:100%" ';
680 throw new Exception(
"Type invalide");
691 $x->value=$this->
cn->make_array($r->ad_extra);
692 $x->selected=$r->av_text;
697 $w->value=$r->av_text;
701 $w->name=
"av_text".$r->ad_id;
704 if ($r->ad_id==21||$r->ad_id==22||$r->ad_id==20||$r->ad_id==31)
708 $ret.=
"<TR>".td(_($r->ad_text).$bulle).td(
$w->input().
" ".
$msg).
" </TR>";
724 if ( $this->
id == 0 )
725 $this->
insert($p_fiche_def);
748 $fiche_id=$this->
cn->get_next_seq(
's_fiche');
761 $sql=sprintf(
"insert into fiche(f_id,fd_id)".
762 " values (%d,%d)", $fiche_id, $p_fiche_def);
768 if (preg_match(
'/^av_text[0-9]+$/',
$name)==0)
771 list (
$id)=sscanf(
$name,
"av_text%d");
779 $sql=sprintf(
"select insert_quick_code(%d,'%s')", $fiche_id,
781 $this->
cn->exec_sql(
$sql);
797 if (strlen(
trim($v))!=0)
799 if (strpos(
$value,
',')==0)
801 $v=$this->
cn->get_value(
"select format_account($1)",
806 $ac_array=explode(
",",
$value);
807 if (count($ac_array)<>2)
808 throw new Exception(
'Désolé, il y a trop de virgule dans le poste comptable '.
h(
$value));
811 $part1=$this->
cn->get_value(
'select format_account($1)',
813 $part2=$this->
cn->get_value(
'select format_account($1)',
815 $v=$part1.
','.$part2;
817 $parameter=array($this->
id, $v);
821 $parameter=array($this->
id, null);
823 $v=$this->
cn->get_value(
"select account_insert($1,$2)",
828 throw new Exception(
"Erreur : ce compte [$v] n'a pas de compte parent.".
829 "L'opération est annulée", 1);
841 if ($this->
cn->count_sql(
"select * from tva_rate where tva_id=".$value)==0)
850 $sql=sprintf(
"select attribut_insert(%d,%d,'%s')", $fiche_id,
851 $id, strip_tags(
trim($value2)));
852 $this->
cn->exec_sql(
$sql);
857 $this->
cn->rollback();
880 if (preg_match(
'/^av_text[0-9]+$/',
$name)==0)
883 list (
$id)=sscanf(
$name,
"av_text%d");
889 $sql=
" select jft_id from fiche_detail where ad_id=$id and f_id=$this->id";
894 $jft_id=$this->
cn->get_next_seq(
's_jnt_fic_att_value');
896 $sql2=
"insert into fiche_detail(jft_id,ad_id,f_id,ad_value) values ($1,$2,$3,NULL)";
898 $ret2=$this->
cn->exec_sql($sql2,
899 array($jft_id,
$id, $this->
id));
904 $jft_id=
$tmp[
'jft_id'];
910 $sql=sprintf(
"select update_quick_code(%d,'%s')", $jft_id,
912 $this->
cn->exec_sql(
$sql);
927 if (strpos($v,
',')!=0)
929 $ac_array=explode(
",", $v);
930 if (count($ac_array)<>2)
931 throw new Exception(
'Désolé, il y a trop de virgule dans le poste comptable '.
h($v));
934 $part1=$this->
cn->get_value(
'select format_account($1)',
936 $part2=$this->
cn->get_value(
'select format_account($1)',
938 $v=$part1.
','.$part2;
942 $v=$this->
cn->get_value(
'select format_account($1)',
945 $sql=sprintf(
"select account_update(%d,'%s')",
949 $this->
cn->exec_sql(
$sql);
953 throw new Exception(__LINE__.
"Erreur : ce compte [$v] n'a pas de compte parent.".
954 "L'opération est annulée");
958 if (strlen(
trim($v))==0)
961 $sql=sprintf(
"select account_update(%d,null)", $this->
id);
968 throw new Exception(__LINE__.
"Erreur : ce compte [$v] n'a pas de compte parent.".
969 "L'opération est annulée");
981 if ($this->
cn->count_sql(
"select * from tva_rate where tva_id=".$value)==0)
988 $sql=
"update fiche_detail set ad_value=$1 where jft_id=$2";
989 $this->
cn->exec_sql(
$sql, array(strip_tags(
$value), $jft_id));
994 echo
'<span class="error">'.
997 error_log($e->getMessage());
998 error_log($e->getTraceAsString());
999 $this->
cn->rollback();
1002 $this->
cn->commit();
1008 function remove($silent=
false)
1010 if ( $this->
id==0 )
return;
1021 if ( $this->
cn->count_sql(
"select * from jrnx where j_qcode='".Database::escape_string(
$qcode).
"'") != 0)
1024 alert(_(
'Impossible cette fiche est utilisée dans un journal'));
1039 $sql=
"select ad_value from fiche_detail
1040 where ad_id=1 and f_id=$1";
1041 $Res=$this->
cn->exec_sql(
$sql,array($this->
id));
1043 if (
sizeof(
$r) == 0 )
1045 return $r[0][
'ad_value'];
1053 $sql=
"select ad_value from fiche_detail where ad_id=23 and f_id=$1";
1054 $Res=$this->
cn->exec_sql(
$sql,array($this->
id));
1056 if (
sizeof(
$r) == 0 )
1058 return $r[0][
'ad_value'];
1080 return fiche::GetByDef($this->fiche_def_ref,$p_offset,$p_search,
$p_order);
1088 $result=$this->
cn->get_array(
"select frd_id from fiche join fiche_Def using (fd_id) where f_id=".$this->
id);
1104 if (
$Max == 0 )
return null;
1106 for ($i=0;$i<
$Max;$i++)
1109 if (
$array[$i][
'j_debit']==
't')
1134 if ( $this->
id == 0 )
1136 echo_error(
"class_fiche",__LINE__,
"id is 0");
1139 $filter_sql=$g_user->get_ledger_sql(
'ALL',3);
1146 $sql_let=
' and j_id in (select j_id from letter_cred union select j_id from letter_deb)';
1149 $sql_let=
' and j_id not in (select j_id from letter_cred union select j_id from letter_deb) ';
1154 $Res=$this->
cn->exec_sql(
"select distinct substring(jr_pj_number,'[0-9]+$'),j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,j_qcode,".
1155 "case when j_debit='t' then j_montant else 0 end as deb_montant,".
1156 "case when j_debit='f' then j_montant else 0 end as cred_montant,".
1157 " jr_comment as description,jrn_def_name as jrn_name,".
1159 "j_debit, jr_internal,jr_id,coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter, ".
1160 " jr_tech_per,p_exercice,jrn_def_name,
1162 " from jrnx left join jrn_def on jrn_def_id=j_jrn_def ".
1163 " left join jrn on jr_grpt_id=j_grpt".
1164 " left join parm_periode on (p_id=jr_tech_per) ".
1165 " where j_qcode=$1 and ".
1166 " ( to_date($2,'DD.MM.YYYY') <= j_date and ".
1167 " to_date($3,'DD.MM.YYYY') >= j_date )".
1168 " and $filter_sql $sql_let ".
1169 " order by j_date,substring(jr_pj_number,'[0-9]+$')",array(
$qcode,$p_from,$p_to));
1185 if ( $this->
id == 0 )
1187 echo_error(
"class_fiche",__LINE__,
"id is 0");
1193 $Res=$this->
cn->exec_sql(
"select j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,j_qcode,".
1194 "case when j_debit='t' then j_montant else 0 end as deb_montant,".
1195 "case when j_debit='f' then j_montant else 0 end as cred_montant,".
1196 " jr_comment as description,jrn_def_name as jrn_name,".
1197 "j_debit, jr_internal,jr_id ".
1198 " from jrnx left join jrn_def on jrn_def_id=j_jrn_def ".
1199 " left join jrn on jr_grpt_id=j_grpt".
1201 " order by j_date::date");
1222 if ( count($this->row ) == 0 )
1227 $already_seen=array();
1228 echo
'<h2 class="info">'.$this->id.
" ".
$name.
'</h2>';
1229 echo
"<TABLE class=\"result\" style=\"width:100%;border-collapse:separate;border-spacing:5px\">";
1231 "<TH>"._(
"n° de pièce / Code interne").
" </TH>".
1232 "<TH>"._(
"Date").
"</TH>".
1233 "<TH>"._(
"Description").
" </TH>".
1234 "<TH>"._(
'Montant').
" </TH>".
1235 "<TH> "._(
'Débit/Crédit').
" </TH>".
1238 foreach ( $this->row as
$op )
1240 if ( in_array($op[
'jr_internal'],$already_seen) )
1243 $already_seen[]=$op[
'jr_internal'];
1244 echo
"<TR style=\"text-align:center;background-color:lightgrey\">".
1245 "<td>".$op[
'jr_pj_number'].
" / ".$op[
'jr_internal'].
"</td>".
1246 "<td>".$op[
'j_date'].
"</td>".
1247 "<td>".h($op[
'description']).
"</td>".
1252 $ac->jr_id=$op[
'jr_id'];
1254 echo
$ac->display_jrnx_detail(1);
1263 "<TD>$tot_deb</TD>".
1264 "<TD>$tot_cred</TD>".
1293 if ( count($this->row ) == 0 )
1299 echo
"<TABLE id=\"tbpopup\" class=\"resultfooter\" style=\"margin:1%;width:98%;;border-collapse:separate;border-spacing:0px 5px\">";
1303 echo
"<TABLE id=\"tb" .
$from_div .
"\"class=\"result\" style=\"margin:1%;width:98%;border-collapse:separate;border-spacing:0px 2px\">";
1307 "<TH style=\"text-align:left\">"._(
'Date').
"</TH>".
1308 "<TH style=\"text-align:left\">"._(
'n° pièce').
" </TH>".
1309 "<TH style=\"text-align:left\">"._(
'Code interne').
" </TH>".
1310 "<TH style=\"text-align:left\">"._(
'Description').
" </TH>".
1311 "<TH style=\"text-align:right\">"._(
'Débit').
" </TH>".
1312 "<TH style=\"text-align:right\">"._(
'Crédit').
" </TH>".
1313 th(
'Prog.',
'style="text-align:right"').
1314 th(
'Let.',
'style="text-align:right"');
1317 $old_exercice=
"";$sum_deb=0;$sum_cred=0;
1320 foreach ( $this->row as
$op )
1322 $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']);
1325 if ($op[
'letter'] != -1)
1327 $let = strtoupper(base_convert($op[
'letter'], 10, 36));
1330 $tmp_diff=bcsub($op[
'deb_montant'],$op[
'cred_montant']);
1335 if ( $old_exercice != $op[
'p_exercice'])
1337 if ($old_exercice !=
'' )
1341 echo
"<TR class=\"highlight\">".
1342 "<TD>$old_exercice</TD>".
1346 "<TD style=\"text-align:right\">".nbm($sum_deb).
"</TD>".
1347 "<TD style=\"text-align:right\">".nbm($sum_cred).
"</TD>".
1358 $sum_cred=bcadd($sum_cred,$op[
'cred_montant']);
1359 $sum_deb=bcadd($sum_deb,$op[
'deb_montant']);
1363 echo
"<TR $class name=\"tr_" .
$let .
"_" .
$from_div .
"\">" .
1364 "<TD>".smaller_date(
format_date($op[
'j_date_fmt'])).
"</TD>".
1365 td(
h($op[
'jr_pj_number'])).
1366 "<TD>".$vw_operation.
"</TD>".
1367 "<TD>".h($op[
'description']).
"</TD>".
1368 "<TD style=\"text-align:right\">".nbm($op[
'deb_montant']).
"</TD>".
1369 "<TD style=\"text-align:right\">".nbm($op[
'cred_montant']).
"</TD>".
1371 td($html_let,
' style="text-align:right"') .
1373 $old_exercice=$op[
'p_exercice'];
1376 $solde_type=($sum_deb>$sum_cred)?
"solde débiteur":
"solde créditeur";
1377 $diff=abs(bcsub($sum_deb,$sum_cred));
1379 echo
"<TR class=\"highlight\">".
1384 "<TD style=\"text-align:right\">".nbm($sum_deb).
"</TD>".
1385 "<TD style=\"text-align:right\">".nbm($sum_cred).
"</TD>".
1386 "<TD style=\"text-align:right\">".nbm(
$diff).
"</TD>".
1389 echo
"<TR style=\"font-weight:bold\">".
1390 "<TD>$solde_type</TD>".
1391 "<TD style=\"text-align:right\">".nbm(
$diff).
"</TD>".
1412 echo
'<div class="noprint">';
1416 echo
'<TD><form method="GET" ACTION="">'.
1420 $hid->input(
"type",
"poste").$hid->input(
'p_action',
'impress').
"</form></TD>";
1423 echo
'<TD><form method="GET" ACTION="export.php">'.
1425 dossier::hidden().$str_ople.
1427 $hid->input(
"type",
"poste").
1428 $hid->input(
'p_action',
'impress').
1429 $hid->input(
"f_id",$this->
id).
1433 if (isset(
$p_array[
'oper_detail']))
1434 echo
$hid->input(
'oper_detail',
'on');
1436 echo
"</form></TD>";
1438 echo
'<TD><form method="GET" ACTION="export.php">'.
1441 dossier::hidden().$str_ople.
1442 $hid->input(
"type",
"poste").
1443 $hid->input(
'p_action',
'impress').
1444 $hid->input(
"f_id",$this->
id).
1447 if (isset(
$p_array[
'oper_detail']))
1448 echo
$hid->input(
'oper_detail',
'on');
1450 echo
"</form></TD>";
1451 echo
"</form></TD>";
1452 echo
'<td style="vertical-align:top">';
1467 if ( $this->
id == 0 )
return array(
'credit'=>0,
'debit'=>0,
'solde'=>0);
1470 if ( $p_cond !=
"") $p_cond=
" and ".$p_cond;
1471 $Res=$this->
cn->exec_sql(
"select sum(deb) as sum_deb, sum(cred) as sum_cred from
1473 case when j_debit='t' then j_montant else 0 end as deb,
1474 case when j_debit='f' then j_montant else 0 end as cred
1477 j_qcode = ('$qcode'::text)
1481 if (
$Max==0)
return 0;
1484 return array(
'debit'=>
$r[
'sum_deb'],
1485 'credit'=>
$r[
'sum_cred'],
1486 'solde'=>abs(
$r[
'sum_deb']-
$r[
'sum_cred']));
1494 if ( $this->
id == 0 )
throw new Exception(
'fiche->id est nul');
1497 if ( $p_cond !=
"") $p_cond=
" and ".$p_cond;
1498 $sql=
"select sum(deb) as sum_deb, sum(cred) as sum_cred from
1500 case when j_debit='t' then j_montant else 0 end as deb,
1501 case when j_debit='f' then j_montant else 0 end as cred
1503 join jrn on (jr_grpt_id=j_grpt)
1505 j_qcode = ('$qcode'::text)
1511 if (
$Max==0)
return 0;
1514 return array(
'debit'=>
$r[
'sum_deb'],
1515 'credit'=>
$r[
'sum_cred'],
1516 'solde'=>abs(
$r[
'sum_deb']-
$r[
'sum_cred']));
1525 $sql=
"select ad_value
1528 left join attr_def using (ad_id) where f_id=".$this->id.
1529 " and ad_id = ".$p_attr.
1534 return (strlen(
trim($text)) > 0)?
false:
true;
1563 $filter_year=
" j_tech_per in (select p_id from parm_periode ".
1564 "where p_exercice='".$g_user->get_exercice().
"')";
1566 if ( $p_amount) $filter_amount=
' and f_id in (select f_id from jrnx where '.$filter_year.
')';
1568 $all_tiers=$this->
count_by_modele($this->fiche_def_ref,
"",$p_sql.$filter_amount);
1582 if (
trim($p_search) !=
"" )
1584 $search.=
" and f_id in
1585 (select distinct f_id from fiche_detail
1587 ad_id in (1,32,30,23,18,13) and ad_value ~* '$p_search')";
1592 if ( $all_tiers == 0 || count($step_tiers)==0 )
return "";
1596 $r.=
'<table id="tiers_tb" class="sortable" style="width:90%;margin-left:5%">
1598 <TH>'._(
'Quick Code').HtmlInput::infobulle(17).
'</TH>'.
1599 '<th>'._(
'Poste comptable').
'</th>'.
1600 '<th class="sorttable_sorted_reverse">'._(
'Nom').
'<span id="sorttable_sortrevind"> ▴</span>'.
'</th>
1601 <th>'._(
'Adresse').
'</th>
1602 <th style="text-align:right">'._(
'Total débit').
'</th>
1603 <th style="text-align:right">'._(
'Total crédit').
'</th>
1604 <th style="text-align:right">'._(
'Solde').
'</th>';
1606 if (
sizeof ($step_tiers ) == 0 )
1611 foreach ($step_tiers as $tiers )
1619 if ( $p_amount &&
$amount[
'debit']==0 &&
$amount[
'credit'] == 0 &&
$amount[
'solde'] == 0 )
continue;
1622 $odd = ($i % 2 == 0 ) ?
' odd ':
' even ';
1625 if ( strpos($accounting,$bank->p_value)===0 || strpos($accounting,$cash->p_value)===0 || strpos($accounting,$cc->p_value)===0){
1631 $odd=
' class="'.$odd.
'"';
1634 $url_detail=
$script.
'?'.http_build_query(array(
'sb'=>
'detail',
'sc'=>
'sv',
'ac'=>
$_REQUEST[
'ac'],
'f_id'=>$tiers->id,
'gDossier'=>
$gDossier));
1635 $e=sprintf(
'<A HREF="%s" title="Détail" class="line"> ',
1639 $r.=
"<TD sorttable_customkey=\"text{$accounting}\"> $e".$accounting.
"</TD>";
1648 $r.=
'<TD sorttable_customkey="'.$amount[
'debit'].
'" align="right"> '.$str_deb.
'</TD>';
1649 $r.=
'<TD sorttable_customkey="'.$amount[
'credit'].
'" align="right"> '.$str_cred.
'</TD>';
1661 $r.=
'<TD class="'.$red.
'" sorttable_customkey="'.
$amount[
'solde'].
'" align="right"> '.$str_solde.
"$side </TD>";
1671 $r.=
'<tr class="highlight">';
1672 $r.=
td(
"").td(
"").td(
"").td(
"Totaux").td(
nbm(
$deb),
'class="num"').td(
nbm(
$cred),
'class="num"').td(
" $side ".
nbm(
$solde),
'class="num"');
1684 if ( $this->
id == 0 )
throw new Exception(
'class_fiche : f_id = 0 ');
1685 $sql=
'select fd_id from fiche where f_id=$1';
1686 $R=$this->
cn->get_value(
$sql, array($this->
id));
1710 if (($this->quick_code==null || $this->quick_code ==
"" )
1713 throw new Exception(
'erreur ni quick_code ni f_id ne sont donnes');
1717 if ( $this->quick_code==
"")
1721 if ( $this->quick_code==null)
1724 if ( $this->
id == 0 )
1731 $get=
'jrn_def_fiche_deb';
1735 $get=
'jrn_def_fiche_cred';
1739 $Res=$this->
cn->exec_sql(
"select $get as fiche from jrn_def where jrn_def_id=$p_jrn");
1744 $Res=$this->
cn->exec_sql(
" select jrn_def_fiche_cred as fiche
1745 from jrn_def where jrn_def_id=$p_jrn
1747 select jrn_def_fiche_deb
1748 from jrn_def where jrn_def_id=$p_jrn"
1762 if ( $row[
'fiche'] !=
'' )
1764 $str_list.=$comma.$row[
'fiche'];
1778 fd_id in (".$str_list.
") and f_id= ".
$this->id;
1798 $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';
1801 $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';
1804 $sql=
'select f_id from fiche where fd_id=$1 ';
1806 $array=$p_cn->get_array(
$sql,array($pFd_id));
1817 $sql=
'select count(*) as c from jrnx where j_qcode=$1';
1819 if (
$count == 0 )
return false;
1826 $Res=$this->
cn->exec_sql(
"delete from fiche_detail
1831 $Res=$this->
cn->exec_sql(
"delete from fiche where f_id=".$this->
id);
1849 extract(
$array, EXTR_SKIP);
1851 $filter_fd_id=
'true';
1853 if (isset($typecard))
1855 if (strpos($typecard,
"sql")==
false)
1861 throw (
'Erreur pas de valeur pour jrn');
1862 $filter_jrn=$this->
cn->make_list(
"select jrn_def_fiche_cred from jrn_Def where jrn_def_id=$1",
1864 $filter_fd_id=
" fd_id in (".$filter_jrn.
")";
1869 throw (
'Erreur pas de valeur pour jrn');
1870 $filter_jrn=$this->
cn->make_list(
"select jrn_def_fiche_deb from jrn_Def where jrn_def_id=$1",
1872 $filter_fd_id=
" fd_id in (".$filter_jrn.
")";
1877 throw (
'Erreur pas de valeur pour jrn');
1878 $filter_jrn=$this->
cn->make_list(
"select jrn_def_fiche_deb from jrn_Def where jrn_def_id=$1",
1881 if (
trim($filter_jrn)!=
'')
1882 $fp1=
" fd_id in (".$filter_jrn.
")";
1886 $filter_jrn=$this->
cn->make_list(
"select jrn_def_fiche_cred from jrn_Def where jrn_def_id=$1",
1889 if (
trim($filter_jrn)!=
'')
1890 $fp2=
" fd_id in (".$filter_jrn.
")";
1894 $filter_fd_id=
'('.$fp1.
' or '.$fp2.
')';
1899 $filter_fd_id=
' true';
1902 if (
trim($typecard)!=
'')
1903 $filter_fd_id=
' fd_id in ('.$typecard.
')';
1905 $filter_fd_id=
' fd_id < 0';
1910 $filter_fd_id=str_replace(
'[sql]',
'', $typecard);
1921 $filter_query=$and.
"(vw_name ilike '%$query%' or quick_code ilike ('%$query%') "
1922 .
" or vw_description ilike '%$query%' or tva_num ilike '%$query%' or accounting like upper('$query%'))";
1929 $sql=
"select * from vw_fiche_attr where ".$filter_fd_id.$filter_query;
1941 $this->
cn->exec_sql(
'update fiche set fd_id=$1 where f_id=$2',array($p_fdid,$this->
id));
1943 $this->
cn->exec_sql(
'select fiche_attribut_synchro($1)',array($p_fdid));
1945 $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));
1946 $this->
cn->commit();
1967 $select_cat->value=
$cn->make_array(
'select fd_id,fd_label from fiche_def where frd_id='.
1969 echo
'<FORM METHOD="GET"> ';
1970 echo dossier::hidden();
1972 echo
'Choix de la catégorie';
1976 if ( isset (
$_GET[
'go_card']))
1978 $empty=
$a->to_array(
$_GET[
'fd_id']);
2000 $href=
"export.php?".http_build_query(
2006 "from_periode"=>$p_from,
2007 "to_periode"=>$p_to,
2008 "act"=>
"CSV:fichedetail"
2011 return '<a class="smallbutton" style="display:inline" href="'.$href.
'">'._(
"Export CSV").
'</a>';
2022 $href=
"export.php?".http_build_query(
2028 "from_periode"=>$p_from,
2029 "to_periode"=>$p_to,
2030 "act"=>
"PDF:fichedetail"
2033 return '<a class="smallbutton" style="display:inline" href="'.$href.
'">'._(
"Export PDF").
'</a>';
to_array($pfd_id)
make an array of attributes of the category of card (FICHE_DEF.FD_ID) The array can be used with the ...
blank($p_fiche_def)
insert a new record show a blank card to be filled
alert($p_msg, $buffer=false)
alert in javascript
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...
__construct($p_cn, $p_id=0)
getAttribut()
get all the attribute of a card, add missing ones and sort the array ($this->attribut) by ad_id ...
static fetch_all($ret)
wrapper for the function pg_fetch_all
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...
update($p_array=null)
update a card
if($g_user->check_dossier(dossier::id(), true)=='X') $op
get_bk_balance($p_cond="")
get the bank balance with receipt or not
Manage the table parm_code which contains the custom parameter for the module accountancy.
HtmlTableDetail($p_array=null, $op_let=0)
HtmlTable, display a HTML of a card for the asked period.
sql_string($p_string)
Fix the problem with the quote char for the database.
td($p_string='', $p_extra='')
surround the string with td
filter_history($p_table_id)
Filter in javascript the table with the history.
count_by_modele($p_frd_id, $p_search="", $p_sql="")
Return array of card from the frd family.
define Class fiche and fiche def, those class are using class attribut
static num_row($ret)
wrapper for the function pg_NumRows
insert($p_fiche_def, $p_array=null, $transaction=true)
insert a new record
static get_fiche_def($p_cn, $pFd_id, $p_order='')
get all the card from a categorie
Manage the table attr_def.
get_by_category($p_offset=-1, $p_search="", $p_order='')
get all the card thanks the fiche_def_ref
h2($p_string, $p_class="", $raw="")
th($p_string, $p_extra='', $raw='')
show a button, for selecting a account and a input text for manually inserting an account the differe...
get_row($p_from, $p_to)
Get data for poste.
Save($p_fiche_def=0)
Save a card, call insert or update.
nbm($p_number, $p_dec=2)
format the number with a sep.
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()
Synonum of fiche::getAttribut.
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
setAttribut($p_ad_id, $p_value)
set an attribute by a value, if the attribut array is empty a call to getAttribut is performed ...
const ATTR_DEF_FIRST_NAME
button_csv($p_from, $p_to)
Return a string with the HTML code to display a button to export the history in CSV.
static cmp_name(Fiche $o1, Fiche $o2)
used with a usort function, to sort an array of Fiche on the name
foreach($array as $idx=> $m) $w
get_row_date($p_from, $p_to, $op_let=0)
Get data for poste.
Display($p_readonly)
Display object instance, getAttribute sort the attribute and add missing ones.
build_sql($array)
create the sql statement for retrieving all the card
get_amount_side($p_amount)
return the letter C if amount is > 0, D if < 0 or =
size()
give the size of a card object
static fetch_array($ret, $p_indice=0)
wrapper for the function pg_fetch_array
echo_error($p_log, $p_line="", $p_message="")
log error into the /tmp/noalyss_error.log it doesn't work on windows
seek($p_attribut, $p_value)
find the card with the p_attribut equal to p_value, it is not case sensitive
navigation_bar($p_offset, $p_line, $p_size=0, $p_page=1, $p_javascript="")
Create a navigation_bar (pagesize)
For the periode tables parm_periode and jrn_periode.
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
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.
get_quick_code()
return the quick_code of a card
Summary($p_search="", $p_action="", $p_sql="", $p_amount=false)
show the default screen
for($i=0;$i<$nb_jrn;$i++) $deb
global $g_user
Find the default module or the first one.
empty_attribute($p_attr)
check if an attribute is empty
function trim(s)
remove trailing and heading space
move_to($p_fdid)
move a card to another cat.
strAttribut($p_ad_id, $p_return=1)
cmpDate($p_date, $p_date_oth)
Compare 2 dates.
if(!isset($_REQUEST['p_jrn'])) else $Ledger id
static id()
return the $_REQUEST['gDossier'] after a check
h($p_string)
to protect again bad characters which can lead to a cross scripting attack the string to be diplayed ...
button_pdf($p_from, $p_to)
Return a string with the HTML code to display a button to export the history in PDF.
this file match the tables jrn & jrnx the purpose is to remove or save accountant writing to these ta...
static fetch_result($ret, $p_row=0, $p_col=0)
wrapper for the function pg_fetch_all
foreach($Fiche->row as $op) $solde_type
Input HTML for the card show buttons, in the file, you have to add card.js How to use : ...
load()
Synonum of fiche::getAttribut.
is_used()
check if a card is used
get_row_result($res)
fetch and return and array
if(!isset($_GET['submit_query'])) $p_action
HtmlTable($p_array=null, $op_let=0, $from_div=1)
HtmlTable, display a HTML of a card for the asked period.
GetByDef($p_frd_id, $p_offset=-1, $p_search="", $p_order='')
Return array of card from the frd family.
get_bk_account()
get the available bank_account filtered by the security
HtmlTableHeader($p_array=null)
Display HTML Table Header (button)
get_categorie()
get the fd_id of the card : fd_id, it set the attribute fd_id
get_solde_detail($p_cond="")
give the balance of an card
getName()
return the name of a card
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
This class handles only the numeric input, the input will call a javascript to change comma to period...