noalyss Version-9
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 ($p_jrn, $p_type="")
 Check if a fiche is used by a jrn return 1 if the fiche is in the range otherwise 0, the quick_code or the id must be set.
 
 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::getAttribut.
 
 get_all_account ()
 
 get_amount_side ($p_amount)
 return the letter C if amount is > 0, D if < 0 or =
 
 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 ()
 get all the attribute of a card, add missing ones and sort the array ($this->attribut) by ad_id
 
 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::getAttribut.
 
 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_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)
 set an attribute by a value, if the attribut array is empty a call to getAttribut is performed
 
 setDisplayMode ($p_mode)
 how the card is display : either in a window or a greated container
 
 ShowTable ()
 
 strAttribut ($p_ad_id, $p_return=1)
 
 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 ($p_qcode)
 create a card from a qcode and returns a card
 
static get_fiche_def ($p_cn, $pFd_id, $p_order='')
 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::getAttribut.

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

+ Here is the call graph for this function:

Member Function Documentation

◆ __toString()

Fiche::__toString ( )

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

371 : string
372 {
373 return print_r($this,true);
374 }

◆ belong_ledger()

Fiche::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, the quick_code or the id must be set.

Parameters
$p_jrnjournal_id
$p_type: deb or cred default empty
Returns
1 if the fiche is in the range otherwise < 1 -1 the card doesn't exist -2 the ledger has no card to check

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

1485 {
1486 // check if we have a quick_code or a f_id
1487 if (($this->quick_code==null || $this->quick_code == "" )
1488 && $this->id == 0 )
1489 {
1490 throw new Exception( 'erreur ni quick_code ni f_id ne sont donnes');
1491 }
1492
1493 //retrieve the quick_code
1494 if ( $this->quick_code=="")
1495 $this->quick_code=$this->get_quick_code();
1496
1497
1498 if ( $this->quick_code==null)
1499 return -1;
1500
1501 if ( $this->id == 0 )
1502 if ( $this->get_by_qcode(null,false) == 1)
1503 return -1;
1504
1505 $get="";
1506 if ( $p_type == 'deb' )
1507 {
1508 $get='jrn_def_fiche_deb';
1509 }elseif ( $p_type == 'cred' )
1510 {
1511 $get='jrn_def_fiche_cred';
1512 }
1513 if ( $get != "" )
1514 {
1515 $Res=$this->cn->exec_sql("select $get as fiche from jrn_def where jrn_def_id=$p_jrn");
1516 }
1517 else
1518 {
1519 // Get all the fiche type (deb and cred)
1520 $Res=$this->cn->exec_sql(" select jrn_def_fiche_cred as fiche
1521 from jrn_def where jrn_def_id=$p_jrn
1522 union
1523 select jrn_def_fiche_deb
1524 from jrn_def where jrn_def_id=$p_jrn"
1525 );
1526 }
1528 if ( $Max==0)
1529 {
1530 return -2;
1531 }
1532 /* convert the array to a string */
1534 $str_list="";
1535 $comma='';
1536 foreach ($list as $row)
1537 {
1538 if ( $row['fiche'] != '' )
1539 {
1540 $str_list.=$comma.$row['fiche'];
1541 $comma=',';
1542 }
1543 }
1544 // Normally Max must be == 1
1545
1546 if ( $str_list=="")
1547 {
1548 return -3;
1549 }
1550
1551 $sql="select *
1552 from fiche
1553 where
1554 fd_id in (".$str_list.") and f_id= ".$this->id;
1555
1556 $Res=$this->cn->exec_sql($sql);
1558 if ($Max==0 )
1559 return 0;
1560 else
1561 return 1;
1562 }
static fetch_all($ret)
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)

References $id, $list, $Max, $p_jrn, $p_type, $Res, $row, $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 352 of file fiche.class.php.

353 {
354 // array = array of attribute object sorted on ad_id
355 $fiche_def=new Fiche_Def($this->cn,$p_fiche_def);
356 $fiche_def->get();
357 $array=$fiche_def->getAttribut();
358 $r="";
359 $r.='<table style="width:98%;margin:1%">';
360 foreach ($array as $attr)
361 {
362 $table=0;
363 $msg="";$bulle='';
364 $r.=$attr->input($fiche_def);
365
366 }
367 $r.= '</table>';
368 return $r;
369 }
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 1645 of file fiche.class.php.

1646 {
1647 if (!empty($array))
1648 extract($array, EXTR_SKIP);
1649 $and='';
1650 $filter_fd_id='true';
1651 $filter_query='';
1652 if (isset($typecard))
1653 {
1654 if (strpos($typecard, "sql")==false)
1655 {
1656 switch ($typecard)
1657 {
1658 case 'cred':
1659 if (!isset($jrn))
1660 throw Exception('Erreur pas de valeur pour jrn');
1661 $filter_jrn=$this->cn->make_list("select jrn_def_fiche_cred from jrn_Def where jrn_def_id=$1",
1662 array($jrn));
1663 $filter_fd_id=(empty($filter_jrn))?" fd_id in (-1) ":" fd_id in (".$filter_jrn.")";
1664 $and=" and ";
1665 break;
1666 case 'deb':
1667 if (!isset($jrn))
1668 throw Exception('Erreur pas de valeur pour jrn');
1669 $filter_jrn=$this->cn->make_list("select jrn_def_fiche_deb from jrn_Def where jrn_def_id=$1",
1670 array($jrn));
1671 $filter_fd_id=(empty($filter_jrn))?"fd_id in (-1) ":" fd_id in (".$filter_jrn.")";
1672 $and=" and ";
1673 break;
1674 case 'filter':
1675 if (!isset($jrn))
1676 throw Exception('Erreur pas de valeur pour jrn');
1677 $filter_jrn=$this->cn->make_list("select jrn_def_fiche_deb from jrn_Def where jrn_def_id=$1",
1678 array($jrn));
1679
1680 if (noalyss_trim($filter_jrn)!='')
1681 $fp1=" fd_id in (".$filter_jrn.")";
1682 else
1683 $fp1="fd_id < 0";
1684
1685 $filter_jrn=$this->cn->make_list("select jrn_def_fiche_cred from jrn_Def where jrn_def_id=$1",
1686 array($jrn));
1687
1688 if (noalyss_trim($filter_jrn)!='')
1689 $fp2=" fd_id in (".$filter_jrn.")";
1690 else
1691 $fp2="fd_id < 0";
1692
1693 $filter_fd_id='('.$fp1.' or '.$fp2.')';
1694
1695 $and=" and ";
1696 break;
1697 case 'all':
1698 $filter_fd_id=' true';
1699 break;
1700 default:
1701 if (noalyss_trim($typecard)!='')
1702 $filter_fd_id=' fd_id in ('.$typecard.')';
1703 else
1704 $filter_fd_id=' fd_id < 0';
1705 }
1706 }
1707 else
1708 {
1709 $filter_fd_id=noalyss_str_replace('[sql]', '', $typecard);
1710 }
1711 }
1712
1713 $and=" and ";
1714 if (isset($query))
1715 {
1717
1719 {
1721 $filter_query=$and."(vw_name ilike '%$query%' or quick_code ilike ('%$query%') "
1722 ." or vw_description ilike '%$query%' or tva_num ilike '%$query%' or accounting like upper('$query%'))";
1723 }
1724 else
1725 {
1726 $filter_query='';
1727 }
1728 }
1729 $sql="select * from vw_fiche_attr where ".$filter_fd_id.$filter_query;
1730 return $sql;
1731 }
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 1824 of file fiche.class.php.

1824 {
1825 $href="export.php?".http_build_query(
1826 array(
1827 "gDossier"=>Dossier::id(),
1828 "f_id"=>$this->id,
1829 "ople"=>0,
1830 "type"=>"poste",
1831 "from_periode"=>$p_from,
1832 "to_periode"=>$p_to,
1833 "act"=>"CSV:fichedetail"
1834 )
1835 );
1836 return '<a class="smallbutton" style="display:inline-block" href="'.$href.'">'._("Export CSV").'</a>';
1837
1838 }
$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 1846 of file fiche.class.php.

1846 {
1847 $href="export.php?".http_build_query(
1848 array(
1849 "gDossier"=>Dossier::id(),
1850 "f_id"=>$this->id,
1851 "ople"=>0,
1852 "type"=>"poste",
1853 "from_periode"=>$p_from,
1854 "to_periode"=>$p_to,
1855 "act"=>"PDF:fichedetail"
1856 )
1857 );
1858 return '<a class="smallbutton" style="display:inline-block" href="'.$href.'">'._("Export PDF").'</a>';
1859
1860 }

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->strAttribut(ATTR_DEF_NAME),$o2->strAttribut(ATTR_DEF_NAME));
140 }
strAttribut($p_ad_id, $p_return=1)
const ATTR_DEF_NAME
Definition constant.php:216

References ATTR_DEF_NAME, and strAttribut().

+ 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 251 of file fiche.class.php.

252 {
253 // Scan for SQL inject
254 $this->cn->search_sql_inject($p_sql);
255
256 if ( $p_search != "" )
257 {
258 $result = $this->cn->get_value("select count(*) from
259 vw_fiche_attr
260 where
261 frd_id=$1
262 and vw_name ilike '%'||$2||'%'",
263 [$p_frd_id,$p_search]);
264 return $result;
265 } else {
266 $result = $this->cn->get_value("select count(*)
267 from
268 fiche join fiche_Def using (fd_id)
269 where frd_id=$1 ".$p_sql
270 ,[$p_frd_id]);
271 return $result;
272 }
273
274
275 }

References $result, and cn.

Referenced by Summary().

◆ delete()

Fiche::delete ( )

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

1618 {
1619 $this->cn->start();
1620
1621 // Remove from attr_value
1622 $Res=$this->cn->exec_sql("delete from fiche_detail
1623 where
1624 f_id= $1",[ $this->id] );
1625
1626 // Remove from fiche
1627 $Res=$this->cn->exec_sql("delete from fiche where f_id=$1",[$this->id]);
1628
1629 $this->cn->commit();
1630
1631
1632 }

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 397 of file fiche.class.php.

398 {
399 $this->GetAttribut();
401 $ret="";
402 $ret.='<span style="margin-right:5px;float:right;font-size:80%">'.
403 _('id').':'.$this->id."</span>";
404 $ret.="<table style=\"width:98%;margin:1%\">";
405 if (empty($attr))
406 {
407 return 'FNT';
408 }
409
410 $fiche_def=new Fiche_Def($this->cn,$this->fiche_def);
411 /* for each attribute */
412 foreach ($attr as $r)
413 {
414 $msg="";
415 $bulle="";
416 $r->setDisplayMode($this->display_mode);
417 if ($p_readonly)
418 {
419 $ret .= $r->print();
420 }
421 if ($p_readonly==false)
422 {
423 $ret .= $r->input($fiche_def);
424
425 }
426 }
427 // Display if the card is enable or not
428 $enable_is=new InputSwitch("f_enable");
429 $enable_is->value=$this->f_enable;
430 $enable_is->readOnly=$p_readonly;
431
432 $ret.=tr(
433 td(_("Actif"),'class="input_text"').td($enable_is->input(),'class="input_text"')
434 );
435
436
437 $ret.="</table>";
438
439 return $ret;
440 }
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

References $attr, $attribut, $f_enable, $fiche_def, $msg, $p_readonly, $r, $ret, _, cn, 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 1894 of file fiche.class.php.

1895 {
1896 $this->getAttribut();
1897 foreach($this->attribut as $attr) {
1898 $sort="";
1899
1900 if ($attr->ad_type!='select')
1901 {
1902
1903 if ($attr->ad_type=="date") {
1904 // format YYYYMMDD
1905 $sort='sorttable_customkey="'.format_date($attr->av_text, "DD.MM.YYYY", "YYYYMMDD").'"';
1906 }
1907 elseif ($attr->ad_type=="poste"){
1908 $sort='sorttable_customkey="TEXT'.$attr->av_text.'"';
1909 }
1910 echo td($attr->av_text, 'style="padding: 0 10 1 10;white-space:nowrap;" '.$sort);
1911 }
1912 else {
1913 $value=$this->cn->make_array($attr->ad_extra);
1914 $row_content="";
1915 for ($e=0; $e<count($value); $e++) {
1916 if ( $value[$e]['value']==$attr->av_text) {
1917 $row_content=h($value[$e]['label']);
1918 break;
1919 }
1920 }
1921 echo td($row_content, 'style="padding: 0 10 1 10;white-space:nowrap;"');
1922
1923 }
1924 }
1925
1926 }
h( $row[ 'oa_description'])
getAttribut()
get all the attribute of a card, add missing ones and sort the array ($this->attribut) by ad_id
for($i=0;$i< count($aHeading);$i++) $sort

References $attr, $e, $sort, $value, cn, elseif, getAttribut(), h, 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 1286 of file fiche.class.php.

1287 {
1288 $sql="select ad_value
1289 from fiche_detail
1290 natural join fiche
1291 left join attr_def using (ad_id) where f_id=$1 ".
1292 " and ad_id = $2 ".
1293 " order by ad_id";
1294 $res=$this->cn->exec_sql($sql,[$this->id,$p_attr]);
1295 if ( Database::num_row($res) == 0 ) return true;
1297 return (strlen(noalyss_trim($text)) > 0)?false:true;
1298
1299
1300 }
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 1867 of file fiche.class.php.

1867 {
1868 return _('Cherche').' '.HtmlInput::filter_table($p_table_id, '0,1,2,3,4,5,6,7,8,9,10', 1);
1869 }
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 ( $p_qcode)
static

create a card from a qcode and returns a card

Parameters
string$p_qcodeqcode of the card

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

1932 {
1934 $card=new Card($cn);
1935 $card->get_by_qcode($p_qcode);
1936 return $card;
1937 }
static connect()

References $card, and $cn.

◆ Get()

Fiche::Get ( )

Synonum of fiche::getAttribut.

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

640 {
641 $this->getAttribut();
642 }

References getAttribut().

+ Here is the call graph for this function:

◆ get_all_account()

Fiche::get_all_account ( )

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

1814 {
1815
1816 }

◆ 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 1753 of file fiche.class.php.

1754 {
1755 if ($p_amount == 0)
1756 return "";
1757 if ($p_amount < 0)
1758 return "C";
1759 if ($p_amount > 0)
1760 return "D";
1761 }

◆ 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 1873 of file fiche.class.php.

1874 {
1875 try {
1876 $id=$this->cn->get_value("select jrn_def_id from jrn_def where jrn_def_bank = $1 ",[$this->id]);
1877 if ($id == "") { return NULL;}
1878 $ledger=new Acc_Ledger_Fin($this->cn,$id);
1879 $ledger->load();
1880 return $ledger;
1881 }
1882 catch (Exception $e) {
1883 record_log(__FILE__.":".__LINE__);
1884 record_log($e->getMessage());
1885 throw $e;
1886 }
1887 }
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->getAttribut();
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 1255 of file fiche.class.php.

1256 {
1257 if ( $this->id == 0 ) throw new Exception('fiche->id est nul');
1259
1260 if ( $p_cond != "") $p_cond=" and ".$p_cond;
1261 $sql="select sum(deb) as sum_deb, sum(cred) as sum_cred from
1262 ( select j_poste,
1263 case when j_debit='t' then j_montant else 0 end as deb,
1264 case when j_debit='f' then j_montant else 0 end as cred
1265 from jrnx
1266 join jrn on (jr_grpt_id=j_grpt)
1267 where
1268 j_qcode = ('$qcode'::text)
1269 $p_cond
1270 ) as m ";
1271
1272 $Res=$this->cn->exec_sql($sql);
1274 if ($Max==0) return 0;
1276
1277 return array('debit'=>$r['sum_deb'],
1278 'credit'=>$r['sum_cred'],
1279 'solde'=>abs($r['sum_deb']-$r['sum_cred']));
1280
1281 }
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:237

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

+ 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 1233 of file fiche.class.php.

1234 {
1235 if ( $this->id == 0 ) throw new Exception('fiche->id est nul');
1236
1237 if ( $p_cond != "") $p_cond=" and ".$p_cond;
1238
1239 $sql = "
1240 select sum(sum_oc_amount)
1241 from
1242 v_all_card_currency
1243 where
1244 f_id=$1
1245 $p_cond";
1246 $val=$this->cn->get_value($sql,[$this->id]);
1247
1248 return $val;
1249
1250 }

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 655 of file fiche.class.php.

656 {
657 switch($p_order)
658 {
659 case 'name' :
660 $order=' order by name';
661 break;
662 case 'f_id':
663 $order='order by f_id';
664 break;
665 default:
666 $order='';
667 }
668 if ( $p_offset == -1 )
669 {
670 $sql="select *
671 from
672 fiche join fiche_Def using (fd_id) join vw_fiche_name using(f_id)
673 where frd_id=".$this->fiche_def_ref." $p_search ".$order;
674 }
675 else
676 {
677 $limit=($_SESSION[SESSION_KEY.'g_pagesize']!=-1)?"limit ".$_SESSION[SESSION_KEY.'g_pagesize']:"";
678 $sql="select *
679 from
680 fiche join fiche_Def using (fd_id) join vw_fiche_name using(f_id)
681 where frd_id=".$this->fiche_def_ref." $p_search $order "
682 .$limit." offset ".$p_offset;
683
684 }
685
686 $Ret=$this->cn->exec_sql($sql);
687 if ( ($Max=Database::num_row($Ret)) == 0 )
688 return [];
689 $all[0]=new Fiche($this->cn);
690
691 for ($i=0;$i<$Max;$i++)
692 {
694 $t=new Fiche($this->cn,$row['f_id']);
695 $t->getAttribut();
696 $all[$i]=clone $t;
697
698 }
699 return $all;
700 }

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->getAttribut();
196 return 0;
197 }

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

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 1458 of file fiche.class.php.

1459 {
1460 if ( $this->id == 0 ) throw new Exception('class_fiche : f_id = 0 ');
1461 $sql='select fd_id from fiche where f_id=$1';
1462 $R=$this->cn->get_value($sql, array($this->id));
1463 if ( $R == "" )
1464 $this->fd_id=0;
1465 else
1466 $this->fd_id=$R;
1467 return $this->fd_id;
1468 }
$fd_id

References $fd_id, $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,
$pFd_id,
$p_order = '' )
static

get all the card from a categorie

Parameters
$p_cndatabase connx
$pFd_idis the category id
$p_orderfor the sort, possible values is name_asc,name_desc or nothing
Returns
an array of card, but only the fiche->id is set

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

1570 {
1571 switch ($p_order)
1572 {
1573 case 'name_asc':
1574 $sql='select f_id,ad_value from fiche join fiche_detail using (f_id) where ad_id=1 and fd_id=$1 order by 2 asc';
1575 break;
1576 case 'name_desc':
1577 $sql='select f_id,ad_value from fiche join fiche_detail using (f_id) where ad_id=1 and fd_id=$1 order by 2 desc';
1578 break;
1579 default:
1580 $sql='select f_id from fiche where fd_id=$1 ';
1581 }
1582 $array=$p_cn->get_array($sql,array($pFd_id));
1583
1584 return $array;
1585 }

References $array, $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 705 of file fiche.class.php.

706 {
707 $result=$this->cn->get_array("select frd_id from fiche join fiche_Def using (fd_id) where f_id=$1",[$this->id]);
708 if ( $result == null )
709 return null;
710
711 return $result[0]['frd_id'];
712 }

References $result, and cn.

◆ get_gestion_title()

Fiche::get_gestion_title ( )

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

1809 {
1810 $r = "<h2 id=\"gestion_title\">" . h($this->getName()) . " " . h($this->strAttribut(ATTR_DEF_FIRST_NAME,0)) . '[' . $this->get_quick_code() . ']</h2>';
1811 return $r;
1812 }
getName()
return the name of a card
const ATTR_DEF_FIRST_NAME
Definition constant.php:238

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

+ 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 627 of file fiche.class.php.

628 {
629 $sql="select ad_value from fiche_detail where ad_id=23 and f_id=$1";
630 $Res=$this->cn->exec_sql($sql,array($this->id));
632 if ( $r == FALSE || sizeof($r) == 0 )
633 return null;
634 return $r[0]['ad_value'];
635 }

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 847 of file fiche.class.php.

848 {
849 if ( $this->id == 0 )
850 {
851 echo_error("class_fiche",__LINE__,"id is 0");
852 return;
853 }
855 $periode=sql_filter_per($this->cn,$p_from,$p_to,'p_id','jr_tech_per');
856
857 $this->row=$this->cn->get_array("select j_date,
858 to_char(j_date,'DD.MM.YYYY') as j_date_fmt,
859 j_qcode,
860 case when j_debit='t' then j_montant else 0 end as deb_montant,
861 case when j_debit='f' then j_montant else 0 end as cred_montant,
862 jr_comment as description,
863 jrn_def_name as jrn_name,
864 j_debit,
865 jr_internal,
866 jr_id
867 from jrnx
868 left join jrn_def on jrn_def_id=j_jrn_def
869 left join jrn on jr_grpt_id=j_grpt
870 where
871 j_qcode=$1 and {$periode}
872 order by j_date::date",array(
873 $qcode
874 ));
875 $res_saldo = $this->cn->exec_sql("select sum(deb_montant),sum(cred_montant) from
876 (select case when j_debit='t' then j_montant else 0 end as deb_montant,
877 case when j_debit='f' then j_montant else 0 end as cred_montant
878 from jrnx
879 left join jrn_def on jrn_def_id=j_jrn_def
880 left join jrn on jr_grpt_id=j_grpt
881 where
882 j_qcode=$1 and {$periode} ) as m",
883 array($this->id));
884 $this->tot_deb=$this->tot_cred=0;
885
886 if ( Database::num_row($res_saldo) > 0 ) {
887 $this->tot_deb=Database::fetch_result($res_saldo, 0, 0);
888 $this->tot_cred=Database::fetch_result($res_saldo, 0, 1);
889 }
890 return array($this->row,$this->tot_deb,$this->tot_cred);
891
892 }
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(), DatabaseCore\num_row(), sql_filter_per(), and strAttribut().

+ 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 753 of file fiche.class.php.

754 {
755 global $g_user;
756 if ( $this->id == 0 )
757 {
758 echo_error("class_fiche",__LINE__,"id is 0");
759 return;
760 }
761 $filter_sql=$g_user->get_ledger_sql('ALL',3);
762 $sql_let='';
763 switch ($op_let)
764 {
765 case 0:
766 break;
767 case 1:
768 $sql_let=' and j1.j_id in (select j_id from letter_cred union select j_id from letter_deb)';
769 break;
770 case '2':
771 $sql_let=' and j1.j_id not in (select j_id from letter_cred union select j_id from letter_deb) ';
772 break;
773 }
774
776 $this->row=$this->cn->get_array("
777 with sqlletter as
778 (select j_id,jl_id from letter_cred union all select j_id , jl_id from letter_deb )
779 select distinct substring(jr_pj_number,'[0-9]+$'),j1.j_id,j_date,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,j_qcode,".
780 "case when j_debit='t' then j_montant else 0 end as deb_montant,".
781 "case when j_debit='f' then j_montant else 0 end as cred_montant,".
782 " jr_comment as description,jrn_def_name as jrn_name,j_poste,".
783 " jr_pj_number,".
784 "j_debit, jr_internal,jr_id,(select distinct jl_id from sqlletter where sqlletter.j_id=j1.j_id ) as letter , ".
785 "jr_optype , ".
786 " jr_tech_per,p_exercice,jrn_def_name,
787 (with cred as (select jl_id, sum(j_montant) as amount_cred from letter_cred lc1 left join jrnx as j3 on (j3.j_id=lc1.j_id) group by jl_id ),
788 deb as (select jl_id, sum(j_montant) as amount_deb from letter_deb ld1 left join jrnx as j2 on (j2.j_id = ld1.j_id) group by jl_id )
789 select amount_deb-amount_cred
790 from
791 cred
792 full join deb using (jl_id) where jl_id=(select distinct jl_id from sqlletter where sqlletter.j_id=j1.j_id )) as delta_letter,
793 jrn_def_code,
794 jrn.currency_rate,
795 jrn.currency_rate_ref,
796 jrn.currency_id,
797 (select cr_code_iso from currency where id=jrn.currency_id) as cr_code_iso,
798 j_montant,
799 sum_oc_amount as oc_amount,
800 sum_oc_vat_amount as oc_vat_amount ,
801 case when exists(select 1 from operation_analytique oa where j1.j_id=oa.j_id) then 1 else 0 end as op_analytic
802 from jrnx as j1 left join jrn_def on jrn_def_id=j_jrn_def
803 left join (select j_id,
804 coalesce(oc_amount,0) as sum_oc_amount ,
805 coalesce(oc_vat_amount,0) as sum_oc_vat_amount
806 from jrnx left join operation_currency using (j_id)
807 ) as v1 on (v1.j_id=j1.j_id )
808 left join jrn on jr_grpt_id=j_grpt".
809 " left join parm_periode on (p_id=jr_tech_per) ".
810 " where j_qcode=$1 and ".
811 " ( to_date($2,'DD.MM.YYYY') <= j_date and ".
812 " to_date($3,'DD.MM.YYYY') >= j_date )".
813 " and $filter_sql $sql_let ".
814 " order by j_date,substring(jr_pj_number,'[0-9]+$')",array($qcode,$p_from,$p_to));
815
816 $res_saldo = $this->cn->exec_sql("select sum(deb_montant),sum(cred_montant) from
817 (select case when j_debit='t' then j_montant else 0 end as deb_montant,
818 case when j_debit='f' then j_montant else 0 end as cred_montant
819 from jrnx j1
820 join jrn_def on (jrn_def_id=j_jrn_def )
821 join jrn on (jr_grpt_id=j_grpt)
822 join tmp_pcmn on (j_poste=pcm_val)
823 join parm_periode on (p_id=jr_tech_per)
824 where j_qcode=$1 and
825 ( to_date($2,'DD.MM.YYYY') <= j_date and
826 to_date($3,'DD.MM.YYYY') >= j_date )
827 and $filter_sql $sql_let ) as m",array($this->id,$p_from,$p_to));
828 $this->tot_deb=$this->tot_cred=0;
829
830 if ( Database::num_row($res_saldo) > 0 ) {
831 $this->tot_deb=Database::fetch_result($res_saldo, 0, 0);
832 $this->tot_cred=Database::fetch_result($res_saldo, 0, 1);
833 }
834
836 }

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

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 718 of file fiche.class.php.

719 {
720 $array=array();
721 $tot_cred=0.0;
722 $tot_deb=0.0;
724 if ( $Max == 0 ) return null;
725 bcscale(2);
726 for ($i=0;$i<$Max;$i++)
727 {
729 if ($array[$i]['j_debit']=='t')
730 {
731 $tot_deb=bcadd($tot_deb, $array[$i]['deb_montant'] );
732 }
733 else
734 {
735 $tot_cred=bcadd($tot_cred,$array[$i]['cred_montant'] );
736 }
737 }
738 $this->row=$array;
739 $this->tot_deb=$tot_deb;
740 $this->tot_cred=$tot_cred;
741 return array($array,$tot_deb,$tot_cred);
742 }

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 1203 of file fiche.class.php.

1204 {
1205 if ( $this->id == 0 ) return array('credit'=>0,'debit'=>0,'solde'=>0);
1207
1208 if ( $p_cond != "") $p_cond=" and ".$p_cond;
1209 $Res=$this->cn->exec_sql("select coalesce(sum(deb),0) as sum_deb,
1210 coalesce(sum(cred),0) as sum_cred from
1211 ( select j_poste,
1212 case when j_debit='t' then j_montant else 0 end as deb,
1213 case when j_debit='f' then j_montant else 0 end as cred
1214 from jrnx
1215 where
1216 j_qcode = ('$qcode'::text)
1217 $p_cond
1218 ) as m ");
1220 if ($Max==0) return 0;
1222
1223 return array('debit'=>$r['sum_deb'],
1224 'credit'=>$r['sum_cred'],
1225 'solde'=>abs($r['sum_deb']-$r['sum_cred']));
1226 }

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

+ Here is the call graph for this function:

◆ getAttribut()

Fiche::getAttribut ( )

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

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

224 {
225 Card_Property::load($this);
226 }
static load(Fiche $fiche)
Load all the attribute of a card , it modifies the parameter $fiche.

References Card_Property\load().

Referenced by display_row(), Get(), get_by_qcode(), insert(), load(), setAttribut(), strAttribut(), to_array(), and update().

+ 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 288 of file fiche.class.php.

289 {
290 return $this->get_by_category($p_offset,$p_search,$p_order);
291 }
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 380 of file fiche.class.php.

381 {
382 $type_card=$this->cn->get_value('select fd_label '
383 . ' from fiche_def join fiche using (fd_id) where f_id=$1',
384 array($this->id));
385 return $type_card;
386 }

References cn.

◆ getName()

Fiche::getName ( )

return the name of a card

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

614 {
615 $sql="select ad_value from fiche_detail
616 where ad_id=1 and f_id=$1";
617 $Res=$this->cn->exec_sql($sql,array($this->id));
619 if ( empty($r) )
620 throw new Exception (_("Fiche n'existe pas"), 1000);
621 return $r[0]['ad_value'];
622 }

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 966 of file fiche.class.php.

967 {
968 if ( $p_array == null)
970 global $g_parameter;
971 $progress=0;
972 // if from_periode is greater than to periode then swap the values
973 if (cmpDate($p_array['from_periode'],$p_array['to_periode']) > 0)
974 {
975 $tmp=$p_array['from_periode'];
976 $p_array['from_periode']=$p_array['to_periode'];
977 $p_array['to_periode']=$tmp;
978
979 }
980 list($array, $tot_deb, $tot_cred) = $this->get_row_date($p_array['from_periode'], $p_array['to_periode'], $op_let);
981
982 if ( count($this->row ) == 0 )
983 return -1;
984
985 $rep="";
986 if ( $from_div==1)
987 {
988 echo "<TABLE id=\"tbpopup\" class=\"resultfooter\" style=\"margin:1%;width:98%;;border-collapse:collapse;border-spacing:0px 5px\">";
989 }
990 else
991 {
992 echo "<TABLE id=\"tb" . $from_div . "\"class=\"result\" style=\"margin:1%;width:98%;border-collapse:collapse;border-spacing:0px 2px\">";
993 }
994 echo '<tbody>';
995 echo "<TR>".
996 "<TH style=\"text-align:left\">"._('Date')."</TH>".
997 "<TH style=\"text-align:left\">"._('Pièce')." </TH>".
998 "<TH style=\"text-align:left\">"._('Poste')." </TH>".
999 "<TH style=\"text-align:left\">"._('Interne')." </TH>".
1000 "<TH style=\"text-align:left\">"._('Tiers')." </TH>".
1001 "<TH style=\"text-align:left\">"._('Description')." </TH>".
1002 "<TH style=\"text-align:left\">"._('Type')."</TH>".
1003 "<TH style=\"text-align:left\">"._('ISO')."</TH>".
1004 "<TH style=\"text-align:right\">"._('Dev.')."</TH>".
1005 "<TH style=\"text-align:right\">"._('Débit')." </TH>".
1006 "<TH style=\"text-align:right\">"._('Crédit')." </TH>".
1007 th('Prog.','style="text-align:right"').
1008 th('Let.','style="text-align:right"');
1009 "</TR>"
1010 ;
1011 $old_exercice="";$sum_deb=0;$sum_cred=0;
1012 bcscale(2);
1013 $idx=0;
1014 $operation=new Acc_Operation($this->cn);
1015 foreach ( $this->row as $op )
1016 {
1017 $vw_operation = sprintf('<A class="detail" style="text-decoration:underline;color:red" HREF="javascript:modifyOperation(\'%s\',\'%s\')" >%s</A>', $op['jr_id'], dossier::id(), $op['jr_internal']);
1018 $let = '';
1019 $html_let = "";
1020 if ($op['letter'] != "")
1021 {
1022 $let = strtoupper(base_convert($op['letter'], 10, 36));
1024 if ( $op['delta_letter'] != 0) $html_let='<img src="image/warning.png" onmouseover="displayBulle(\'delta = '.$op['delta_letter'].'\')" onmouseleave="hideBulle()" style="height:12px"/>'.$html_let;
1025 }
1026 $tmp_diff=bcsub($op['deb_montant'],$op['cred_montant']);
1027
1028 /*
1029 * reset prog. balance to zero if we change of exercice
1030 */
1031 if ( $old_exercice != $op['p_exercice'])
1032 {
1033 if ($old_exercice != '' )
1034 {
1035 $progress=bcsub($sum_deb,$sum_cred);
1036 $side="&nbsp;".$this->get_amount_side($progress);
1037 echo "<TR class=\"highlight\">".
1038 "<TD>$old_exercice</TD>".
1039 td('').
1040 td('').
1041 "<TD></TD>".td().
1042 "<TD>Totaux</TD>".
1043 td().
1044 td().
1045 td().
1046 "<TD style=\"text-align:right\">".nbm($sum_deb)."</TD>".
1047 "<TD style=\"text-align:right\">".nbm($sum_cred)."</TD>".
1048 td(nbm(abs($progress)).$side,'style="text-align:right"').
1049 td('').
1050 "</TR>";
1051 $sum_cred=0;
1052 $sum_deb=0;
1053 $progress=0;
1054 }
1055 }
1056 $progress=bcadd($progress,$tmp_diff);
1057 $side="&nbsp;".$this->get_amount_side($progress);
1058 $sum_cred=bcadd($sum_cred,$op['cred_montant']);
1059 $sum_deb=bcadd($sum_deb,$op['deb_montant']);
1060 if ($idx%2 == 0) $class='class="odd"'; else $class=' class="even"';
1061 $idx++;
1062
1063 $tiers=$operation->find_tiers($op['jr_id'], $op['j_id'], $op['j_qcode']);
1064 $op_analytic=($op['op_analytic']==1)?'<span style="float:right;background:black;color:white;">&ni;</span>':'';
1065 echo "<TR $class name=\"tr_" . $let . "_" . $from_div . "\">" .
1066 "<TD>".smaller_date(format_date($op['j_date_fmt']))."</TD>".
1067 td(h($op['jr_pj_number'])).
1068 td($op['j_poste']).
1069 "<TD>".$vw_operation."</TD>".
1070 td($tiers).
1071 "<TD>".h($op['description']).$op_analytic."</TD>".
1072 td($op['jr_optype']);
1073
1074 /// If the currency is not the default one , then show the amount
1075 if ( $op['currency_id'] > 0 && $op['oc_amount'] != 0)
1076 {
1077 echo td($op['cr_code_iso']).
1078 td(nbm($op['oc_amount'],4),'style="text-align:right;padding-left:10px;"');
1079 } else {
1080 echo td().td();
1081 }
1082
1083 echo "<TD style=\"text-align:right\">".nbm($op['deb_montant'])."</TD>".
1084 "<TD style=\"text-align:right\">".nbm($op['cred_montant'])."</TD>".
1085 td(nbm(abs($progress)).$side,'style="text-align:right"').
1086 td($html_let, ' style="text-align:right"') .
1087 "</TR>";
1088 $old_exercice=$op['p_exercice'];
1089
1090 }
1091 $solde_type=_("Année ").($sum_deb>$sum_cred)?_("solde débiteur"):_("solde créditeur");
1092 $solde_side=($sum_deb>$sum_cred)?"D":"C";
1093 $diff=abs(bcsub($sum_deb,$sum_cred));
1094 echo '<tfoot>';
1095 echo "<TR class=\"highlight\">".
1096 td($op['p_exercice']).
1097 td().
1098 td().
1099 td().
1100 td().
1101 td(_('Totaux')).
1102 td().
1103 td().
1104 "<TD></TD>".
1105 "<TD style=\"text-align:right\">".nbm($sum_deb)."</TD>".
1106 "<TD style=\"text-align:right\">".nbm($sum_cred)."</TD>".
1107 "<TD style=\"text-align:right\">".nbm($diff)."</TD>".
1108 td($solde_side).
1109 "</TR>";
1110 echo "<TR style=\"font-weight:bold\">".
1111 "<TD>$solde_type</TD>".
1112 "<TD style=\"text-align:right\">".nbm($diff)."</TD>".
1113 "<TD></TD>".
1114 "</TR>";
1115 // take saldo from 1st day until last
1116 if ($g_parameter->MY_REPORT=='N') {
1117 $solde_until_now=$this->get_solde_detail(" j_date <= to_date('{$p_array['to_periode']}','DD.MM.YYYY') ");
1118 echo '<tr style="font-weight:bold;color:orangered">';
1119 echo td(_("Solde global"));
1120 echo td("D : ".nbm($solde_until_now['debit']),'class="num"');
1121 echo td("C : ".nbm($solde_until_now['credit']),'class="num"');
1122 echo td("Delta : ".nbm($solde_until_now['solde'])." ".$this->get_amount_side($solde_until_now['debit']-$solde_until_now['credit']),'class="num"');
1123 echo '</tr>';
1124
1125 }
1126 echo '</tfoot>';
1127 echo '</tbody>';
1128
1129 echo "</table>";
1130
1131 return 0;
1132 }
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']
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="")
foreach( $Fiche->row as $op) $solde_type
$side

References $_REQUEST, $array, $class, $from_div, $g_parameter, $idx, $let, $op, $operation, $p_array, $progress, $rep, $side, $tiers, $tmp, $tot_cred, $tot_deb, cmpDate(), cn, format_date(), 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 898 of file fiche.class.php.

899 {
900 if ( $p_array == null)
902
903 $name=$this->getName();
904
905 list($array,$tot_deb,$tot_cred)=$this->get_row_date( $p_array['from_periode'],
906 $p_array['to_periode'],
907 $op_let
908 );
909
910 if ( count($this->row ) == 0 )
911 return;
913
914 $rep="";
915 $already_seen=array();
916 echo '<h2 class="info">'.$this->id." ".$name.'</h2>';
917 echo "<TABLE class=\"result\" style=\"width:100%;border-collapse:separate;border-spacing:5px\">";
918 echo "<TR>".
919 "<TH>"._("n° de pièce / Code interne")." </TH>".
920 "<TH>"._("Date")."</TH>".
921 "<TH>"._("Description")." </TH>".
922 "<TH>"._('Montant')." </TH>".
923 "<TH> "._('Débit/Crédit')." </TH>".
924 "</TR>";
925
926 foreach ( $this->row as $op )
927 {
928 if ( in_array($op['jr_internal'],$already_seen) )
929 continue;
930 else
931 $already_seen[]=$op['jr_internal'];
932 echo "<TR style=\"text-align:center;background-color:lightgrey\">".
933 "<td>".$op['jr_pj_number']." / ".$op['jr_internal']."</td>".
934 "<td>".$op['j_date']."</td>".
935 "<td>".h($op['description'])."</td>".
936 "<td>"."</td>".
937 "<td>"."</td>".
938 "</TR>";
939 $ac=new Acc_Operation($this->cn);
940 $ac->jr_id=$op['jr_id'];
941 $ac->qcode=$qcode;
942 echo $ac->display_jrnx_detail(1);
943
944 }
945 $solde_type=($tot_deb>$tot_cred)?_("solde débiteur"):_("solde créditeur");
946 $diff=round(abs($tot_deb-$tot_cred),2);
947 echo "<TR>".
948 "<TD>$solde_type".
949 "<TD>$diff</TD>".
950 "<TD></TD>".
951 "<TD>$tot_deb</TD>".
952 "<TD>$tot_cred</TD>".
953 "</TR>";
954
955 echo "</table>";
956
957 return;
958 }
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_row_date(), getName(), and strAttribut().

+ Here is the call graph for this function:

◆ HtmlTableHeader()

Fiche::HtmlTableHeader ( $p_array = null)

Display HTML Table Header (button)

Returns
none

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

1139 {
1140 if ( $p_array == null)
1142
1143 $hid=new IHidden();
1144 echo '<div class="noprint">';
1145 echo "<table >";
1146 echo '<TR>';
1147
1148 echo '<TD><form method="GET" ACTION="">'.
1149 HtmlInput::submit('bt_other',_("Autre poste")).
1150 HtmlInput::array_to_hidden(array('gDossier','ac'), $_REQUEST).
1151 dossier::hidden().
1152 $hid->input("type","poste").$hid->input('p_action','impress')."</form></TD>";
1153 $str_ople=(isset($_REQUEST['ople']))?HtmlInput::hidden('ople',$_REQUEST['ople']):'';
1154
1155 echo '<TD><form method="GET" ACTION="export.php" ';
1156 $id=uniqid("export_");
1157 printf( 'id="%s" onsubmit="download_document_form(\'%s\')">',$id,$id);
1158 echo
1159 HtmlInput::submit('bt_pdf',_("Export PDF")).
1160 dossier::hidden().$str_ople.
1161 HtmlInput::hidden('act','PDF:fichedetail').
1162 $hid->input("type","poste").
1163 $hid->input('p_action','impress').
1164 $hid->input("f_id",$this->id).
1165 dossier::hidden().
1166 $hid->input("from_periode",$p_array['from_periode']).
1167 $hid->input("to_periode",$p_array['to_periode']);
1168 if (isset($p_array['oper_detail']))
1169 echo $hid->input('oper_detail','on');
1170
1171 echo "</form></TD>";
1172
1173 echo '<TD><form method="GET" ACTION="export.php" ';
1174 $id=uniqid("export_");
1175 printf( 'id="%s" onsubmit="download_document_form(\'%s\')">',$id,$id);
1176
1177 echo HtmlInput::submit('bt_csv',_("Export CSV")).
1178 HtmlInput::hidden('act','CSV:fichedetail').
1179 dossier::hidden().$str_ople.
1180 $hid->input("type","poste").
1181 $hid->input('p_action','impress').
1182 $hid->input("f_id",$this->id).
1183 $hid->input("from_periode",$p_array['from_periode']).
1184 $hid->input("to_periode",$p_array['to_periode']);
1185 if (isset($p_array['oper_detail']))
1186 echo $hid->input('oper_detail','on');
1187
1188 echo "</form></TD>";
1189 echo "</form></TD>";
1190 echo '<td style="vertical-align:top">';
1192 echo '</td>';
1193 echo "</table>";
1194 echo '</div>';
1195
1196 }
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_arrayis the array containing the data key = av_textX where X is AD_ID
$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 470 of file fiche.class.php.

471 {
472 if ($p_array==null)
474
475 $fiche_id=$this->cn->get_next_seq('s_fiche');
476 $this->id=$fiche_id;
477 $this->fiche_def=$p_fiche_def;
478 try
479 {
480
481 // by default the card is available
482 if (!isset($p_array['f_enable']))
483 {
484 $p_array['f_enable']=1;
485 }
486 $Ret=$this->cn->exec_sql("insert into fiche(f_id,f_enable,fd_id) values ($1,$2,$3)",
487 array($fiche_id, $p_array['f_enable'], $p_fiche_def));
488 // first we need to save the name , to compute properly the quickcode
489 if ( empty ($p_array['av_text'.ATTR_DEF_NAME])) {
490
491 $p_array['av_text'.ATTR_DEF_NAME]=_("Nom vide");
492 }
493 // the name must be saved first
494 $this->cn->exec_sql("insert into fiche_detail (f_id,ad_id,ad_value) values ($1,$2,$3)",
495 array($fiche_id,1,$p_array['av_text'.ATTR_DEF_NAME]));
496
497 // compute a quick_code
498 if (!isset($p_array["av_text".ATTR_DEF_QUICKCODE]))
499 {
500 $p_array["av_text".ATTR_DEF_QUICKCODE]="";
501 }
502 $sql=sprintf("select insert_quick_code(%d,'%s')", $fiche_id,
504 $this->cn->exec_sql($sql);
505 // get the card properties for this card category
506 $fiche_def=new Fiche_Def($this->cn, $p_fiche_def);
507
508 $this->attribut=$fiche_def->getAttribut();
509
510 if (empty($this->attribut))
511 {
512 throw new Exception("FICHE.UPDATE02"._("Aucun attribut ")."($p_fiche_def)", EXC_INVALID);
513 }
514 // for each property set the attribut on the card
515 foreach ($this->attribut as $property)
516 {
517 $key='av_text'.$property->ad_id;
518 if (isset($p_array[$key]))
519 {
520 $this->setAttribut($property->ad_id, $p_array[$key]);
521 }
522 }
523 // For accounting
524
526 // reread from database
527 $this->getAttribut();
528 }
529 catch (Exception $e)
530 {
531 record_log("FIC603".$e->getMessage()." ".$e->getTraceAsString());
532 $this->cn->rollback();
533 throw ($e);
534 return;
535 }
536 return;
537 }
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...
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 EXC_INVALID
Definition constant.php:346
$_POST['ac']
Definition do.php:312

References $_POST, $e, $fiche_def, $fiche_id, $p_array, $sql, _, ATTR_DEF_NAME, ATTR_DEF_QUICKCODE, cn, EXC_INVALID, getAttribut(), record_log(), setAttribut(), 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 1589 of file fiche.class.php.

1590 {
1591 /* retrieve first the quickcode */
1593 $sql='select count(*) as c from jrnx where j_qcode=$1';
1594 $count=$this->cn->get_value($sql,array($qcode));
1595 if ( $count > 0 ) return TRUE;
1596 $count=$this->cn->get_value("select count(*) from action_gestion where f_id_dest=$1 or ag_contact=$1 ",
1597 [$this->id]);
1598 if ( $count > 0 ) return TRUE;
1599 $count=$this->cn->get_value("select count(*) from action_person where f_id=$1 ",
1600 [$this->id]);
1601 if ( $count > 0 ) return TRUE;
1602
1603 $count=$this->cn->get_value("
1604 select count(*)
1605 from attr_def
1606 join fiche_detail using (ad_id)
1607 where ad_type='card'
1608 and ad_value=$1"
1609 ,[$qcode]);
1610
1611 if ( $count > 0 ) return TRUE;
1612
1613 return FALSE;
1614
1615 }
$count

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

Referenced by remove().

+ Here is the call graph for this function:

◆ load()

Fiche::load ( )

Synonum of fiche::getAttribut.

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

645 :void
646 {
647 $this->getAttribut();
648 }

References getAttribut().

Referenced by __construct().

+ 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 1738 of file fiche.class.php.

1739 {
1740 $this->cn->start();
1741 $this->cn->exec_sql('update fiche set fd_id=$1 where f_id=$2',array($p_fdid,$this->id));
1742 // add missing
1743 $this->cn->exec_sql('select fiche_attribut_synchro($1)',array($p_fdid));
1744 // add to the destination missing fields
1745 $this->cn->exec_sql("insert into jnt_fic_attr (fd_id,ad_id,jnt_order) select $1,ad_id,100 from fiche_detail where f_id=$2 and ad_id not in (select ad_id from jnt_fic_attr where fd_id=$3)",array($p_fdid,$this->id,$p_fdid));
1746 $this->cn->commit();
1747 }

References cn.

◆ remove()

Fiche::remove ( $silent = false)

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

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

593 {
594 if ( $this->id==0 ) return;
595 // verify if that card has not been used is a ledger nor in the followup
596 // if the card has its own account in PCMN
597 // Get the fiche_def.fd_id from fiche.f_id
598 if ( $this->is_used() == FALSE) {
599 $this->delete();
600 return 0;
601 }
602
603 if ( ! $silent ) {
604 alert(_('Impossible cette fiche est utilisée dans un journal'));
605 }
606 return 1;
607 }
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 448 of file fiche.class.php.

449 {
450 // new card or only a update ?
451 if ( $this->id == 0 )
452 $this->insert($p_fiche_def);
453 else
454 $this->update();
455 }
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 233 of file fiche.class.php.

234 {
235 $sql="select jft_id,f_id,fd_id,ad_id,ad_value from fiche join fiche_detail using (f_id)
236 where ad_id=$1 and upper(ad_value)=upper($2)";
237 $res=$this->cn->get_array($sql,array($p_attribut,$p_value));
238 return $res;
239 }

References $res, $sql, and cn.

◆ 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 )

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

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

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

206 {
207 if ( $this->fiche_def == 0) throw new Exception ("FICHE.179 Invalid category",EXC_INVALID);
208 if ( sizeof($this->attribut)==0 ) $this->getAttribut();
209
210 for ($e=0;$e <sizeof($this->attribut);$e++)
211 {
212 if ( $this->attribut[$e]->ad_id == $p_ad_id )
213 {
214 $this->attribut[$e]->av_text=$p_value;
215 break;
216 }
217 }
218 }

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

Referenced by insert(), and update().

+ 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 292 of file fiche.class.php.

293 {
294 echo "<TR><TD> ".
295 $this->id."</TD>".
296 "<TR> <TD>".
297 $this->attribut_value."</TD>".
298 "<TR> <TD>".
299 $this->attribut_def."</TD></TR>";
300 }

◆ strAttribut()

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

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

311 {
312 $return=($p_return==1)?NOTFOUND:"";
313 if ( empty ($this->attribut) )
314 {
315
316 $this->getAttribut();
317 }
318
319 foreach ($this->attribut as $e)
320 {
321 if ( $e->ad_id == $p_ad_id )
322 return noalyss_trim($e->av_text);
323 }
324 return $return;
325 }
const NOTFOUND(!defined("SYSINFO_DISPLAY"))
Definition constant.php:130

References $e, getAttribut(), 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(), HtmlTableDetail(), Acc_Ledger_Purchase\insert_no_deductible(), is_used(), Card_Property\update(), and update().

+ 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 1310 of file fiche.class.php.

1311 {
1312 global $g_user;
1313 global $g_parameter;
1314 $http=new HttpInput();
1315 $bank=new Acc_Parm_Code($this->cn,'BANQUE');
1316 $cash=new Acc_Parm_Code($this->cn,'CAISSE');
1317 $cc=new Acc_Parm_Code($this->cn,'COMPTE_COURANT');
1318
1319 bcscale(4);
1320 $gDossier=dossier::id();
1321 $p_search=sql_string($p_search);
1322 $script=$_SERVER['PHP_SELF'];
1323 // Creation of the nav bar
1324 // Get the max numberRow
1325 $filter_amount='';
1326 global $g_user;
1327
1328 $filter_year=" j_tech_per in (select p_id from parm_periode ".
1329 "where p_exercice='".$g_user->get_exercice()."')";
1330
1331 if ( $p_amount) $filter_amount=' and f_id in (select f_id from jrnx where '.$filter_year.')';
1332
1333 $all_tiers=$this->count_by_modele($this->fiche_def_ref,"",$p_sql.$filter_amount);
1334 // Get offset and page variable
1335 $offset=$http->request("offset","number",0);
1336 $page=$http->request("page","number",1);
1337 $bar=navigation_bar($offset,$all_tiers,$_SESSION[SESSION_KEY.'g_pagesize'],$page);
1338
1339 // set a filter ?
1340 $search=$p_sql;
1341
1342 if ( noalyss_trim($p_search) != "" )
1343 {
1344 $search.=" and f_id in
1345 (select distinct f_id from fiche_detail
1346 where
1347 ad_id in (1,32,30,23,18,13) and ad_value ilike '%$p_search%')";
1348 }
1349 // Get The result Array
1350 $step_tiers=$this->get_by_category($offset,$search.$filter_amount,'name');
1351
1352 if ( $all_tiers == 0 || empty($step_tiers ) ) { return ""; }
1353 $r="";
1354 $r.=$bar;
1355
1356 $r.='<table id="tiers_tb" class="sortable" style="">
1357 <TR >
1358 <TH>'._('Quick Code').Icon_Action::infobulle(17).'</TH>'.
1359 '<th>'._('Poste comptable').'</th>'.
1360 '<th class="sorttable_sorted">'._('Nom').'</span>'.'</th>
1361 <th>'._('Adresse').'</th>
1362 <th>'._('site web').'</th>
1363 <th style="text-align:right">'._('Total débit').'</th>
1364 <th style="text-align:right">'._('Total crédit').'</th>
1365 <th style="text-align:right">'._('Solde').'</th>';
1366 $r.='</TR>';
1367 if ( sizeof ($step_tiers ) == 0 )
1368 return $r;
1369
1370 $i=0;
1371 $deb=0;$cred=0;
1372 foreach ($step_tiers as $tiers )
1373 {
1374 $i++;
1375
1376 /* Filter on the default year */
1377 if ( $g_parameter->MY_REPORT == 'N') {
1378 list($l_from,$l_to)=(new Periode($this->cn))->get_limit($g_user->get_exercice());
1379 $condition = sprintf (" j_date <= to_date('%s','DD.MM.YYYY') ", $l_to->last_day());
1380 $amount = $tiers->get_solde_detail($condition);
1381 } else {
1382 $amount=$tiers->get_solde_detail($filter_year);
1383 }
1384
1385 /* skip the tiers without operation */
1386 if ( $p_amount && $amount['debit']==0 && $amount['credit'] == 0 && $amount['solde'] == 0 ) continue;
1387
1388 $odd="";
1389 $odd = ($i % 2 == 0 ) ? ' odd ': ' even ';
1390 $accounting=$tiers->strAttribut(ATTR_DEF_ACCOUNT,0);
1391 if ( ! empty($accounting) && $p_action == 'bank'
1392 && $amount['debit'] < $amount['credit']
1393 &&
1394 ( /** the accounting is a financial account *****/
1395 (!empty ($bank->value) && strpos($accounting,$bank->p_value)===0 )
1396 || (!empty ($cash->value) && strpos($accounting,$cash->p_value)===0 )
1397 || ( !empty ($cc->value) && strpos($accounting,$cc->p_value)===0)
1398 )
1399 )
1400 {
1401 //put in red if c>d
1402 $odd.=" notice ";
1403 }
1404
1405 $odd=' class="'.$odd.'"';
1406
1407 $r.="<TR $odd>";
1408 $url_detail=$script.'?'.http_build_query(array('sb'=>'detail','sc'=>'sv','ac'=>$_REQUEST['ac'],'f_id'=>$tiers->id,'gDossier'=>$gDossier));
1409 $e=sprintf('<A HREF="%s" title="Détail" class="line"> ',
1410 $url_detail);
1411
1412 $r.="<TD> $e".$tiers->strAttribut(ATTR_DEF_QUICKCODE)."</A></TD>";
1413 $r.="<TD sorttable_customkey=\"text{$accounting}\"> $e".$accounting."</TD>";
1414 $r.="<TD>".h($tiers->strAttribut(ATTR_DEF_NAME))."</TD>";
1415 $r.="<TD>".h($tiers->strAttribut(ATTR_DEF_ADRESS,0).
1416 " ".$tiers->strAttribut(ATTR_DEF_CP,0).
1417 " ".$tiers->strAttribut(ATTR_DEF_PAYS,0)).
1418 "</TD>";
1419 $r.='<td>'.linkTo($tiers->strAttribut(ATTR_DEF_WEBSITE,0)).'</td>';
1420 $str_deb=(($amount['debit']==0)?0:nbm($amount['debit']));
1421 $str_cred=(($amount['credit']==0)?0:nbm($amount['credit']));
1422 $str_solde=nbm($amount['solde']);
1423 $r.='<TD sorttable_customkey="'.$amount['debit'].'" align="right"> '.$str_deb.'</TD>';
1424 $r.='<TD sorttable_customkey="'.$amount['credit'].'" align="right"> '.$str_cred.'</TD>';
1425 $side=($amount['debit'] > $amount['credit'])?'D':'C';
1426 $side=($amount['debit'] == $amount['credit'])?'=':$side;
1427 $red="";
1428 if ( $p_action == 'customer' && $amount['debit'] < $amount['credit'] ){
1429 //put in red if d>c
1430 $red=" notice ";
1431 }
1432 if ( $p_action == 'supplier' && $amount['debit'] > $amount['credit'] ){
1433 //put in red if c>d
1434 $red=" notice ";
1435 }
1436 $r.='<TD class="'.$red.'" sorttable_customkey="'.$amount['solde'].'" align="right"> '.$str_solde."$side </TD>";
1437 $deb=bcadd($deb,$amount['debit']);
1438 $cred=bcadd($cred,$amount['credit']);
1439
1440 $r.="</TR>";
1441
1442 }
1443 $r.="<tfoot >";
1444 $solde=abs(bcsub($deb,$cred));
1445 $side=($deb > $cred)?'Débit':'Crédit';
1446 $r.='<tr class="highlight">';
1447 $r.=td("").td("").td("").td("").td("Totaux").td(nbm($deb),'class="num"').td(nbm($cred),'class="num"').td(" $side ".nbm($solde),'class="num"');
1448 $r.='</tr>';
1449 $r.="</tfoot>";
1450 $r.="</TABLE>";
1451 $r.=$bar;
1452
1453 return $r;
1454 }
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:223
const ATTR_DEF_CP
Definition constant.php:224
const ATTR_DEF_WEBSITE
Definition constant.php:239
const ATTR_DEF_ACCOUNT
Definition constant.php:215
const ATTR_DEF_PAYS
Definition constant.php:225
catch(\Exception $e) $bar
$script
Definition popup.php:125
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, $side, $solde, $tiers, _, ATTR_DEF_ACCOUNT, ATTR_DEF_ADRESS, ATTR_DEF_CP, ATTR_DEF_NAME, ATTR_DEF_PAYS, 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 1762 of file fiche.class.php.

1763 {
1765 $http=new HttpInput();
1766 echo h1('Test select category');
1767 $a=new Fiche($cn);
1768 $select_cat=new ISelect('fd_id');
1769 $select_cat->value=$cn->make_array('select fd_id,fd_label from fiche_def where frd_id='.
1771 echo '<FORM METHOD="GET"> ';
1772 echo dossier::hidden();
1773 echo HtmlInput::hidden('test_select',$http->get('test_select',"string",1));
1774 echo 'Choix de la catégorie';
1775 echo $select_cat->input();
1776 echo HtmlInput::submit('go_card','Afficher');
1777 echo '</form>';
1778 if ( isset ($_GET['go_card']))
1779 {
1780 $empty=$a->to_array($_GET['fd_id']);
1781 print_r($empty);
1782 }
1783 // testing insert
1784 echo h1("Insert new card");
1785 $name="test ".microtime();
1786 $fiche=new Fiche($cn);
1787 $fiche_def=new Fiche_Def($cn,1);
1788 $fiche_def->get();
1789
1790 $fiche->set_fiche_def($fiche_def->id);
1791
1792 $fiche->setAttribut(ATTR_DEF_NAME,$name);
1793 $fiche->setAttribut(ATTR_DEF_ACCOUNT,$fiche_def->class_base.$name);
1794
1795 echo p(print_r($fiche->to_array(),false));
1796 $fiche->insert(1,$fiche->to_array());
1797 assert($name == $fiche->strAttribut(ATTR_DEF_NAME));
1798
1799 echo p("fiche ATTR_DEF_ACCOUNT after insert ",$fiche->strAttribut(ATTR_DEF_ACCOUNT));
1800 $accounting=$fiche->strAttribut(ATTR_DEF_ACCOUNT);
1801 $acc_accounting=new Acc_Account($cn,$accounting);
1802
1803 echo p("accounting id",$acc_accounting->get_parameter("id"));
1804 assert($acc_accounting->get_lib("pcm_lib") == $name,"Cannot create a new accouting with
1805 the right label");
1806 }
h1($p_string, $p_class="")
Definition ac_common.php:72
p($p_string)
Definition ac_common.php:39
$select_cat
$_GET['qcode']
const FICHE_TYPE_CLIENT
Definition constant.php:247

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 331 of file fiche.class.php.

332 {
333 $a_return=[];
334 if ( empty ($this->attribut)) {
335 $this->getAttribut();
336 }
337 foreach ($this->attribut as $attr)
338 {
339 $a_return['av_text'.$attr->ad_id]=$attr->av_text;
340 }
341 $a_return['f_enable']=$this->get_f_enable();
342 return $a_return;
343 }
get_f_enable()

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

+ 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 551 of file fiche.class.php.

552 {
553 if ($p_array==null)
554 {
556 }
557 $this->fiche_def = $this->cn->get_value("select fd_id from fiche where f_id=$1",[$this->id]);
558 // unexistant category of cardf
559 if ( empty($this->fiche_def)) {
560 throw new Exception('FICHE.UPDATE524 category not found',EXC_INVALID);
561 }
562 if ( $this->cn->size()==0) {
563 throw new Exception("FICHE.UPDATE01"._("Fiche n'existe pas"),EXC_INVALID);
564 }
565
566
567 // get the card properties for this card category
568 $this->getAttribut();
569
570 if ( empty ($this->attribut) ) {
571 throw new Exception("FICHE.UPDATE02"._("Aucun attribut ")."($this->fiche_def)",EXC_INVALID);
572 }
573 // for each property set the attribut on the card
574 foreach($this->attribut as $property) {
575 $key='av_text'.$property->ad_id;
576 if ( isset($p_array[$key])) {
577 $this->setAttribut($property->ad_id, $p_array[$key]);
578 }
579 }
580 if ( isset($p_array['f_enable'])) {
581 $this->set_f_enable($p_array["f_enable"]);
582 }else {
583 $this->set_f_enable(1);
584 }
585 // save all
587 $this->quick_code=$this->strAttribut(ATTR_DEF_QUICKCODE);
588 }
set_f_enable($f_enable)

References $_POST, $p_array, _, ATTR_DEF_QUICKCODE, cn, EXC_INVALID, getAttribut(), set_f_enable(), setAttribut(), strAttribut(), 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 setAttribut().

◆ $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: