noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
Fiche Class Reference

define Class fiche and fiche def, those class are using class attribut. When adding or modifing new card in a IPOPUP the ipopup for the accounting item is ipop_account More...

+ Inheritance diagram for Fiche:
+ Collaboration diagram for Fiche:

Public Member Functions

 __construct ($p_cn, $p_id=0)
 !< this variable is a mistake, it shouldn't exist, need code rewrite
 
 __toString ()
 
 belong_ledger ($jrn_def_id, $side="")
 Check if a card can be used and then belong tp a specific ledger, it the card.
 
 blank ($p_fiche_def)
 insert a new record show a blank card to be filled
 
 build_sql ($array)
 create the sql statement for retrieving all the card
 
 button_csv ($p_from, $p_to)
 Return a string with the HTML code to display a button to export the history in CSV.
 
 button_pdf ($p_from, $p_to)
 Return a string with the HTML code to display a button to export the history in PDF.
 
 count_by_modele ($p_frd_id, $p_search="", $p_sql="")
 Count the nb of card with the reference card id frd_id.
 
 delete ()
 
 Display ($p_readonly, $p_in="")
 Display object instance, getAttribute sort the attribute and add missing ones.
 
 display_row ()
 display card as a table row , the tag TR must be added
 
 empty_attribute ($p_attr)
 check if an attribute is empty
 
 filter_history ($p_table_id)
 Filter in javascript the table with the history.
 
 Get ()
 Synonum of fiche::load_attribute.
 
 get_all_account ()
 
 get_amount_side ($p_amount)
 return the letter C if amount is > 0, D if < 0 or =
 
 get_attribute ($p_ad_id, $p_return=1)
 return the string of the given attribute (attr_def.ad_id)
 
 get_bank_ledger ()
 Returns the Acc_Ledger_Fin ledger for which the card is the default bank account or null if no ledger is found.
 
 get_bk_account ()
 get the available bank_account filtered by the security
 
 get_bk_balance ($p_cond="")
 get the bank balance with receipt or not in Euro
 
 get_bk_balance_currency ($p_cond="")
 Get the sum in Currency.
 
 get_by_category ($p_offset=-1, $p_search="", $p_order='')
 get all the card thanks the fiche_def_ref
 
 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 0 if no card is found.
 
 get_categorie ()
 get the fd_id of the card : fd_id, it set the attribute fd_id
 
 get_f_enable ()
 
 get_fiche_def_ref ()
 
 get_fiche_def_ref_id ()
 retrieve the frd_id of the fiche it is the type of the card (bank, purchase...) (fiche_def_ref primary key)
 
 get_gestion_title ()
 
 get_id ()
 
 get_quick_code ()
 return the quick_code of a card
 
 get_row ($p_from, $p_to)
 Get data for poste.
 
 get_row_date ($p_from, $p_to, $op_let=0)
 Get data for poste.
 
 get_solde_detail ($p_cond="")
 give the balance of an card
 
 getAttribut ()
 replace by load_attribute
 
 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.
 
 getDisplayMode ()
 
 getLabelCategory ()
 
 getName ()
 return the name of a card
 
 HtmlTable ($p_array=null, $op_let=0, $from_div=1)
 HtmlTable, display a HTML of a card for the asked period.
 
 HtmlTableDetail ($p_array=null, $op_let=0)
 HtmlTable, display a HTML of a card for the asked period.
 
 HtmlTableHeader ($p_array=null)
 Display HTML Table Header (button)
 
 insert ($p_fiche_def, $p_array=null, $transaction=true)
 insert a new record thanks an array , either as parameter or $_POST
 
 is_used ()
 check if a card is used
 
 load ()
 Synonum of fiche::load_attribute.
 
 load_attribute ()
 get all the attribute of a card, add missing ones and sort the array ($this->attribut) by ad_id
 
 move_to ($p_fdid)
 move a card to another cat.
 
 remove ($silent=false)
 remove a card, check if not used first, must be synchro with is_used
 
 save ($p_fiche_def=0)
 Save a card, call insert or update.
 
 seek ($p_attribut, $p_value)
 find the card with the p_attribut equal to p_value, it is not case sensitive
 
 set_attribute ($p_ad_id, $p_value)
 set an attribute by a value, if the attribut array is empty a call to load_attribute is performed
 
 set_f_enable ($f_enable)
 
 set_fiche_def ($p_fiche_def)
 
 set_fiche_def_ref ($fiche_def_ref)
 
 set_id ($id)
 
 setAttribut ($p_ad_id, $p_value)
 replace by set_attribute
 
 setDisplayMode ($p_mode)
 how the card is display : either in a window or a greated container
 
 ShowTable ()
 
 strAttribut ($p_ad_id, $p_return=1)
 use get_attribute instead
 
 Summary ($p_search="", $p_action="", $p_sql="", $p_amount=false)
 show the default screen
 
 to_array ()
 turn a card into an array , then it can be saved thanks update or insert
 
 update ($p_array=null)
 update a card with an array
 

Static Public Member Functions

static cmp_name (Fiche $o1, Fiche $o2)
 used with a usort function, to sort an array of Fiche on the name
 
static from_qcode (Database $cn, string $p_qcode)
 create a card from a qcode and returns a card
 
static get_fiche_def ($p_cn, $card_category_id, $p_order='', $inactive=1)
 get all the card from a categorie
 
static test_me ()
 

Data Fields

 $attribut
 
 $cn
 
 $fiche_def
 
 $fiche_def_ref
 
 $id
 
 $ledger_description
 !< this variable is a mistake, it shouldn't exist, need code rewrite
 
 $ledger_name
 
 $quick_code
 
 $row
 
 $tot_cred
 
 $tot_deb
 

Private Member Functions

 get_row_result_deprecated ($res)
 fetch and return and array
 

Private Attributes

 $display_mode
 
 $f_enable
 

Detailed Description

define Class fiche and fiche def, those class are using class attribut. When adding or modifing new card in a IPOPUP the ipopup for the accounting item is ipop_account

Definition at line 37 of file fiche.class.php.

Constructor & Destructor Documentation

◆ __construct()

Fiche::__construct ( $p_cn,
$p_id = 0 )

!< this variable is a mistake, it shouldn't exist, need code rewrite

Reimplemented in Admin, Bank, contact, Customer, Manager, and Supplier.

Definition at line 53 of file fiche.class.php.

54 {
55 $this->cn=$p_cn;
56 // in PHP7 , a null string == 0
57 // in PHP8 , a null string == a null string and is not equal to 0
58 // to fix this, we set the fix here
59 if ( isNumber($p_id) == 1 ) {
60 $this->id=$p_id;
61 } else {
62 $this->id=0;
63 }
64 $this->quick_code='';
65 $this->attribut=array();
66 $this->f_enable='1';
67 if ($p_id != 0 ) { $this->load();} else {
68 $this->fiche_def=0;
69 }
70
71 $this->display_mode="window";
72 }
isNumber($p_int)
$input_from cn
load()
Synonum of fiche::load_attribute.

References $p_id, cn, isNumber(), and load().

+ Here is the call graph for this function:

Member Function Documentation

◆ __toString()

Fiche::__toString ( )

Definition at line 396 of file fiche.class.php.

396 : string
397 {
398 return print_r($this,true);
399 }

◆ belong_ledger()

Fiche::belong_ledger ( $jrn_def_id,
$side = "" )

Check if a card can be used and then belong tp a specific ledger, it the card.

return 1 if the fiche is in the range otherwise 0, the quick_code or the id must be set

Parameters
$jrn_def_idjournal_id (JRN.JRN_DEF_ID)
$side: deb or cred , default empty = both
Returns
1 if the card belongs to the ledger, 0 the card doesn't belong, -1 the card doesn't exist, -2 the ledger has no card to check, -3 there is no category of card for this ledger

Definition at line 1545 of file fiche.class.php.

1546 {
1547 // check if we have a quick_code or a f_id
1548 if (($this->quick_code==null || $this->quick_code == "" )
1549 && $this->id == 0 )
1550 {
1551 throw new Exception( 'erreur ni quick_code ni f_id ne sont donnes');
1552 }
1553
1554 //retrieve the quick_code
1555 if ($this->quick_code == "") {
1556 $this->quick_code = $this->get_quick_code();
1557 }
1558
1559
1560 if ($this->quick_code == null) {
1561 return -1;
1562 }
1563
1564 if ($this->id == 0 && $this->get_by_qcode(null, false) == 1) {
1565 return -1;
1566 }
1567
1568 if ( $side == 'deb' )
1569 {
1570 $Res=$this->cn->exec_sql("select jrn_def_fiche_deb as fiche from jrn_def where jrn_def_id=$1",[$jrn_def_id]);
1571 }elseif ( $side == 'cred' )
1572 {
1573 $Res=$this->cn->exec_sql("select jrn_def_fiche_cred as fiche from jrn_def where jrn_def_id=$1",[$jrn_def_id]);
1574 }
1575 else
1576 {
1577 // Get all the fiche type (deb and cred)
1578 $Res=$this->cn->exec_sql(" select jrn_def_fiche_cred as fiche
1579 from jrn_def where jrn_def_id=$1
1580 union
1581 select jrn_def_fiche_deb
1582 from jrn_def where jrn_def_id=$1",
1583 [$jrn_def_id]
1584 );
1585 }
1586 if ( Database::num_row($Res)==0)
1587 {
1588 return -2;
1589 }
1590 /* convert the array to a string */
1592 $str_list="";
1593 $comma='';
1594 foreach ($list as $row)
1595 {
1596 if ( $row['fiche'] != '' )
1597 {
1598 $str_list.=$comma.$row['fiche'];
1599 $comma=',';
1600 }
1601 }
1602 // Normally Max must be == 1
1603
1604 if ( $str_list=="")
1605 {
1606 return -3;
1607 }
1608
1609 $sql="select *
1610 from fiche
1611 where
1612 fd_id in (".$str_list.") and f_id= ".$this->id;
1613
1614 $Res=$this->cn->exec_sql($sql);
1615 if (Database::num_row($Res) == 0) {
1616 return 0;
1617 }
1618 return 1;
1619
1620 }
static fetch_all($ret, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_all
static num_row($ret)
wrapper for the function pg_num_rows
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...
get_quick_code()
return the quick_code of a card
if( $delta< 0) elseif( $delta==0)
$side

References $id, $list, $Res, $row, $side, $sql, cn, elseif, DatabaseCore\fetch_all(), get_by_qcode(), get_quick_code(), and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ blank()

Fiche::blank ( $p_fiche_def)

insert a new record show a blank card to be filled

Parameters
$p_fiche_defis the fiche_def.fd_id
Returns
HTML Code

Definition at line 377 of file fiche.class.php.

378 {
379 // array = array of attribute object sorted on ad_id
380 $fiche_def=new Fiche_Def($this->cn,$p_fiche_def);
381 $fiche_def->get();
382 $array=$fiche_def->load_attribute();
383 $r="";
384 $r.='<table style="width:98%;margin:1%">';
385 foreach ($array as $attr)
386 {
387 $table=0;
388 $msg="";$bulle='';
389 $r.=$attr->input($fiche_def);
390
391 }
392 $r.= '</table>';
393 return $r;
394 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$table
Definition menu.inc.php:104

References $array, $attr, $fiche_def, $msg, $r, $table, and cn.

◆ build_sql()

Fiche::build_sql ( $array)

create the sql statement for retrieving all the card

Returns
string with sql statement
Parameters
$arraycontains the condition
   [jrn] => 2
   [typecard] => cred / deb / filter or list
   [query] => string
Note
the typecard cred, deb or filter must be used with jrn, the value of list means a list of fd_id
See also
ajax_card.php cards.js

Reimplemented in contact.

Definition at line 1717 of file fiche.class.php.

1718 {
1719 if (!empty($array))
1720 extract($array, EXTR_SKIP);
1721 $and='';
1722 $filter_fd_id='true';
1723 $filter_query='';
1724 if (isset($typecard))
1725 {
1726 if (strpos($typecard, "sql")==false)
1727 {
1728 switch ($typecard)
1729 {
1730 case 'cred':
1731 if (!isset($jrn))
1732 throw Exception('Erreur pas de valeur pour jrn');
1733 $filter_jrn=$this->cn->make_list("select jrn_def_fiche_cred from jrn_Def where jrn_def_id=$1",
1734 array($jrn));
1735 $filter_fd_id=(empty($filter_jrn))?" fd_id in (-1) ":" fd_id in (".$filter_jrn.")";
1736 $and=" and ";
1737 break;
1738 case 'deb':
1739 if (!isset($jrn))
1740 throw Exception('Erreur pas de valeur pour jrn');
1741 $filter_jrn=$this->cn->make_list("select jrn_def_fiche_deb from jrn_Def where jrn_def_id=$1",
1742 array($jrn));
1743 $filter_fd_id=(empty($filter_jrn))?"fd_id in (-1) ":" fd_id in (".$filter_jrn.")";
1744 $and=" and ";
1745 break;
1746 case 'filter':
1747 if (!isset($jrn))
1748 throw Exception('Erreur pas de valeur pour jrn');
1749 $filter_jrn=$this->cn->make_list("select jrn_def_fiche_deb from jrn_Def where jrn_def_id=$1",
1750 array($jrn));
1751
1752 if (noalyss_trim($filter_jrn)!='')
1753 $fp1=" fd_id in (".$filter_jrn.")";
1754 else
1755 $fp1="fd_id < 0";
1756
1757 $filter_jrn=$this->cn->make_list("select jrn_def_fiche_cred from jrn_Def where jrn_def_id=$1",
1758 array($jrn));
1759
1760 if (noalyss_trim($filter_jrn)!='')
1761 $fp2=" fd_id in (".$filter_jrn.")";
1762 else
1763 $fp2="fd_id < 0";
1764
1765 $filter_fd_id='('.$fp1.' or '.$fp2.')';
1766
1767 $and=" and ";
1768 break;
1769 case 'all':
1770 $filter_fd_id=' true';
1771 break;
1772 default:
1773 if (noalyss_trim($typecard)!='')
1774 $filter_fd_id=' fd_id in ('.$typecard.')';
1775 else
1776 $filter_fd_id=' fd_id < 0';
1777 }
1778 }
1779 else
1780 {
1781 $filter_fd_id=noalyss_str_replace('[sql]', '', $typecard);
1782 }
1783 }
1784
1785 $and=" and ";
1786 if (isset($query))
1787 {
1789
1791 {
1793 $filter_query=$and."(vw_name ilike '%$query%' or quick_code ilike ('%$query%') "
1794 ." or vw_description ilike '%$query%' or tva_num ilike '%$query%' or accounting like upper('$query%'))";
1795 }
1796 else
1797 {
1798 $filter_query='';
1799 }
1800 }
1801 $sql="select * from vw_fiche_attr where ".$filter_fd_id.$filter_query;
1802 return $sql;
1803 }
noalyss_strlentrim($p_string)
noalyss_str_replace($search, $replace, $string)
sql_string($p_string)
Fix the problem with the quote char for the database.
noalyss_trim($p_string)
$typecard
Definition fid_card.php:62

References $array, $jrn, $query, $sql, $typecard, cn, noalyss_str_replace(), noalyss_strlentrim(), noalyss_trim(), and sql_string().

+ Here is the call graph for this function:

◆ button_csv()

Fiche::button_csv ( $p_from,
$p_to )

Return a string with the HTML code to display a button to export the history in CSV.

Parameters
type$p_fromfrom date (DD.MM.YYYY)
type$p_toto date (DD.MM.YYYY)
Returns
HTML string

Definition at line 1896 of file fiche.class.php.

1896 {
1897 $href="export.php?".http_build_query(
1898 array(
1899 "gDossier"=>Dossier::id(),
1900 "f_id"=>$this->id,
1901 "ople"=>0,
1902 "type"=>"poste",
1903 "from_periode"=>$p_from,
1904 "to_periode"=>$p_to,
1905 "act"=>"CSV:fichedetail"
1906 )
1907 );
1908 return '<a class="smallbutton" style="display:inline-block" href="'.$href.'">'._("Export CSV").'</a>';
1909
1910 }
$href
Definition adm.inc.php:31
_("actif, passif,charge,...")

References $href, and _.

◆ button_pdf()

Fiche::button_pdf ( $p_from,
$p_to )

Return a string with the HTML code to display a button to export the history in PDF.

Parameters
type$p_fromfrom date (DD.MM.YYYY)
type$p_toto date (DD.MM.YYYY)
Returns
HTML string

Definition at line 1918 of file fiche.class.php.

1918 {
1919 $href="export.php?".http_build_query(
1920 array(
1921 "gDossier"=>Dossier::id(),
1922 "f_id"=>$this->id,
1923 "ople"=>0,
1924 "type"=>"poste",
1925 "from_periode"=>$p_from,
1926 "to_periode"=>$p_to,
1927 "act"=>"PDF:fichedetail"
1928 )
1929 );
1930 return '<a class="smallbutton" style="display:inline-block" href="'.$href.'">'._("Export PDF").'</a>';
1931
1932 }

References $href, and _.

◆ cmp_name()

static Fiche::cmp_name ( Fiche $o1,
Fiche $o2 )
static

used with a usort function, to sort an array of Fiche on the name

Definition at line 137 of file fiche.class.php.

138 {
139 return strcmp($o1->get_attribute(ATTR_DEF_NAME),$o2->get_attribute(ATTR_DEF_NAME));
140 }
get_attribute($p_ad_id, $p_return=1)
return the string of the given attribute (attr_def.ad_id)
const ATTR_DEF_NAME
Definition constant.php:223

References ATTR_DEF_NAME, and get_attribute().

+ Here is the call graph for this function:

◆ count_by_modele()

Fiche::count_by_modele ( $p_frd_id,
$p_search = "",
$p_sql = "" )

Count the nb of card with the reference card id frd_id.

Parameters
$p_frd_idthe fiche_def_ref.frd_id
$p_searchp_search is a filter on the name
$p_sqlextra sql condition
Returns
nb of item found

Definition at line 266 of file fiche.class.php.

267 {
268 // Scan for SQL inject
269 $this->cn->search_sql_inject($p_sql);
270
271 if ( $p_search != "" )
272 {
273 $result = $this->cn->get_value("select count(*) from
274 vw_fiche_attr
275 where
276 frd_id=$1
277 and vw_name ilike '%'||$2||'%'",
278 [$p_frd_id,$p_search]);
279 return $result;
280 } else {
281 $result = $this->cn->get_value("select count(*)
282 from
283 fiche join fiche_Def using (fd_id)
284 where frd_id=$1 ".$p_sql
285 ,[$p_frd_id]);
286 return $result;
287 }
288
289
290 }

References $result, and cn.

Referenced by Summary().

◆ delete()

Fiche::delete ( )

Definition at line 1689 of file fiche.class.php.

1690 {
1691 $this->cn->start();
1692
1693 // Remove from attr_value
1694 $Res=$this->cn->exec_sql("delete from fiche_detail
1695 where
1696 f_id= $1",[ $this->id] );
1697
1698 // Remove from fiche
1699 $Res=$this->cn->exec_sql("delete from fiche where f_id=$1",[$this->id]);
1700
1701 $this->cn->commit();
1702
1703
1704 }

References $Res, and cn.

◆ Display()

Fiche::Display ( $p_readonly,
$p_in = "" )

Display object instance, getAttribute sort the attribute and add missing ones.

Parameters
$p_readonlytrue= if can not modify, otherwise false
string$p_inif called from an ajax it is the id of the html elt containing
Returns
string to display or FNT string for fiche non trouvé

Definition at line 422 of file fiche.class.php.

423 {
424 $this->load_attribute();
426 $ret="";
427 $ret.='<span style="margin-right:5px;float:right;font-size:80%">'.
428 _('id').':'.$this->id."</span>";
429 $ret.="<table style=\"width:98%;margin:1%\">";
430 if (empty($attr))
431 {
432 return 'FNT';
433 }
434
435 $fiche_def=new Fiche_Def($this->cn,$this->fiche_def);
436 /* for each attribute */
437 foreach ($attr as $r)
438 {
439 $msg="";
440 $bulle="";
441 $r->setDisplayMode($this->display_mode);
442 if ($p_readonly)
443 {
444 $ret .= $r->print();
445 }
446 if ($p_readonly==false)
447 {
448 $ret .= $r->input($fiche_def);
449
450 }
451 }
452 // Display if the card is enable or not
453 $enable_is=new InputSwitch("f_enable");
454 $enable_is->value=$this->f_enable;
455 $enable_is->readOnly=$p_readonly;
456
457 $ret.=tr(
458 td(_("Actif"),'class="input_text"').td($enable_is->input(),'class="input_text"')
459 );
460
461
462 $ret.="</table>";
463
464 return $ret;
465 }
tr($p_string, $p_extra='')
Definition ac_common.php:88
td($p_string='', $p_extra='')
surround the string with td
Definition ac_common.php:83
load_attribute()
get all the attribute of a card, add missing ones and sort the array ($this->attribut) by ad_id

References $attr, $attribut, $f_enable, $fiche_def, $msg, $p_readonly, $r, $ret, _, cn, load_attribute(), td(), and tr().

+ Here is the call graph for this function:

◆ display_row()

Fiche::display_row ( )

display card as a table row , the tag TR must be added

Returns
HTML string starting

Definition at line 1966 of file fiche.class.php.

1967 {
1968 $this->load_attribute();
1969 foreach($this->attribut as $attr) {
1970 $sort="";
1971
1972 if ($attr->ad_type!='select')
1973 {
1974
1975 if ($attr->ad_type=="date") {
1976 // format YYYYMMDD
1977 $sort='sorttable_customkey="'.format_date($attr->av_text, "DD.MM.YYYY", "YYYYMMDD").'"';
1978 }
1979 elseif ($attr->ad_type=="poste"){
1980 $sort='sorttable_customkey="TEXT'.$attr->av_text.'"';
1981 }
1982 echo td($attr->av_text, 'style="padding: 0 10 1 10;white-space:nowrap;" '.$sort);
1983 }
1984 else {
1985 $value=$this->cn->make_array($attr->ad_extra);
1986 $row_content="";
1987 for ($e=0; $e<count($value); $e++) {
1988 if ( $value[$e]['value']==$attr->av_text) {
1989 $row_content=h($value[$e]['label']);
1990 break;
1991 }
1992 }
1993 echo td($row_content, 'style="padding: 0 10 1 10;white-space:nowrap;"');
1994
1995 }
1996 }
1997
1998 }
h( $row[ 'oa_description'])
for($i=0;$i< count($aHeading);$i++) $sort

References $attr, $e, $sort, $value, cn, elseif, h, load_attribute(), and td().

+ Here is the call graph for this function:

◆ empty_attribute()

Fiche::empty_attribute ( $p_attr)

check if an attribute is empty

Parameters
$p_attrthe id of the attribut to check (ad_id)
Returns
return true is the attribute is empty or missing

Definition at line 1342 of file fiche.class.php.

1343 {
1344 $sql="select ad_value
1345 from fiche_detail
1346 natural join fiche
1347 left join attr_def using (ad_id) where f_id=$1 ".
1348 " and ad_id = $2 ".
1349 " order by ad_id";
1350 $res=$this->cn->exec_sql($sql,[$this->id,$p_attr]);
1351 if ( Database::num_row($res) == 0 ) return true;
1353 return (strlen(noalyss_trim($text)) > 0)?false:true;
1354
1355
1356 }
static fetch_result($ret, $p_row=0, $p_col=0)
wrapper for the function pg_fetch_all

References $res, $sql, $text, cn, DatabaseCore\fetch_result(), noalyss_trim(), and DatabaseCore\num_row().

Referenced by Acc_Ledger_Purchase\compute_no_deductible(), and Acc_Ledger_Purchase\insert_no_deductible().

+ Here is the call graph for this function:

◆ filter_history()

Fiche::filter_history ( $p_table_id)

Filter in javascript the table with the history.

Parameters
type$p_table_idid of the table containting the data to filter
Returns
html string

Definition at line 1939 of file fiche.class.php.

1939 {
1940 return _('Cherche').' '.HtmlInput::filter_table($p_table_id, '0,1,2,3,4,5,6,7,8,9,10', 1);
1941 }
static filter_table($p_table_id, $p_col, $start_row)
filter the rows in a table and keep the colored row in alternance

References _.

◆ from_qcode()

static Fiche::from_qcode ( Database $cn,
string $p_qcode )
static

create a card from a qcode and returns a card

Parameters
$cnDatabase cnx
$p_qcode(string) qcode of the card

Definition at line 2004 of file fiche.class.php.

2005 {
2006 $card=new Fiche($cn);
2007 $card->get_by_qcode($p_qcode);
2008 return $card;
2009 }

References $card, and $cn.

Referenced by Noalyss\XMLDocument\XMLInvoice\fill_operation_from_array().

◆ Get()

Fiche::Get ( )

Synonum of fiche::load_attribute.

Definition at line 678 of file fiche.class.php.

679 {
680 $this->load_attribute();
681 }

References load_attribute().

+ Here is the call graph for this function:

◆ get_all_account()

Fiche::get_all_account ( )

Definition at line 1885 of file fiche.class.php.

1886 {
1887
1888 }

◆ get_amount_side()

Fiche::get_amount_side ( $p_amount)

return the letter C if amount is > 0, D if < 0 or =

Parameters
type$p_amount
Returns
string

Definition at line 1825 of file fiche.class.php.

1826 {
1827 if ($p_amount == 0)
1828 return "";
1829 if ($p_amount < 0)
1830 return "C";
1831 if ($p_amount > 0)
1832 return "D";
1833 }

◆ get_attribute()

Fiche::get_attribute ( $p_ad_id,
$p_return = 1 )

return the string of the given attribute (attr_def.ad_id)

Parameters
int$p_ad_idAD_ID from attr_def.ad_id
int$p_return1 return NOTFOUND otherwise an empty string
See also
constant.php
Returns
string
Note
reread data from database and so it reset previous unsaved change

Definition at line 335 of file fiche.class.php.

336 {
337 $return=($p_return==1)?NOTFOUND:"";
338 if ( empty ($this->attribut) )
339 {
340
341 $this->load_attribute();
342 }
343
344 foreach ($this->attribut as $e)
345 {
346 if ( $e->ad_id == $p_ad_id )
347 return noalyss_trim($e->av_text);
348 }
349 return $return;
350 }
const NOTFOUND(!defined("SYSINFO_DISPLAY"))
Definition constant.php:135

References $e, load_attribute(), noalyss_trim(), and NOTFOUND.

Referenced by cmp_name(), Acc_Ledger_Purchase\compute_no_deductible(), get_bk_balance(), get_gestion_title(), get_row(), get_row_date(), get_solde_detail(), HtmlTable(), HtmlTableDetail(), Acc_Ledger_Purchase\insert_no_deductible(), is_used(), strAttribut(), Card_Property\update(), and update().

+ Here is the call graph for this function:

◆ get_bank_ledger()

Fiche::get_bank_ledger ( )

Returns the Acc_Ledger_Fin ledger for which the card is the default bank account or null if no ledger is found.

Definition at line 1945 of file fiche.class.php.

1946 {
1947 try {
1948 $id=$this->cn->get_value("select jrn_def_id from jrn_def where jrn_def_bank = $1 ",[$this->id]);
1949 if ($id == "") { return NULL;}
1950 $ledger=new Acc_Ledger_Fin($this->cn,$id);
1951 $ledger->load();
1952 return $ledger;
1953 }
1954 catch (Exception $e) {
1955 record_log(__FILE__.":".__LINE__);
1956 record_log($e->getMessage());
1957 throw $e;
1958 }
1959 }
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...

References $e, $id, $ledger, cn, and record_log().

+ Here is the call graph for this function:

◆ get_bk_account()

Fiche::get_bk_account ( )

get the available bank_account filtered by the security

Returns
array of card

Definition at line 146 of file fiche.class.php.

147 {
148 global $g_user;
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");
153
154 if ( count($avail) == 0 )
155 return null;
156
157 for ($i=0;$i<count($avail);$i++)
158 {
159 $t=new Fiche($this->cn,$avail[$i]['jrn_def_bank']);
160 $t->ledger_name=$avail[$i]['jrn_def_name'];
161 $t->ledger_description=$avail[$i]['jrn_def_description'];
162 $t->load_attribute();
163 $all[$i]=$t;
164
165 }
166 return $all;
167 }
global $g_user
if no group available , then stop
$t
Definition compute.php:46

References $all, $avail, $g_user, $i, $t, and cn.

◆ get_bk_balance()

Fiche::get_bk_balance ( $p_cond = "")

get the bank balance with receipt or not in Euro

Definition at line 1311 of file fiche.class.php.

1312 {
1313 if ( $this->id == 0 ) throw new Exception('fiche->id est nul');
1315
1316 if ( $p_cond != "") $p_cond=" and ".$p_cond;
1317 $sql="select sum(deb) as sum_deb, sum(cred) as sum_cred from
1318 ( select j_poste,
1319 case when j_debit='t' then j_montant else 0 end as deb,
1320 case when j_debit='f' then j_montant else 0 end as cred
1321 from jrnx
1322 join jrn on (jr_grpt_id=j_grpt)
1323 where
1324 j_qcode = ('$qcode'::text)
1325 $p_cond
1326 ) as m ";
1327
1328 $Res=$this->cn->exec_sql($sql);
1330 if ($Max==0) return 0;
1332
1333 return array('debit'=>$r['sum_deb'],
1334 'credit'=>$r['sum_cred'],
1335 'solde'=>abs($r['sum_deb']-$r['sum_cred']));
1336
1337 }
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
const ATTR_DEF_QUICKCODE
Definition constant.php:244

References $Max, $qcode, $r, $Res, $sql, ATTR_DEF_QUICKCODE, cn, DatabaseCore\fetch_array(), get_attribute(), and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ get_bk_balance_currency()

Fiche::get_bk_balance_currency ( $p_cond = "")

Get the sum in Currency.

Parameters
string$p_cond
Returns
type
Exceptions
Exception

Definition at line 1289 of file fiche.class.php.

1290 {
1291 if ( $this->id == 0 ) throw new Exception('fiche->id est nul');
1292
1293 if ( $p_cond != "") $p_cond=" and ".$p_cond;
1294
1295 $sql = "
1296 select sum(sum_oc_amount)
1297 from
1298 v_all_card_currency
1299 where
1300 f_id=$1
1301 $p_cond";
1302 $val=$this->cn->get_value($sql,[$this->id]);
1303
1304 return $val;
1305
1306 }

References $sql, and cn.

◆ get_by_category()

Fiche::get_by_category ( $p_offset = -1,
$p_search = "",
$p_order = '' )

get all the card thanks the fiche_def_ref

Parameters
$p_offset(default =-1)
$p_searchsql condition
Returns
array of fiche object

Definition at line 694 of file fiche.class.php.

695 {
696 switch($p_order)
697 {
698 case 'name' :
699 $order=' order by name';
700 break;
701 case 'f_id':
702 $order='order by f_id';
703 break;
704 default:
705 $order='';
706 }
707 if ( $p_offset == -1 )
708 {
709 $sql="select *
710 from
711 fiche join fiche_Def using (fd_id) join vw_fiche_name using(f_id)
712 where frd_id=".$this->fiche_def_ref." $p_search ".$order;
713 }
714 else
715 {
716 $limit=($_SESSION[SESSION_KEY.'g_pagesize']!=-1)?"limit ".$_SESSION[SESSION_KEY.'g_pagesize']:"";
717 $sql="select *
718 from
719 fiche join fiche_Def using (fd_id) join vw_fiche_name using(f_id)
720 where frd_id=".$this->fiche_def_ref." $p_search $order "
721 .$limit." offset ".$p_offset;
722
723 }
724
725 $Ret=$this->cn->exec_sql($sql);
726 if ( ($Max=Database::num_row($Ret)) == 0 )
727 return [];
728 $all[0]=new Fiche($this->cn);
729
730 for ($i=0;$i<$Max;$i++)
731 {
733 $t=new Fiche($this->cn,$row['f_id']);
734 $t->load_attribute();
735 $all[$i]=clone $t;
736
737 }
738 return $all;
739 }

References $all, $i, $limit, $Max, $order, $p_order, $row, $sql, $t, cn, DatabaseCore\fetch_array(), and DatabaseCore\num_row().

Referenced by GetByDef(), and Summary().

+ Here is the call graph for this function:

◆ get_by_qcode()

Fiche::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 0 if no card is found.

get_by_qcode($p_qcode)

Parameters
$p_qcodequick_code (ad_id=23)
$p_allretrieve all the attribut of the card, possible value are true or false. false retrieves only the f_id. By default true
Returns
0 success , card found / 1 error card not found

Definition at line 179 of file fiche.class.php.

180 {
181 if ( $p_qcode == null )
182 $p_qcode=$this->quick_code;
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)
188 {
189 $this->id=0;
190 return 1;
191 }
192
193
194 if ( $p_all )
195 $this->load_attribute();
196 return 0;
197 }

References $quick_code, $sql, cn, and load_attribute().

Referenced by belong_ledger().

+ Here is the call graph for this function:

◆ get_categorie()

Fiche::get_categorie ( )

get the fd_id of the card : fd_id, it set the attribute fd_id

Definition at line 1517 of file fiche.class.php.

1518 {
1519 if ( $this->id == 0 ) throw new Exception('class_fiche : f_id = 0 ');
1520 $sql='select fd_id from fiche where f_id=$1';
1521 $R=$this->cn->get_value($sql, array($this->id));
1522 if ( $R == "" )
1523 $this->fiche_def=0;
1524 else
1525 $this->fiche_def=$R;
1526 return $this->fiche_def;
1527 }

References $fiche_def, $sql, and cn.

◆ get_f_enable()

Fiche::get_f_enable ( )

Definition at line 111 of file fiche.class.php.

112 {
113 return $this->f_enable;
114 }

References $f_enable.

Referenced by to_array(), and Card_Property\update().

◆ get_fiche_def()

static Fiche::get_fiche_def ( $p_cn,
$card_category_id,
$p_order = '',
$inactive = 1 )
static

get all the card from a categorie

Parameters
$p_cndatabase connx
$card_category_idis the category id
$p_orderfor the sort, possible values is name_asc,name_desc or nothing
$inactiveint possible values : 1 = inactive included, 0 = only active ones (default 1)
Returns
an array of card, but only the fiche->id is set

Definition at line 1629 of file fiche.class.php.

1630 {
1631 // var $cond_active string SQL cond for filtering active or not
1632 $cond_active=($inactive == 1)?"":" and f_enable='1' ";
1633
1634 switch ($p_order)
1635 {
1636 case 'name_asc':
1637 $sql="select f_id,ad_value from fiche join fiche_detail using (f_id)
1638 where
1639 ad_id=1
1640 and fd_id=$1
1641 $cond_active
1642 order by 2 asc";
1643 break;
1644 case 'name_desc':
1645 $sql="select f_id,ad_value from fiche join fiche_detail using (f_id)
1646 where ad_id=1
1647 and fd_id=$1
1648 $cond_active
1649 order by 2 desc";
1650 break;
1651 default:
1652 $sql="select f_id from fiche where fd_id=$1 $cond_active ";
1653 }
1654 $array=$p_cn->get_array($sql,array($card_category_id));
1655
1656 return $array;
1657 }

References $array, $inactive, $p_order, and $sql.

◆ get_fiche_def_ref()

Fiche::get_fiche_def_ref ( )

Definition at line 106 of file fiche.class.php.

107 {
109 }

References $fiche_def_ref.

◆ get_fiche_def_ref_id()

Fiche::get_fiche_def_ref_id ( )

retrieve the frd_id of the fiche it is the type of the card (bank, purchase...) (fiche_def_ref primary key)

Definition at line 744 of file fiche.class.php.

745 {
746 $result=$this->cn->get_array("select frd_id from fiche join fiche_Def using (fd_id) where f_id=$1",[$this->id]);
747 if ( $result == null )
748 return null;
749
750 return $result[0]['frd_id'];
751 }

References $result, and cn.

◆ get_gestion_title()

Fiche::get_gestion_title ( )

Definition at line 1880 of file fiche.class.php.

1881 {
1882 $r = "<h2 id=\"gestion_title\">" . h($this->getName()) . " " . h($this->get_attribute(ATTR_DEF_FIRST_NAME,0)) . '[' . $this->get_quick_code() . ']</h2>';
1883 return $r;
1884 }
getName()
return the name of a card
const ATTR_DEF_FIRST_NAME
Definition constant.php:245

References $r, ATTR_DEF_FIRST_NAME, get_attribute(), get_quick_code(), getName(), and h.

+ Here is the call graph for this function:

◆ get_id()

Fiche::get_id ( )

Definition at line 101 of file fiche.class.php.

102 {
103 return $this->id;
104 }

References $id.

◆ get_quick_code()

Fiche::get_quick_code ( )

return the quick_code of a card

Returns
null if not quick_code is found

Definition at line 666 of file fiche.class.php.

667 {
668 $sql="select ad_value from fiche_detail where ad_id=23 and f_id=$1";
669 $Res=$this->cn->exec_sql($sql,array($this->id));
671 if ( $r == FALSE || sizeof($r) == 0 )
672 return null;
673 return $r[0]['ad_value'];
674 }

References $r, $Res, $sql, cn, and DatabaseCore\fetch_all().

Referenced by belong_ledger(), and get_gestion_title().

+ Here is the call graph for this function:

◆ get_row()

Fiche::get_row ( $p_from,
$p_to )

Get data for poste.

Parameters
$p_fromperiode periode.p_id
$p_toend periode periode.p_id
Returns
double array (j_date,deb_montant,cred_montant,description,jrn_name,j_debit,jr_internal) (tot_deb,tot_credit

Definition at line 886 of file fiche.class.php.

887 {
888 if ( $this->id == 0 )
889 {
890 echo_error("class_fiche",__LINE__,"id is 0");
891 return;
892 }
894 $periode=sql_filter_per($this->cn,$p_from,$p_to,'p_id','jr_tech_per');
895
896 $this->row=$this->cn->get_array("select j_date,
897 to_char(j_date,'DD.MM.YYYY') as j_date_fmt,
898 j_qcode,
899 case when j_debit='t' then j_montant else 0 end as deb_montant,
900 case when j_debit='f' then j_montant else 0 end as cred_montant,
901 jr_comment as description,
902 jrn_def_name as jrn_name,
903 j_debit,
904 jr_internal,
905 jr_id
906 from jrnx
907 left join jrn_def on jrn_def_id=j_jrn_def
908 left join jrn on jr_grpt_id=j_grpt
909 where
910 j_qcode=$1 and {$periode}
911 order by j_date::date",array(
912 $qcode
913 ));
914 $res_saldo = $this->cn->exec_sql("select sum(deb_montant),sum(cred_montant) from
915 (select case when j_debit='t' then j_montant else 0 end as deb_montant,
916 case when j_debit='f' then j_montant else 0 end as cred_montant
917 from jrnx
918 left join jrn_def on jrn_def_id=j_jrn_def
919 left join jrn on jr_grpt_id=j_grpt
920 where
921 j_qcode=$1 and {$periode} ) as m",
922 array($this->id));
923 $this->tot_deb=$this->tot_cred=0;
924
925 if ( Database::num_row($res_saldo) > 0 ) {
926 $this->tot_deb=Database::fetch_result($res_saldo, 0, 0);
927 $this->tot_cred=Database::fetch_result($res_saldo, 0, 1);
928 }
929 return array($this->row,$this->tot_deb,$this->tot_cred);
930
931 }
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.
echo_error($p_log, $p_line="", $p_message="")
log error into the /tmp/noalyss_error.log it doesn't work on windows

References $periode, $qcode, ATTR_DEF_QUICKCODE, cn, echo_error(), DatabaseCore\fetch_result(), get_attribute(), DatabaseCore\num_row(), and sql_filter_per().

+ Here is the call graph for this function:

◆ get_row_date()

Fiche::get_row_date ( $p_from,
$p_to,
$op_let = 0 )

Get data for poste.

Parameters
$p_fromperiode from
$p_toend periode
$op_let0 all operation, 1 only lettered one, 2 only unlettered one
Returns
double array (j_date,deb_montant,cred_montant,description,jrn_name,j_debit,jr_internal) (tot_deb,tot_credit

Definition at line 792 of file fiche.class.php.

793 {
794 global $g_user;
795 if ( $this->id == 0 )
796 {
797 echo_error("class_fiche",__LINE__,"id is 0");
798 return;
799 }
800 $filter_sql=$g_user->get_ledger_sql('ALL',3);
801 $sql_let='';
802 switch ($op_let)
803 {
804 case 0:
805 break;
806 case 1:
807 $sql_let=' and j1.j_id in (select j_id from letter_cred union select j_id from letter_deb)';
808 break;
809 case '2':
810 $sql_let=' and j1.j_id not in (select j_id from letter_cred union select j_id from letter_deb) ';
811 break;
812 }
813
815 $this->row=$this->cn->get_array("
816 with sqlletter as
817 (select j_id,jl_id from letter_cred union all select j_id , jl_id from letter_deb )
818 select distinct substring(jr_pj_number,'[0-9]+$'),j1.j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,j_qcode,".
819 "case when j_debit='t' then j_montant else 0 end as deb_montant,".
820 "case when j_debit='f' then j_montant else 0 end as cred_montant,".
821 " jr_comment as description,jrn_def_name as jrn_name,j_poste,".
822 " jr_pj_number,".
823 "j_debit, jr_internal,jr_id,(select distinct jl_id from sqlletter where sqlletter.j_id=j1.j_id ) as letter , ".
824 "jr_optype , ".
825 " jr_tech_per,p_exercice,jrn_def_name,
826 (with cred as (select jl_id, sum(j_montant) as amount_cred from letter_cred lc1 left join jrnx as j3 on (j3.j_id=lc1.j_id) group by jl_id ),
827 deb as (select jl_id, sum(j_montant) as amount_deb from letter_deb ld1 left join jrnx as j2 on (j2.j_id = ld1.j_id) group by jl_id )
828 select amount_deb-amount_cred
829 from
830 cred
831 full join deb using (jl_id) where jl_id=(select distinct jl_id from sqlletter where sqlletter.j_id=j1.j_id )) as delta_letter,
832 jrn_def_code,
833 jrn.currency_rate,
834 jrn.currency_rate_ref,
835 jrn.currency_id,
836 (select cr_code_iso from currency where id=jrn.currency_id) as cr_code_iso,
837 j_montant,
838 sum_oc_amount as oc_amount,
839 sum_oc_vat_amount as oc_vat_amount ,
840 case when exists(select 1 from operation_analytique oa where j1.j_id=oa.j_id) then 1 else 0 end as op_analytic
841 from jrnx as j1 left join jrn_def on jrn_def_id=j_jrn_def
842 left join (select j_id,
843 coalesce(oc_amount,0) as sum_oc_amount ,
844 coalesce(oc_vat_amount,0) as sum_oc_vat_amount
845 from jrnx left join operation_currency using (j_id)
846 ) as v1 on (v1.j_id=j1.j_id )
847 left join jrn on jr_grpt_id=j_grpt".
848 " left join parm_periode on (p_id=jr_tech_per) ".
849 " where j_qcode=$1 and ".
850 " ( to_date($2,'DD.MM.YYYY') <= j_date and ".
851 " to_date($3,'DD.MM.YYYY') >= j_date )".
852 " and $filter_sql $sql_let ".
853 " order by j_date,substring(jr_pj_number,'[0-9]+$')",array($qcode,$p_from,$p_to));
854
855 $res_saldo = $this->cn->exec_sql("select sum(deb_montant),sum(cred_montant) from
856 (select case when j_debit='t' then j_montant else 0 end as deb_montant,
857 case when j_debit='f' then j_montant else 0 end as cred_montant
858 from jrnx j1
859 join jrn_def on (jrn_def_id=j_jrn_def )
860 join jrn on (jr_grpt_id=j_grpt)
861 join tmp_pcmn on (j_poste=pcm_val)
862 join parm_periode on (p_id=jr_tech_per)
863 where f_id=$1 and
864 ( to_date($2,'DD.MM.YYYY') <= j_date and
865 to_date($3,'DD.MM.YYYY') >= j_date )
866 and $filter_sql $sql_let ) as m",array($this->id,$p_from,$p_to));
867 $this->tot_deb=$this->tot_cred=0;
868
869 if ( Database::num_row($res_saldo) > 0 ) {
870 $this->tot_deb=Database::fetch_result($res_saldo, 0, 0);
871 $this->tot_cred=Database::fetch_result($res_saldo, 0, 1);
872 }
873
875 }

References $g_user, $qcode, $row, $tot_cred, $tot_deb, ATTR_DEF_QUICKCODE, cn, echo_error(), DatabaseCore\fetch_result(), get_attribute(), and DatabaseCore\num_row().

Referenced by HtmlTable(), and HtmlTableDetail().

+ Here is the call graph for this function:

◆ get_row_result_deprecated()

Fiche::get_row_result_deprecated ( $res)
private

fetch and return and array

See also
get_row get_row_date
Deprecated
since version 6920

Definition at line 757 of file fiche.class.php.

758 {
759 $array=array();
760 $tot_cred=0.0;
761 $tot_deb=0.0;
763 if ( $Max == 0 ) return null;
764 bcscale(2);
765 for ($i=0;$i<$Max;$i++)
766 {
768 if ($array[$i]['j_debit']=='t')
769 {
770 $tot_deb=bcadd($tot_deb, $array[$i]['deb_montant'] );
771 }
772 else
773 {
774 $tot_cred=bcadd($tot_cred,$array[$i]['cred_montant'] );
775 }
776 }
777 $this->row=$array;
778 $this->tot_deb=$tot_deb;
779 $this->tot_cred=$tot_cred;
780 return array($array,$tot_deb,$tot_cred);
781 }

References $array, $i, $Max, $res, $tot_cred, $tot_deb, DatabaseCore\fetch_array(), and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ get_solde_detail()

Fiche::get_solde_detail ( $p_cond = "")

give the balance of an card

Returns
balance of the card

Definition at line 1259 of file fiche.class.php.

1260 {
1261 if ( $this->id == 0 ) return array('credit'=>0,'debit'=>0,'solde'=>0);
1263
1264 if ( $p_cond != "") $p_cond=" and ".$p_cond;
1265 $Res=$this->cn->exec_sql("select coalesce(sum(deb),0) as sum_deb,
1266 coalesce(sum(cred),0) as sum_cred from
1267 ( select j_poste,
1268 case when j_debit='t' then j_montant else 0 end as deb,
1269 case when j_debit='f' then j_montant else 0 end as cred
1270 from jrnx
1271 where
1272 j_qcode = ('$qcode'::text)
1273 $p_cond
1274 ) as m ");
1276 if ($Max==0) return 0;
1278
1279 return array('debit'=>$r['sum_deb'],
1280 'credit'=>$r['sum_cred'],
1281 'solde'=>abs($r['sum_deb']-$r['sum_cred']));
1282 }

References $Max, $qcode, $r, $Res, ATTR_DEF_QUICKCODE, cn, DatabaseCore\fetch_array(), get_attribute(), and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ getAttribut()

Fiche::getAttribut ( )

replace by load_attribute

Deprecated
since version 9.3.0.12
Returns
type

Definition at line 231 of file fiche.class.php.

231 {
232 return Card_Property::load($this);
233 }
static load(Fiche $fiche)
Load all the attribute of a card , it modifies the parameter $fiche.

References Card_Property\load().

+ Here is the call graph for this function:

◆ GetByDef()

Fiche::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.

Deprecated
See also
Fiche\get_by_category
Parameters
$p_frd_idthe fiche_def_ref.frd_id NOT USED , $this->fiche_def_ref will be used instead
$p_offset
$p_searchis an optional filter
$p_order: possible values are name, f_id
Returns
array of fiche object

Definition at line 303 of file fiche.class.php.

304 {
305 return $this->get_by_category($p_offset,$p_search,$p_order);
306 }
get_by_category($p_offset=-1, $p_search="", $p_order='')
get all the card thanks the fiche_def_ref

References $p_order, and get_by_category().

+ Here is the call graph for this function:

◆ getDisplayMode()

Fiche::getDisplayMode ( )
Returns
string

Definition at line 91 of file fiche.class.php.

91 : string
92 {
94 }

References $display_mode.

◆ getLabelCategory()

Fiche::getLabelCategory ( )
Returns
string with the category

Definition at line 405 of file fiche.class.php.

406 {
407 $type_card=$this->cn->get_value('select fd_label '
408 . ' from fiche_def join fiche using (fd_id) where f_id=$1',
409 array($this->id));
410 return $type_card;
411 }

References cn.

◆ getName()

Fiche::getName ( )

return the name of a card

Definition at line 652 of file fiche.class.php.

653 {
654 $sql="select ad_value from fiche_detail
655 where ad_id=1 and f_id=$1";
656 $Res=$this->cn->exec_sql($sql,array($this->id));
658 if ( empty($r) )
659 throw new Exception (_("Fiche n'existe pas"), 1000);
660 return $r[0]['ad_value'];
661 }

References $r, $Res, $sql, _, cn, and DatabaseCore\fetch_all().

Referenced by get_gestion_title(), and HtmlTableDetail().

+ Here is the call graph for this function:

◆ HtmlTable()

Fiche::HtmlTable ( $p_array = null,
$op_let = 0,
$from_div = 1 )

HtmlTable, display a HTML of a card for the asked period.

Parameters
$p_arraydefault = null keys = from_periode, to_periode
$op_let0 all operation, 1 only lettered one, 2 only unlettered one
Returns
-1 if nothing is found otherwise 0
See also
get_row_date

If the currency is not the default one , then show the amount

Definition at line 1005 of file fiche.class.php.

1006 {
1007 if ( $p_array == null)
1009 global $g_parameter;
1010 $progress=0;
1011 // if from_periode is greater than to periode then swap the values
1012 if (cmpDate($p_array['from_periode'],$p_array['to_periode']) > 0)
1013 {
1014 $tmp=$p_array['from_periode'];
1015 $p_array['from_periode']=$p_array['to_periode'];
1016 $p_array['to_periode']=$tmp;
1017
1018 }
1019 list($array, $tot_deb, $tot_cred) = $this->get_row_date($p_array['from_periode'], $p_array['to_periode'], $op_let);
1020
1021 if ( count($this->row ) == 0 )
1022 return -1;
1023
1024 $acc_account_ledger=new Acc_Account_Ledger($this->cn,$this->get_attribute(ATTR_DEF_ACCOUNT));
1025 $type=$acc_account_ledger->get_type();
1026 // label warning if the saldo is incorrect
1027 $label="";
1028 if (in_array($type,array('CHA','ACT','PASINV','PROINV')) && $tot_deb<$tot_cred)
1029 {
1030
1031 $label.=_("Solde créditeur au lieu de débiteur").'<span class="icon">&#xe80e;</span>';
1032 }
1033 if (in_array($type,array('PRO','PAS','ACTINV','CHAINV')) && $tot_deb>$tot_cred)
1034 {
1035
1036 $label.=_("Solde débiteur au lieu de créditeur")." ".'<span class="icon">&#xe80e;</span>';
1037 }
1038 if ( $label !="" )
1039 echo '<span class="notice" >'.$label.'</span>';
1040 $rep="";
1041 if ( $from_div==1)
1042 {
1043 echo "<TABLE id=\"tbpopup\" class=\"resultfooter\" style=\"margin:1%;width:98%;;border-collapse:collapse;border-spacing:0px 5px\">";
1044 }
1045 else
1046 {
1047 echo "<TABLE id=\"tb" . $from_div . "\"class=\"result\" style=\"margin:1%;width:98%;border-collapse:collapse;border-spacing:0px 2px\">";
1048 }
1049 echo '<tbody>';
1050 echo "<TR>".
1051 "<TH style=\"text-align:left\">"._('Date')."</TH>".
1052 "<TH style=\"text-align:left\">"._('Pièce')." </TH>".
1053 "<TH style=\"text-align:left\">"._('Poste')." </TH>".
1054 "<TH style=\"text-align:left\">"._('Interne')." </TH>".
1055 "<TH style=\"text-align:left\">"._('Tiers')." </TH>".
1056 "<TH class=\"visible_gt800\" style=\"text-align:left\">"._('Description')." </TH>".
1057 "<TH class=\"visible_gt800\" style=\"text-align:left\">"._('Type')."</TH>".
1058 "<TH class=\"visible_gt800\" style=\"text-align:left\">"._('ISO')."</TH>".
1059 "<TH class=\"visible_gt800\" style=\"text-align:right\">"._('Dev.')."</TH>".
1060 "<TH style=\"text-align:right\">"._('Débit')." </TH>".
1061 "<TH style=\"text-align:right\">"._('Crédit')." </TH>".
1062 th('Prog.','style="text-align:right"').
1063 th('Let.','class="visible_gt800" style="text-align:right"');
1064 "</TR>"
1065 ;
1066 $old_exercice="";$sum_deb=0;$sum_cred=0;
1067 bcscale(2);
1068 $idx=0;
1069 $operation=new Acc_Operation($this->cn);
1070 foreach ( $this->row as $op )
1071 {
1072 $vw_operation = sprintf('<A class="detail" style="text-decoration:underline;color:red" HREF="javascript:modifyOperation(\'%s\',\'%s\')" >%s</A>', $op['jr_id'], dossier::id(), $op['jr_internal']);
1073 $let = '';
1074 $html_let = "";
1075 if ($op['letter'] != "")
1076 {
1077 $let = strtoupper(base_convert($op['letter'], 10, 36));
1079 if ( $op['delta_letter'] != 0) $html_let='<img src="image/warning.png" onmouseover="displayBulle(\'delta = '.$op['delta_letter'].'\')" onmouseleave="hideBulle()" style="height:12px"/>'.$html_let;
1080 }
1081 $tmp_diff=bcsub($op['deb_montant'],$op['cred_montant']);
1082
1083 /*
1084 * reset prog. balance to zero if we change of exercice
1085 */
1086 if ( $old_exercice != $op['p_exercice'])
1087 {
1088 if ($old_exercice != '' )
1089 {
1090 $progress=bcsub($sum_deb,$sum_cred);
1091 $side="&nbsp;".$this->get_amount_side($progress);
1092 echo "<TR class=\"highlight\">".
1093 td($op['p_exercice']).
1094 td("",' class="visible_gt800" ').
1095 td("",' class="visible_gt800" ').
1096 td("",' class="visible_gt800" ').
1097 td().
1098 td(_('Totaux')).
1099 td("",' class="visible_gt800" ').
1100 td("",' class="" ').
1101 "<TD></TD>".
1102 "<TD style=\"text-align:right\">".nbm($sum_deb)."</TD>".
1103 "<TD style=\"text-align:right\">".nbm($sum_cred)."</TD>".
1104 td(nbm(abs($progress)).$side,'style="text-align:right"').
1105 td("",' class="visible_gt800" ').
1106 "</TR>";
1107 $sum_cred=0;
1108 $sum_deb=0;
1109 $progress=0;
1110 }
1111 }
1112 $progress=bcadd($progress,$tmp_diff);
1113 $side="&nbsp;".$this->get_amount_side($progress);
1114 $sum_cred=bcadd($sum_cred,$op['cred_montant']);
1115 $sum_deb=bcadd($sum_deb,$op['deb_montant']);
1116 if ($idx%2 == 0) $class='class="odd"'; else $class=' class="even"';
1117 $idx++;
1118
1119 $tiers=$operation->find_tiers($op['jr_id'], $op['j_id'], $op['j_qcode']);
1120 $op_analytic=($op['op_analytic']==1)?'<span style="float:right;background:black;color:white;">&ni;</span>':'';
1121 echo "<TR $class name=\"tr_" . $let . "_" . $from_div . "\">" .
1122 "<TD>".smaller_date(format_date($op['j_date_fmt']))."</TD>".
1123 td(h($op['jr_pj_number'])).
1124 td($op['j_poste']).
1125 "<TD>".$vw_operation."</TD>".
1126 td($tiers, ' class="visible_gt800" ').
1127 "<TD class=\"visible_gt800\" >".h($op['description']).$op_analytic."</TD>".
1128 td($op['jr_optype']);
1129
1130 /// If the currency is not the default one , then show the amount
1131 if ( $op['currency_id'] > 0 && $op['oc_amount'] != 0)
1132 {
1133 echo td($op['cr_code_iso'], ' class="visible_gt800" ').
1134 td(nbm($op['oc_amount'],4),' class="visible_gt800" style="text-align:right;padding-left:10px;"');
1135 } else {
1136 echo td("",' class="visible_gt800" ').td("",' class="visible_gt800" ');
1137 }
1138
1139 echo "<TD style=\"text-align:right\">".nbm($op['deb_montant'])."</TD>".
1140 "<TD style=\"text-align:right\">".nbm($op['cred_montant'])."</TD>".
1141 td(nbm(abs($progress)).$side,'style="text-align:right"').
1142 td($html_let, ' style="text-align:right" class="visible_gt800" ') .
1143 "</TR>";
1144 $old_exercice=$op['p_exercice'];
1145
1146 }
1147 $solde_type=($sum_deb>$sum_cred)?_("solde débiteur"):_("solde créditeur");
1148 $solde_side=($sum_deb>$sum_cred)?"D":"C";
1149 $diff=abs(bcsub($sum_deb,$sum_cred));
1150 echo '<tfoot>';
1151 echo "<TR class=\"highlight\">".
1152 td($op['p_exercice']).
1153 td("",' class="visible_gt800" ').
1154 td("",' class="visible_gt800" ').
1155 td("",' class="visible_gt800" ').
1156 td().
1157 td(_('Totaux')).
1158 td("",' class="visible_gt800" ').
1159 td("",' class="" ').
1160 "<TD></TD>".
1161 "<TD style=\"text-align:right\">".nbm($sum_deb)."</TD>".
1162 "<TD style=\"text-align:right\">".nbm($sum_cred)."</TD>".
1163 "<TD style=\"text-align:right\">".nbm($diff).$solde_side."</TD>".
1164 td("",' class="visible_gt800" ').
1165 "</TR>";
1166 echo "<TR style=\"font-weight:bold\">".
1167 "<TD>$solde_type</TD>".
1168 "<TD style=\"text-align:right\">".nbm($diff)."</TD>".
1169 "<TD></TD>".
1170 "</TR>";
1171 // take saldo from 1st day until last
1172 if ($g_parameter->MY_REPORT=='N') {
1173 $solde_until_now=$this->get_solde_detail(" j_date <= to_date('{$p_array['to_periode']}','DD.MM.YYYY') ");
1174 echo '<tr style="font-weight:bold;color:orangered">';
1175 echo td(_("Solde global"));
1176 echo td("D : ".nbm($solde_until_now['debit']),'class="num"');
1177 echo td("C : ".nbm($solde_until_now['credit']),'class="num"');
1178 echo td("Delta : ".nbm($solde_until_now['solde'])." ".$this->get_amount_side($solde_until_now['debit']-$solde_until_now['credit']),'class="num"');
1179 echo '</tr>';
1180
1181 }
1182 echo '</tfoot>';
1183 echo '</tbody>';
1184
1185 echo "</table>";
1186
1187 return 0;
1188 }
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='')
Definition ac_common.php:58
nbm($p_number, $p_dec=2)
format the number with a sep.
cmpDate($p_date, $p_date_oth)
Compare 2 dates.
global $g_parameter
$op
$from_div
$_REQUEST['ac']
$class
Display the Plugin and for each profile were it is installed or not.
get_row_date($p_from, $p_to, $op_let=0)
Get data for poste.
get_amount_side($p_amount)
return the letter C if amount is > 0, D if < 0 or =
get_solde_detail($p_cond="")
give the balance of an card
static show_reconcile($p_div, $let, $span="")
const ATTR_DEF_ACCOUNT
Definition constant.php:222
foreach( $Fiche->row as $op) $solde_type
if(count($array)==0) $acc_account_ledger

References $_REQUEST, $acc_account_ledger, $array, $class, $from_div, $g_parameter, $idx, $label, $let, $op, $operation, $p_array, $progress, $rep, $side, $tiers, $tmp, $tot_cred, $tot_deb, $type, _, ATTR_DEF_ACCOUNT, cmpDate(), cn, format_date(), get_attribute(), get_row_date(), h, nbm(), td(), and th().

+ Here is the call graph for this function:

◆ HtmlTableDetail()

Fiche::HtmlTableDetail ( $p_array = null,
$op_let = 0 )

HtmlTable, display a HTML of a card for the asked period.

Parameters
$op_let0 all operation, 1 only lettered one, 2 only unlettered one
Returns
none

Definition at line 937 of file fiche.class.php.

938 {
939 if ( $p_array == null)
941
942 $name=$this->getName();
943
944 list($array,$tot_deb,$tot_cred)=$this->get_row_date( $p_array['from_periode'],
945 $p_array['to_periode'],
946 $op_let
947 );
948
949 if ( count($this->row ) == 0 )
950 return;
952
953 $rep="";
954 $already_seen=array();
955 echo '<h2 class="info">'.$this->id." ".$name.'</h2>';
956 echo "<TABLE class=\"result\" style=\"width:100%;border-collapse:separate;border-spacing:5px\">";
957 echo "<TR>".
958 "<TH>"._("n° de pièce / Code interne")." </TH>".
959 "<TH>"._("Date")."</TH>".
960 "<TH>"._("Description")." </TH>".
961 "<TH>"._('Montant')." </TH>".
962 "<TH> "._('Débit/Crédit')." </TH>".
963 "</TR>";
964
965 foreach ( $this->row as $op )
966 {
967 if ( in_array($op['jr_internal'],$already_seen) )
968 continue;
969 else
970 $already_seen[]=$op['jr_internal'];
971 echo "<TR style=\"text-align:center;background-color:lightgrey\">".
972 "<td>".$op['jr_pj_number']." / ".$op['jr_internal']."</td>".
973 "<td>".$op['j_date']."</td>".
974 "<td>".h($op['description'])."</td>".
975 "<td>"."</td>".
976 "<td>"."</td>".
977 "</TR>";
978 $ac=new Acc_Operation($this->cn);
979 $ac->jr_id=$op['jr_id'];
980 $ac->qcode=$qcode;
981 echo $ac->display_jrnx_detail(1);
982
983 }
984 $solde_type=($tot_deb>$tot_cred)?_("solde débiteur"):_("solde créditeur");
985 $diff=round(abs($tot_deb-$tot_cred),2);
986 echo "<TR>".
987 "<TD>$solde_type".
988 "<TD>$diff</TD>".
989 "<TD></TD>".
990 "<TD>$tot_deb</TD>".
991 "<TD>$tot_cred</TD>".
992 "</TR>";
993
994 echo "</table>";
995
996 return;
997 }
if(isset( $_REQUEST[ 'show'])) if(isset($_REQUEST['del'])) $ac

References $_REQUEST, $ac, $array, $diff, $name, $op, $p_array, $qcode, $rep, $solde_type, $tot_cred, $tot_deb, _, ATTR_DEF_QUICKCODE, cn, get_attribute(), get_row_date(), and getName().

+ Here is the call graph for this function:

◆ HtmlTableHeader()

Fiche::HtmlTableHeader ( $p_array = null)

Display HTML Table Header (button)

Returns
none

Definition at line 1194 of file fiche.class.php.

1195 {
1196 if ( $p_array == null)
1198
1199 $hid=new IHidden();
1200 echo '<div class="noprint">';
1201 echo "<table >";
1202 echo '<TR>';
1203
1204 echo '<TD><form method="GET" ACTION="">'.
1205 HtmlInput::submit('bt_other',_("Autre poste")).
1206 HtmlInput::array_to_hidden(array('gDossier','ac'), $_REQUEST).
1207 dossier::hidden().
1208 $hid->input("type","poste").$hid->input('p_action','impress')."</form></TD>";
1209 $str_ople=(isset($_REQUEST['ople']))?HtmlInput::hidden('ople',$_REQUEST['ople']):'';
1210
1211 echo '<TD><form method="GET" ACTION="export.php" ';
1212 $id=uniqid("export_");
1213 printf( 'id="%s" onsubmit="download_document_form(\'%s\')">',$id,$id);
1214 echo
1215 HtmlInput::submit('bt_pdf',_("Export PDF")).
1216 dossier::hidden().$str_ople.
1217 HtmlInput::hidden('act','PDF:fichedetail').
1218 $hid->input("type","poste").
1219 $hid->input('p_action','impress').
1220 $hid->input("f_id",$this->id).
1221 dossier::hidden().
1222 $hid->input("from_periode",$p_array['from_periode']).
1223 $hid->input("to_periode",$p_array['to_periode']);
1224 if (isset($p_array['oper_detail']))
1225 echo $hid->input('oper_detail','on');
1226
1227 echo "</form></TD>";
1228
1229 echo '<TD><form method="GET" ACTION="export.php" ';
1230 $id=uniqid("export_");
1231 printf( 'id="%s" onsubmit="download_document_form(\'%s\')">',$id,$id);
1232
1233 echo HtmlInput::submit('bt_csv',_("Export CSV")).
1234 HtmlInput::hidden('act','CSV:fichedetail').
1235 dossier::hidden().$str_ople.
1236 $hid->input("type","poste").
1237 $hid->input('p_action','impress').
1238 $hid->input("f_id",$this->id).
1239 $hid->input("from_periode",$p_array['from_periode']).
1240 $hid->input("to_periode",$p_array['to_periode']);
1241 if (isset($p_array['oper_detail']))
1242 echo $hid->input('oper_detail','on');
1243
1244 echo "</form></TD>";
1245 echo "</form></TD>";
1246 echo '<td style="vertical-align:top">';
1248 echo '</td>';
1249 echo "</table>";
1250 echo '</div>';
1251
1252 }
static print_window()
Javascript to print the current window.
static hidden($p_name, $p_value, $p_id="")
static array_to_hidden($array, $global_array)
transform request data to hidden
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")

References $_REQUEST, $hid, $id, $p_array, and _.

◆ insert()

Fiche::insert ( $p_fiche_def,
$p_array = null,
$transaction = true )

insert a new record thanks an array , either as parameter or $_POST

Parameters
$p_fiche_deffiche_def.fd_id
$p_array(double array) array containing arrays of key (av_textX where X is AD_ID ), value of the property
$transationDEPRECATED : if we are in a transaction, we don't commit here , else if not, the then a transaction is started and committed

av_textX where X is the ad_id

example
av_text1=>'name'

Definition at line 495 of file fiche.class.php.

496 {
497 if ($p_array==null)
499
500 $fiche_id=$this->cn->get_next_seq('s_fiche');
501 $this->id=$fiche_id;
502 $this->fiche_def=$p_fiche_def;
503 try
504 {
505
506 // by default the card is available
507 if (!isset($p_array['f_enable']))
508 {
509 $p_array['f_enable']=1;
510 }
511 $Ret=$this->cn->exec_sql("insert into fiche(f_id,f_enable,fd_id) values ($1,$2,$3)",
512 array($fiche_id, $p_array['f_enable'], $p_fiche_def));
513 // first we need to save the name , to compute properly the quickcode
514 if ( empty ($p_array['av_text'.ATTR_DEF_NAME])) {
515
516 $p_array['av_text'.ATTR_DEF_NAME]=_("Nom vide");
517 }
518 // the name must be saved first
519 $this->cn->exec_sql("insert into fiche_detail (f_id,ad_id,ad_value) values ($1,$2,$3)",
520 array($fiche_id,1,$p_array['av_text'.ATTR_DEF_NAME]));
521
522 // compute a quick_code
523 if (!isset($p_array["av_text".ATTR_DEF_QUICKCODE]))
524 {
525 $p_array["av_text".ATTR_DEF_QUICKCODE]="";
526 }
527 // by default the quick_code is the base account of the class + first letters of the name
528 if ( $p_array["av_text".ATTR_DEF_QUICKCODE] =="")
529 {
530 if ( ! empty( $p_array['av_text'. ATTR_DEF_ACCOUNT])) {
531 $base_acc=substr($p_array['av_text'. ATTR_DEF_ACCOUNT]??"",0, 3);
532 }else {
533 $base_acc=$this->cn->get_value("select substr(fd_class_base,1,2) from fiche_def where fd_id = $1",
534 [$p_fiche_def]);
535 }
536 $p_array["av_text".ATTR_DEF_QUICKCODE]=sprintf("%s%s"
537 , $base_acc
538 , substr($p_array["av_text".ATTR_DEF_NAME], 0, 4)
539 );
540 }
541 $sql=sprintf("select insert_quick_code(%d,'%s')", $fiche_id,
543 $this->cn->exec_sql($sql);
544 // get the card properties for this card category
545 $fiche_def=new Fiche_Def($this->cn, $p_fiche_def);
546
547 $this->attribut=$fiche_def->load_attribute();
548
549 if (empty($this->attribut))
550 {
551 throw new Exception("FICHE.UPDATE02"._("Aucun attribut ")."($p_fiche_def)", EXC_INVALID);
552 }
553 // for each property set the attribut on the card
554 foreach ($this->attribut as $property)
555 {
556 $key='av_text'.$property->ad_id;
557 if (isset($p_array[$key]))
558 {
559 $this->set_attribute($property->ad_id, $p_array[$key]);
560 }
561 }
562 // For accounting
563
565 // reread from database
566 $this->load_attribute();
567 }
568 catch (Exception $e)
569 {
570 record_log($e);
571 $this->cn->rollback();
572 throw (new \Exception ("F561 ". __CLASS__.".".__FUNCTION__,561,$e));
573 return;
574 }
575 return;
576 }
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...
set_attribute($p_ad_id, $p_value)
set an attribute by a value, if the attribut array is empty a call to load_attribute is performed
const EXC_INVALID
Definition constant.php:358
$_POST['ac']
Definition do.php:323

References $_POST, $e, $fiche_def, $fiche_id, $p_array, $sql, _, ATTR_DEF_ACCOUNT, ATTR_DEF_NAME, ATTR_DEF_QUICKCODE, cn, EXC_INVALID, load_attribute(), record_log(), set_attribute(), sql_string(), and Card_Property\update().

Referenced by save().

+ Here is the call graph for this function:

◆ is_used()

Fiche::is_used ( )

check if a card is used

Returns
return true is a card is used otherwise false

Definition at line 1661 of file fiche.class.php.

1662 {
1663 /* retrieve first the quickcode */
1665 $sql='select count(*) as c from jrnx where j_qcode=$1';
1666 $count=$this->cn->get_value($sql,array($qcode));
1667 if ( $count > 0 ) return TRUE;
1668 $count=$this->cn->get_value("select count(*) from action_gestion where f_id_dest=$1 or ag_contact=$1 ",
1669 [$this->id]);
1670 if ( $count > 0 ) return TRUE;
1671 $count=$this->cn->get_value("select count(*) from action_person where f_id=$1 ",
1672 [$this->id]);
1673 if ( $count > 0 ) return TRUE;
1674
1675 $count=$this->cn->get_value("
1676 select count(*)
1677 from attr_def
1678 join fiche_detail using (ad_id)
1679 where ad_type='card'
1680 and ad_value=$1"
1681 ,[$qcode]);
1682
1683 if ( $count > 0 ) return TRUE;
1684
1685 return FALSE;
1686
1687 }
$count

References $count, $qcode, $sql, ATTR_DEF_QUICKCODE, cn, and get_attribute().

Referenced by remove().

+ Here is the call graph for this function:

◆ load()

Fiche::load ( )

Synonum of fiche::load_attribute.

Definition at line 684 of file fiche.class.php.

684 :void
685 {
686 $this->load_attribute();
687 }

References load_attribute().

Referenced by __construct().

+ Here is the call graph for this function:

◆ load_attribute()

Fiche::load_attribute ( )

get all the attribute of a card, add missing ones and sort the array ($this->attribut) by ad_id

Definition at line 238 of file fiche.class.php.

239 {
240 Card_Property::load($this);
241 }

References Card_Property\load().

Referenced by Display(), display_row(), Get(), get_attribute(), get_by_qcode(), insert(), load(), set_attribute(), to_array(), and update().

+ Here is the call graph for this function:

◆ move_to()

Fiche::move_to ( $p_fdid)

move a card to another cat.

The properties will changed and be removed

Parameters
$p_fdidthe fd_id of destination

Definition at line 1810 of file fiche.class.php.

1811 {
1812 $this->cn->start();
1813 $this->cn->exec_sql('update fiche set fd_id=$1 where f_id=$2',array($p_fdid,$this->id));
1814 // add missing
1815 $this->cn->exec_sql('select fiche_attribut_synchro($1)',array($p_fdid));
1816 // add to the destination missing fields
1817 $this->cn->exec_sql("insert into jnt_fic_attr (fd_id,ad_id,jnt_order) select $1,ad_id,100 from fiche_detail where f_id=$2 and ad_id not in (select ad_id from jnt_fic_attr where fd_id=$3)",array($p_fdid,$this->id,$p_fdid));
1818 $this->cn->commit();
1819 }

References cn.

◆ remove()

Fiche::remove ( $silent = false)

remove a card, check if not used first, must be synchro with is_used

Definition at line 631 of file fiche.class.php.

632 {
633 if ( $this->id==0 ) return;
634 // verify if that card has not been used is a ledger nor in the followup
635 // if the card has its own account in PCMN
636 // Get the fiche_def.fd_id from fiche.f_id
637 if ( $this->is_used() == FALSE) {
638 $this->delete();
639 return 0;
640 }
641
642 if ( ! $silent ) {
643 alert(_('Impossible cette fiche est utilisée dans un journal'));
644 }
645 return 1;
646 }
alert($p_msg, $buffer=false)
alert in javascript
is_used()
check if a card is used

References _, alert(), and is_used().

+ Here is the call graph for this function:

◆ save()

Fiche::save ( $p_fiche_def = 0)

Save a card, call insert or update.

See also
Fiche\insert , Fiche\update
Parameters
p_fiche_def(default 0)

Definition at line 473 of file fiche.class.php.

474 {
475 // new card or only a update ?
476 if ( $this->id == 0 )
477 $this->insert($p_fiche_def);
478 else
479 $this->update();
480 }
insert($p_fiche_def, $p_array=null, $transaction=true)
insert a new record thanks an array , either as parameter or $_POST
update($p_array=null)
update a card with an array

References insert(), and update().

+ Here is the call graph for this function:

◆ seek()

Fiche::seek ( $p_attribut,
$p_value )

find the card with the p_attribut equal to p_value, it is not case sensitive

Parameters
int$p_attributattribute to find see table attr_def
string$p_valuevalue in attr_value.av_text
Returns
array returns ARRAY OF jft_id,f_id,fd_id,ad_id,av_text

Definition at line 248 of file fiche.class.php.

249 {
250 $sql="select jft_id,f_id,fd_id,ad_id,ad_value from fiche join fiche_detail using (f_id)
251 where ad_id=$1 and upper(ad_value)=upper($2)";
252 $res=$this->cn->get_array($sql,array($p_attribut,$p_value));
253 return $res;
254 }

References $res, $sql, and cn.

◆ set_attribute()

Fiche::set_attribute ( $p_ad_id,
$p_value )

set an attribute by a value, if the attribut array is empty a call to load_attribute is performed

Parameters
intAD_ID attr_def.ad_id
intvalue value of this attribute
See also
constant.php table: attr_def

Definition at line 212 of file fiche.class.php.

213 {
214 if ( $this->fiche_def == 0) throw new Exception ("FICHE.179 Invalid category",EXC_INVALID);
215 if ( sizeof($this->attribut)==0 ) $this->load_attribute();
216
217 for ($e=0;$e <sizeof($this->attribut);$e++)
218 {
219 if ( $this->attribut[$e]->ad_id == $p_ad_id )
220 {
221 $this->attribut[$e]->av_text=$p_value;
222 break;
223 }
224 }
225 }

References $attribut, $e, EXC_INVALID, and load_attribute().

Referenced by insert(), setAttribut(), and update().

+ Here is the call graph for this function:

◆ set_f_enable()

Fiche::set_f_enable ( $f_enable)

Definition at line 128 of file fiche.class.php.

129 {
130 $this->f_enable=$f_enable;
131 return $this;
132 }

References $f_enable.

Referenced by update().

◆ set_fiche_def()

Fiche::set_fiche_def ( $p_fiche_def)

Definition at line 95 of file fiche.class.php.

96 {
97 $this->fiche_def=$p_fiche_def;
98 return $this;
99 }

◆ set_fiche_def_ref()

Fiche::set_fiche_def_ref ( $fiche_def_ref)

Definition at line 122 of file fiche.class.php.

123 {
124 $this->fiche_def_ref=$fiche_def_ref;
125 return $this;
126 }

References $fiche_def_ref.

◆ set_id()

Fiche::set_id ( $id)

Definition at line 116 of file fiche.class.php.

117 {
118 $this->id=$id;
119 return $this;
120 }

References $id.

◆ setAttribut()

Fiche::setAttribut ( $p_ad_id,
$p_value )

replace by set_attribute

Deprecated
since version 9.3.0.12

Definition at line 202 of file fiche.class.php.

202 {
203 $this->set_attribute($p_ad_id, $p_value);
204 }

References set_attribute().

+ Here is the call graph for this function:

◆ setDisplayMode()

Fiche::setDisplayMode ( $p_mode)

how the card is display : either in a window or a greated container

Parameters
string$p_modecan be large or window
Returns
Fiche
Exceptions
Exception

Definition at line 80 of file fiche.class.php.

80 {
81 if ( ! in_array($p_mode,array("window","large"))) {
82 throw new Exception("FIC70 invalide display mode");
83 }
84 $this->display_mode=$p_mode;
85 return $this;
86 }

◆ ShowTable()

Fiche::ShowTable ( )

Definition at line 307 of file fiche.class.php.

308 {
309 echo "<TR><TD> ".
310 $this->id."</TD>".
311 "<TR> <TD>".
312 $this->attribut_value."</TD>".
313 "<TR> <TD>".
314 $this->attribut_def."</TD></TR>";
315 }

◆ strAttribut()

Fiche::strAttribut ( $p_ad_id,
$p_return = 1 )

use get_attribute instead

Deprecated
since version 9.3.12
Parameters
int$p_ad_idAD_ID from attr_def.ad_id
int$p_return1 return NOTFOUND otherwise an empty string

Definition at line 322 of file fiche.class.php.

323 {
324 return $this->get_attribute($p_ad_id,$p_return);
325 }

References get_attribute().

+ Here is the call graph for this function:

◆ Summary()

Fiche::Summary ( $p_search = "",
$p_action = "",
$p_sql = "",
$p_amount = false )

show the default screen

Parameters
$p_search(filter)
$p_actionused for specific action bank, red if credit < debit
$p_sqlSQL to filter the number of card must start with AND
$p_amounttrue : only cards with at least one operation default : false
Returns
: string to display

the accounting is a financial account

Reimplemented in contact.

Definition at line 1366 of file fiche.class.php.

1367 {
1368 global $g_user;
1369 global $g_parameter;
1370 $http=new HttpInput();
1371 $bank=new Acc_Parm_Code($this->cn,'BANQUE');
1372 $cash=new Acc_Parm_Code($this->cn,'CAISSE');
1373 $cc=new Acc_Parm_Code($this->cn,'COMPTE_COURANT');
1374
1375 bcscale(4);
1376 $gDossier=dossier::id();
1377 $p_search=sql_string($p_search);
1378 $script=$_SERVER['PHP_SELF']??"";
1379 // Creation of the nav bar
1380 // Get the max numberRow
1381 $filter_amount='';
1382
1383 $filter_year=" j_tech_per in (select p_id from parm_periode ".
1384 "where p_exercice='".$g_user->get_exercice()."')";
1385
1386 if ($p_amount) {
1387 $filter_amount = ' and f_id in (select f_id from jrnx where ' . $filter_year . ')';
1388 }
1389
1390 $all_tiers=$this->count_by_modele($this->fiche_def_ref,"",$p_sql.$filter_amount);
1391 // Get offset and page variable
1392 $offset=$http->request("offset","number",0);
1393 $page=$http->request("page","number",1);
1394 $bar=navigation_bar($offset,$all_tiers,$_SESSION[SESSION_KEY.'g_pagesize'],$page);
1395
1396 // set a filter ?
1397 $search=$p_sql;
1398
1399 if ( noalyss_trim($p_search) != "" )
1400 {
1401 $search.=" and f_id in
1402 (select distinct f_id from fiche_detail
1403 where
1404 ad_id in (1,32,30,23,18,13) and ad_value ilike '%$p_search%')";
1405 }
1406 // Get The result Array
1407 $step_tiers=$this->get_by_category($offset,$search.$filter_amount,'name');
1408
1409 if ( $all_tiers == 0 || empty($step_tiers ) ) { return ""; }
1410 $r="";
1411 $r.=$bar;
1412
1413 $r.='<table id="tiers_tb" class="sortable" style="">
1414 <TR >
1415 <TH>'._('Quick Code').Icon_Action::infobulle(17).'</TH>'.
1416 '<th>'._('Poste comptable').'</th>'.
1417 '<th class="sorttable_sorted">'._('Nom').'</span>'.'</th>'.
1418 '<th>'._('Compte en banque').'</th>'.
1419 '<th>'._('Adresse').'</th>'.
1420 '<th>'._('site web').'</th>'.
1421 '<th style="text-align:right">'._('Total débit').'</th>
1422 <th style="text-align:right">'._('Total crédit').'</th>
1423 <th style="text-align:right">'._('Solde').'</th>';
1424 $r.='</TR>';
1425 if ( sizeof ($step_tiers ) == 0 )
1426 return $r;
1427
1428 $i=0;
1429 $deb=0;$cred=0;
1430 foreach ($step_tiers as $tiers )
1431 {
1432 $i++;
1433
1434 /* Filter on the default year */
1435 if ( $g_parameter->MY_REPORT == 'N') {
1436 list($l_from,$l_to)=(new Periode($this->cn))->get_limit($g_user->get_exercice());
1437 $condition = sprintf (" j_date <= to_date('%s','DD.MM.YYYY') ", $l_to->last_day());
1438 $amount = $tiers->get_solde_detail($condition);
1439 } else {
1440 $amount=$tiers->get_solde_detail($filter_year);
1441 }
1442
1443 /* skip the tiers without operation */
1444 if ( $p_amount && $amount['debit']==0 && $amount['credit'] == 0 && $amount['solde'] == 0 ) continue;
1445
1446 $odd="";
1447 $odd = ($i % 2 == 0 ) ? ' odd ': ' even ';
1448 $accounting=$tiers->get_attribute(ATTR_DEF_ACCOUNT,0);
1449 if ( ! empty($accounting) && $p_action == 'bank'
1450 && $amount['debit'] < $amount['credit']
1451 &&
1452 ( /** the accounting is a financial account *****/
1453 (!empty ($bank->value) && strpos($accounting,$bank->p_value)===0 )
1454 || (!empty ($cash->value) && strpos($accounting,$cash->p_value)===0 )
1455 || ( !empty ($cc->value) && strpos($accounting,$cc->p_value)===0)
1456 )
1457 )
1458 {
1459 //put in red if c>d
1460 $odd.=" notice ";
1461 }
1462
1463 $odd=' class="'.$odd.'"';
1464
1465 $r.="<TR $odd>";
1466 $url_detail=$script.'?'.http_build_query(array('sb'=>'detail','sc'=>'sv','ac'=>$_REQUEST['ac'],'f_id'=>$tiers->id,'gDossier'=>$gDossier));
1467 $e=sprintf('<A HREF="%s" title="Détail" class="line"> ',
1468 $url_detail);
1469
1470 $r.="<TD> $e".$tiers->get_attribute(ATTR_DEF_QUICKCODE)."</A></TD>";
1471 $r.="<TD sorttable_customkey=\"text{$accounting}\"> $e".$accounting."</TD>";
1472 $r.="<TD>".h($tiers->get_attribute(ATTR_DEF_NAME))."</TD>";
1473 $r.=td($tiers->get_attribute(ATTR_DEF_BQ_NO,0));
1474 $r.="<TD>".h($tiers->get_attribute(ATTR_DEF_ADRESS,0).
1475 " ".$tiers->get_attribute(ATTR_DEF_POSTCODE,0).
1476 " ".$tiers->get_attribute(ATTR_DEF_COUNTRY,0)).
1477 "</TD>";
1478 $r.='<td>'.linkTo($tiers->get_attribute(ATTR_DEF_WEBSITE,0)).'</td>';
1479 $str_deb=(($amount['debit']==0)?0:nbm($amount['debit']));
1480 $str_cred=(($amount['credit']==0)?0:nbm($amount['credit']));
1481 $str_solde=nbm($amount['solde']);
1482 $r.='<TD sorttable_customkey="'.$amount['debit'].'" align="right"> '.$str_deb.'</TD>';
1483 $r.='<TD sorttable_customkey="'.$amount['credit'].'" align="right"> '.$str_cred.'</TD>';
1484 $side=($amount['debit'] > $amount['credit'])?'D':'C';
1485 $side=($amount['debit'] == $amount['credit'])?'=':$side;
1486 $red="";
1487 if ( $p_action == 'customer' && $amount['debit'] < $amount['credit'] ){
1488 //put in red if d>c
1489 $red=" notice ";
1490 }
1491 if ( $p_action == 'supplier' && $amount['debit'] > $amount['credit'] ){
1492 //put in red if c>d
1493 $red=" notice ";
1494 }
1495 $r.='<TD class="'.$red.'" sorttable_customkey="'.$amount['solde'].'" align="right"> '.$str_solde."$side </TD>";
1496 $deb=bcadd($deb,$amount['debit']);
1497 $cred=bcadd($cred,$amount['credit']);
1498
1499 $r.="</TR>";
1500
1501 }
1502 $r.="<tfoot >";
1503 $solde=abs(bcsub($deb,$cred));
1504 $side=($deb > $cred)?'Débit':'Crédit';
1505 $r.='<tr class="highlight">';
1506 $r.=td("").td("").td("").td("").td("Totaux").td(nbm($deb),'class="num"').td(nbm($cred),'class="num"').td(" $side ".nbm($solde),'class="num"');
1507 $r.='</tr>';
1508 $r.="</tfoot>";
1509 $r.="</TABLE>";
1510 $r.=$bar;
1511
1512 return $r;
1513 }
if(trim($query)==''|| $filter=='') $search
if(! isset($_GET['submit_query'])) $p_action
count_by_modele($p_frd_id, $p_search="", $p_sql="")
Count the nb of card with the reference card id frd_id.
const ATTR_DEF_ADRESS
Definition constant.php:230
const ATTR_DEF_COUNTRY
Definition constant.php:232
const ATTR_DEF_WEBSITE
Definition constant.php:246
const ATTR_DEF_BQ_NO
Definition constant.php:224
const ATTR_DEF_POSTCODE
Definition constant.php:231
catch(\Exception $e) $bar
$script
Definition popup.php:131
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

References $_REQUEST, $accounting, $amount, $bar, $cred, $deb, $e, $filter_year, $g_parameter, $g_user, $gDossier, $http, $i, $offset, $p_action, $r, $script, $search, $side, $solde, $tiers, _, ATTR_DEF_ACCOUNT, ATTR_DEF_ADRESS, ATTR_DEF_BQ_NO, ATTR_DEF_COUNTRY, ATTR_DEF_NAME, ATTR_DEF_POSTCODE, ATTR_DEF_QUICKCODE, ATTR_DEF_WEBSITE, cn, count_by_modele(), get_by_category(), navigation_bar(), nbm(), noalyss_trim(), sql_string(), and td().

+ Here is the call graph for this function:

◆ test_me()

static Fiche::test_me ( )
static

Definition at line 1834 of file fiche.class.php.

1835 {
1837 $http=new HttpInput();
1838 echo h1('Test select category');
1839 $a=new Fiche($cn);
1840 $select_cat=new ISelect('fd_id');
1841 $select_cat->value=$cn->make_array('select fd_id,fd_label from fiche_def where frd_id='.
1843 echo '<FORM METHOD="GET"> ';
1844 echo dossier::hidden();
1845 echo HtmlInput::hidden('test_select',$http->get('test_select',"string",1));
1846 echo 'Choix de la catégorie';
1847 echo $select_cat->input();
1848 echo HtmlInput::submit('go_card','Afficher');
1849 echo '</form>';
1850 if ( isset ($_GET['go_card']))
1851 {
1852 $empty=$a->to_array($_GET['fd_id']);
1853 print_r($empty);
1854 }
1855 // testing insert
1856 echo h1("Insert new card");
1857 $name="test ".microtime();
1858 $fiche=new Fiche($cn);
1859 $fiche_def=new Fiche_Def($cn,1);
1860 $fiche_def->get();
1861
1862 $fiche->set_fiche_def($fiche_def->id);
1863
1864 $fiche->set_attribute(ATTR_DEF_NAME,$name);
1865 $fiche->set_attribute(ATTR_DEF_ACCOUNT,$fiche_def->class_base.$name);
1866
1867 echo p(print_r($fiche->to_array(),false));
1868 $fiche->insert(1,$fiche->to_array());
1869 assert($name == $fiche->get_attribute(ATTR_DEF_NAME));
1870
1871 echo p("fiche ATTR_DEF_ACCOUNT after insert ",$fiche->get_attribute(ATTR_DEF_ACCOUNT));
1872 $accounting=$fiche->get_attribute(ATTR_DEF_ACCOUNT);
1873 $acc_accounting=new Acc_Account($cn,$accounting);
1874
1875 echo p("accounting id",$acc_accounting->get_parameter("id"));
1876 assert($acc_accounting->get_lib("pcm_lib") == $name,"Cannot create a new accouting with
1877 the right label");
1878 }
p($p_string, $p_extra='')
Definition ac_common.php:39
h1($p_string, $p_class="")
Definition ac_common.php:72
$select_cat
$_GET['qcode']
static connect()
const FICHE_TYPE_CLIENT
Definition constant.php:259

References $_GET, $a, $accounting, $cn, $fiche, $fiche_def, $http, $name, $select_cat, ATTR_DEF_ACCOUNT, ATTR_DEF_NAME, FICHE_TYPE_CLIENT, h1(), and p().

+ Here is the call graph for this function:

◆ to_array()

Fiche::to_array ( )

turn a card into an array , then it can be saved thanks update or insert

See also
Fiche\insert , Fiche\update

Definition at line 356 of file fiche.class.php.

357 {
358 $a_return=[];
359 if ( empty ($this->attribut)) {
360 $this->load_attribute();
361 }
362 foreach ($this->attribut as $attr)
363 {
364 $a_return['av_text'.$attr->ad_id]=$attr->av_text;
365 }
366 $a_return['f_enable']=$this->get_f_enable();
367 return $a_return;
368 }
get_f_enable()

References $attr, get_f_enable(), and load_attribute().

+ Here is the call graph for this function:

◆ update()

Fiche::update ( $p_array = null)

update a card with an array

Parameters
$p_array(optional) is the array containing the data , if NULL then $_POST will be uses
$transationif we want to manage the transaction in this function true for small insert and false for a larger loading, the BEGIN / COMMIT sql must be done into the caller av_textX where X is the ad_id \verb example av_text1=>'name' \endverb

Definition at line 590 of file fiche.class.php.

591 {
592 if ($p_array==null)
593 {
595 }
596 $this->fiche_def = $this->cn->get_value("select fd_id from fiche where f_id=$1",[$this->id]);
597 // unexistant category of cardf
598 if ( empty($this->fiche_def)) {
599 throw new Exception('FICHE.UPDATE524 category not found',EXC_INVALID);
600 }
601 if ( $this->cn->size()==0) {
602 throw new Exception("FICHE.UPDATE01"._("Fiche n'existe pas"),EXC_INVALID);
603 }
604
605
606 // get the card properties for this card category
607 $this->load_attribute();
608
609 if ( empty ($this->attribut) ) {
610 throw new Exception("FICHE.UPDATE02"._("Aucun attribut ")."($this->fiche_def)",EXC_INVALID);
611 }
612 // for each property set the attribut on the card
613 foreach($this->attribut as $property) {
614 $key='av_text'.$property->ad_id;
615 if ( isset($p_array[$key])) {
616 $this->set_attribute($property->ad_id, $p_array[$key]);
617 }
618 }
619 if ( isset($p_array['f_enable'])) {
620 $this->set_f_enable($p_array["f_enable"]);
621 }else {
622 $this->set_f_enable(1);
623 }
624 // save all
626 $this->quick_code=$this->get_attribute(ATTR_DEF_QUICKCODE);
627 }
set_f_enable($f_enable)

References $_POST, $p_array, _, ATTR_DEF_QUICKCODE, cn, EXC_INVALID, get_attribute(), load_attribute(), set_attribute(), set_f_enable(), and Card_Property\update().

Referenced by save().

+ Here is the call graph for this function:

Field Documentation

◆ $attribut

Fiche::$attribut

< $fiche_def fd_id

Definition at line 42 of file fiche.class.php.

Referenced by Display(), and set_attribute().

◆ $cn

Fiche::$cn

Definition at line 39 of file fiche.class.php.

Referenced by from_qcode(), and test_me().

◆ $display_mode

Fiche::$display_mode
private

how the card is displaid

Definition at line 47 of file fiche.class.php.

Referenced by getDisplayMode().

◆ $f_enable

Fiche::$f_enable
private

if card is enable (fiche.f_enable)

Definition at line 46 of file fiche.class.php.

Referenced by Display(), get_f_enable(), and set_f_enable().

◆ $fiche_def

Fiche::$fiche_def

< $id fiche.f_id

Definition at line 41 of file fiche.class.php.

Referenced by blank(), Display(), insert(), and test_me().

◆ $fiche_def_ref

Fiche::$fiche_def_ref

< $attribut array of Card_Property objects $fiche_def_ref Type

Definition at line 43 of file fiche.class.php.

Referenced by get_fiche_def_ref(), and set_fiche_def_ref().

◆ $id

Fiche::$id

< $cn database connection

Definition at line 40 of file fiche.class.php.

Referenced by get_bank_ledger(), get_id(), HtmlTableHeader(), and set_id().

◆ $ledger_description

Fiche::$ledger_description

!< this variable is a mistake, it shouldn't exist, need code rewrite

Definition at line 51 of file fiche.class.php.

◆ $ledger_name

Fiche::$ledger_name

Definition at line 50 of file fiche.class.php.

◆ $quick_code

Fiche::$quick_code

< All the row from the ledgers quick_code of the card

Definition at line 45 of file fiche.class.php.

Referenced by get_by_qcode().

◆ $row

◆ $tot_cred

Fiche::$tot_cred

◆ $tot_deb

Fiche::$tot_deb

The documentation for this class was generated from the following file: