noalyss Version-9
Public Member Functions | Static Public Member Functions | Data Fields | Private Member Functions | Private Attributes
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)
 
 __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. More...
 
 blank ($p_fiche_def)
 insert a new record show a blank card to be filled More...
 
 build_sql ($array)
 create the sql statement for retrieving all the card More...
 
 button_csv ($p_from, $p_to)
 Return a string with the HTML code to display a button to export the history in CSV. More...
 
 button_pdf ($p_from, $p_to)
 Return a string with the HTML code to display a button to export the history in PDF. More...
 
 count_by_modele ($p_frd_id, $p_search="", $p_sql="")
 Count the nb of card with the reference card id frd_id. More...
 
 delete ()
 
 Display ($p_readonly, $p_in="")
 Display object instance, getAttribute sort the attribute and add missing ones. More...
 
 display_row ()
 display card as a table row , the tag TR must be added More...
 
 empty_attribute ($p_attr)
 check if an attribute is empty More...
 
 filter_history ($p_table_id)
 Filter in javascript the table with the history. More...
 
 Get ()
 Synonum of fiche::getAttribut. More...
 
 get_all_account ()
 
 get_amount_side ($p_amount)
 return the letter C if amount is > 0, D if < 0 or = More...
 
 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. More...
 
 get_bk_account ()
 get the available bank_account filtered by the security More...
 
 get_bk_balance ($p_cond="")
 get the bank balance with receipt or not in Euro More...
 
 get_bk_balance_currency ($p_cond="")
 Get the sum in Currency. More...
 
 get_by_category ($p_offset=-1, $p_search="", $p_order='')
 get all the card thanks the fiche_def_ref More...
 
 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. More...
 
 get_categorie ()
 get the fd_id of the card : fd_id, it set the attribute fd_id More...
 
 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) More...
 
 get_gestion_title ()
 
 get_id ()
 
 get_quick_code ()
 return the quick_code of a card More...
 
 get_row ($p_from, $p_to)
 Get data for poste. More...
 
 get_row_date ($p_from, $p_to, $op_let=0)
 Get data for poste. More...
 
 get_solde_detail ($p_cond="")
 give the balance of an card More...
 
 getAttribut ()
 get all the attribute of a card, add missing ones and sort the array ($this->attribut) by ad_id More...
 
 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. More...
 
 getDisplayMode ()
 
 getLabelCategory ()
 
 getName ()
 return the name of a card More...
 
 HtmlTable ($p_array=null, $op_let=0, $from_div=1)
 HtmlTable, display a HTML of a card for the asked period. More...
 
 HtmlTableDetail ($p_array=null, $op_let=0)
 HtmlTable, display a HTML of a card for the asked period. More...
 
 HtmlTableHeader ($p_array=null)
 Display HTML Table Header (button) More...
 
 insert ($p_fiche_def, $p_array=null, $transaction=true)
 insert a new record thanks an array , either as parameter or $_POST More...
 
 is_used ()
 check if a card is used More...
 
 load ()
 Synonum of fiche::getAttribut. More...
 
 move_to ($p_fdid)
 move a card to another cat. More...
 
 remove ($silent=false)
 remove a card, check if not used first, must be synchro with is_used More...
 
 save ($p_fiche_def=0)
 Save a card, call insert or update. More...
 
 seek ($p_attribut, $p_value)
 find the card with the p_attribut equal to p_value, it is not case sensitive More...
 
 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 More...
 
 setDisplayMode ($p_mode)
 how the card is display : either in a window or a greated container More...
 
 ShowTable ()
 
 strAttribut ($p_ad_id, $p_return=1)
 
 Summary ($p_search="", $p_action="", $p_sql="", $p_amount=false)
 show the default screen More...
 
 to_array ()
 turn a card into an array , then it can be saved thanks update or insert More...
 
 update ($p_array=null)
 update a card with an array More...
 

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 More...
 
static from_qcode ($p_qcode)
 create a card from a qcode and returns a card More...
 
static get_fiche_def ($p_cn, $pFd_id, $p_order='')
 get all the card from a categorie More...
 
static test_me ()
 

Data Fields

 $attribut
 
 $cn
 
 $fiche_def
 
 $fiche_def_ref
 
 $id
 
 $quick_code
 
 $row
 
 $tot_cred
 
 $tot_deb
 

Private Member Functions

 get_row_result_deprecated ($res)
 fetch and return and array More...
 

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 
)

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

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

52 {
53 $this->cn=$p_cn;
54 // in PHP7 , a null string == 0
55 // in PHP8 , a null string == a null string and is not equal to 0
56 // to fix this, we set the fix here
57 if ( isNumber($p_id) == 1 ) {
58 $this->id=$p_id;
59 } else {
60 $this->id=0;
61 }
62 $this->quick_code='';
63 $this->attribut=array();
64 $this->f_enable='1';
65 if ($p_id != 0 ) { $this->load();} else {
66 $this->fiche_def=0;
67 }
68
69 $this->display_mode="window";
70 }
isNumber($p_int)
Definition: ac_common.php:215
$input_from cn
Definition: balance.inc.php:66
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 369 of file fiche.class.php.

369 : string
370 {
371 return print_r($this,true);
372 }

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

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

References $id, $list, $Max, $p_type, $Res, $row, $sql, cn, elseif, DatabaseCore\fetch_all(), 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 350 of file fiche.class.php.

351 {
352 // array = array of attribute object sorted on ad_id
353 $fiche_def=new Fiche_Def($this->cn,$p_fiche_def);
354 $fiche_def->get();
355 $array=$fiche_def->getAttribut();
356 $r="";
357 $r.='<table style="width:98%;margin:1%">';
358 foreach ($array as $attr)
359 {
360 $table=0;
361 $msg="";$bulle='';
362 $r.=$attr->input($fiche_def);
363
364 }
365 $r.= '</table>';
366 return $r;
367 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
define Class fiche and fiche def, those class are using class attribut
$table
Definition: menu.inc.php:103

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

1647 {
1648 if (!empty($array))
1649 extract($array, EXTR_SKIP);
1650 $and='';
1651 $filter_fd_id='true';
1652 $filter_query='';
1653 if (isset($typecard))
1654 {
1655 if (strpos($typecard, "sql")==false)
1656 {
1657 switch ($typecard)
1658 {
1659 case 'cred':
1660 if (!isset($jrn))
1661 throw Exception('Erreur pas de valeur pour jrn');
1662 $filter_jrn=$this->cn->make_list("select jrn_def_fiche_cred from jrn_Def where jrn_def_id=$1",
1663 array($jrn));
1664 $filter_fd_id=(empty($filter_jrn))?" fd_id in (-1) ":" fd_id in (".$filter_jrn.")";
1665 $and=" and ";
1666 break;
1667 case 'deb':
1668 if (!isset($jrn))
1669 throw Exception('Erreur pas de valeur pour jrn');
1670 $filter_jrn=$this->cn->make_list("select jrn_def_fiche_deb from jrn_Def where jrn_def_id=$1",
1671 array($jrn));
1672 $filter_fd_id=(empty($filter_jrn))?"fd_id in (-1) ":" fd_id in (".$filter_jrn.")";
1673 $and=" and ";
1674 break;
1675 case 'filter':
1676 if (!isset($jrn))
1677 throw Exception('Erreur pas de valeur pour jrn');
1678 $filter_jrn=$this->cn->make_list("select jrn_def_fiche_deb from jrn_Def where jrn_def_id=$1",
1679 array($jrn));
1680
1681 if (noalyss_trim($filter_jrn)!='')
1682 $fp1=" fd_id in (".$filter_jrn.")";
1683 else
1684 $fp1="fd_id < 0";
1685
1686 $filter_jrn=$this->cn->make_list("select jrn_def_fiche_cred from jrn_Def where jrn_def_id=$1",
1687 array($jrn));
1688
1689 if (noalyss_trim($filter_jrn)!='')
1690 $fp2=" fd_id in (".$filter_jrn.")";
1691 else
1692 $fp2="fd_id < 0";
1693
1694 $filter_fd_id='('.$fp1.' or '.$fp2.')';
1695
1696 $and=" and ";
1697 break;
1698 case 'all':
1699 $filter_fd_id=' true';
1700 break;
1701 default:
1703 $filter_fd_id=' fd_id in ('.$typecard.')';
1704 else
1705 $filter_fd_id=' fd_id < 0';
1706 }
1707 }
1708 else
1709 {
1710 $filter_fd_id=noalyss_str_replace('[sql]', '', $typecard);
1711 }
1712 }
1713
1714 $and=" and ";
1715 if (isset($query))
1716 {
1718
1720 {
1722 $filter_query=$and."(vw_name ilike '%$query%' or quick_code ilike ('%$query%') "
1723 ." or vw_description ilike '%$query%' or tva_num ilike '%$query%' or accounting like upper('$query%'))";
1724 }
1725 else
1726 {
1727 $filter_query='';
1728 }
1729 }
1730 $sql="select * from vw_fiche_attr where ".$filter_fd_id.$filter_query;
1731 return $sql;
1732 }
noalyss_strlentrim($p_string)
Definition: ac_common.php:1549
noalyss_str_replace($search, $replace, $string)
Definition: ac_common.php:1553
sql_string($p_string)
Fix the problem with the quote char for the database.
Definition: ac_common.php:511
noalyss_trim($p_string)
Definition: ac_common.php:1545
if(!headers_sent())
– pour utiliser unoconv démarrer un server libreoffice commande libreoffice –headless –accept="socket...
$typecard
Definition: fid_card.php:62

References $array, $jrn, $query, $sql, $typecard, cn, if, 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 1825 of file fiche.class.php.

1825 {
1826 $href="export.php?".http_build_query(
1827 array(
1828 "gDossier"=>Dossier::id(),
1829 "f_id"=>$this->id,
1830 "ople"=>0,
1831 "type"=>"poste",
1832 "from_periode"=>$p_from,
1833 "to_periode"=>$p_to,
1834 "act"=>"CSV:fichedetail"
1835 )
1836 );
1837 return '<a class="smallbutton" style="display:inline-block" href="'.$href.'">'._("Export CSV").'</a>';
1838
1839 }
$href
Definition: adm.inc.php:31
static id()
return the 'gDossier' value after a check

References $href, and Dossier\id().

+ Here is the call graph for this function:

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

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

References $href, and Dossier\id().

+ Here is the call graph for this function:

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

136 {
137 return strcmp($o1->strAttribut(ATTR_DEF_NAME),$o2->strAttribut(ATTR_DEF_NAME));
138 }
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 249 of file fiche.class.php.

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

References $result, and cn.

◆ delete()

Fiche::delete ( )

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

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

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

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

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

1896 {
1897 $this->getAttribut();
1898 foreach($this->attribut as $attr) {
1899 $sort="";
1900
1901 if ($attr->ad_type!='select')
1902 {
1903
1904 if ($attr->ad_type=="date") {
1905 // format YYYYMMDD
1906 $sort='sorttable_customkey="'.format_date($attr->av_text, "DD.MM.YYYY", "YYYYMMDD").'"';
1907 }
1908 elseif ($attr->ad_type=="poste"){
1909 $sort='sorttable_customkey="TEXT'.$attr->av_text.'"';
1910 }
1911 echo td($attr->av_text, 'style="padding: 0 10 1 10;white-space:nowrap;" '.$sort);
1912 }
1913 else {
1914 $value=$this->cn->make_array($attr->ad_extra);
1915 $row_content="";
1916 for ($e=0; $e<count($value); $e++) {
1917 if ( $value[$e]['value']==$attr->av_text) {
1918 $row_content=h($value[$e]['label']);
1919 break;
1920 }
1921 }
1922 echo td($row_content, 'style="padding: 0 10 1 10;white-space:nowrap;"');
1923
1924 }
1925 }
1926
1927 }
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, 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 1284 of file fiche.class.php.

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

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

References HtmlInput\filter_table().

+ Here is the call graph for this function:

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

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

References $card, $cn, and Dossier\connect().

+ Here is the call graph for this function:

◆ Get()

Fiche::Get ( )

Synonum of fiche::getAttribut.

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

638 {
639 $this->getAttribut();
640 }

References getAttribut().

+ Here is the call graph for this function:

◆ get_all_account()

Fiche::get_all_account ( )

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

1815 {
1816
1817 }

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

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

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

1875 {
1876 try {
1877 $id=$this->cn->get_value("select jrn_def_id from jrn_def where jrn_def_bank = $1 ",[$this->id]);
1878 if ($id == "") { return NULL;}
1879 $ledger=new Acc_Ledger_Fin($this->cn,$id);
1880 $ledger->load();
1881 return $ledger;
1882 }
1883 catch (Exception $e) {
1884 record_log(__FILE__.":".__LINE__);
1885 record_log($e->getMessage());
1886 throw $e;
1887 }
1888 }
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342
the class Acc_Ledger_Fin inherits from Acc_Ledger, this object permit to manage the financial ledger

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

145 {
146 global $g_user;
147 $sql_ledger=$g_user->get_ledger_sql('FIN',3);
148 $avail=$this->cn->get_array("select jrn_def_id,jrn_def_name,"
149 . "jrn_def_bank,jrn_def_description,currency_id from jrn_def where jrn_def_type='FIN' and $sql_ledger
150 order by jrn_def_name");
151
152 if ( count($avail) == 0 )
153 return null;
154
155 for ($i=0;$i<count($avail);$i++)
156 {
157 $t=new Fiche($this->cn,$avail[$i]['jrn_def_bank']);
158 $t->ledger_name=$avail[$i]['jrn_def_name'];
159 $t->ledger_description=$avail[$i]['jrn_def_description'];
160 $t->getAttribut();
161 $all[$i]=$t;
162
163 }
164 return $all;
165 }
global $g_user
if no group available , then stop
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
Definition: fiche.class.php:38
$all

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

◆ get_bk_balance()

Fiche::get_bk_balance (   $p_cond = "")

get the bank balance with receipt or not in Euro

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

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

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

References $sql, $val, 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 653 of file fiche.class.php.

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

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

Referenced by GetByDef().

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

178 {
179 if ( $p_qcode == null )
180 $p_qcode=$this->quick_code;
181 $p_qcode=trim($p_qcode);
182 $sql="select f_id from fiche_detail
183 where ad_id=23 and ad_value=upper($1)";
184 $this->id=$this->cn->get_value($sql,array($p_qcode));
185 if ( $this->cn->count()==0)
186 {
187 $this->id=0;
188 return 1;
189 }
190
191
192 if ( $p_all )
193 $this->getAttribut();
194 return 0;
195 }

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

Referenced by Follow_Up\save().

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

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

References $fd_id, $sql, and cn.

◆ get_f_enable()

Fiche::get_f_enable ( )

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

110 {
111 return $this->f_enable;
112 }

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

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

References $array, $p_order, and $sql.

◆ get_fiche_def_ref()

Fiche::get_fiche_def_ref ( )

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

105 {
107 }
$fiche_def_ref
Definition: fiche.class.php:43

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

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

References $result, and cn.

◆ get_gestion_title()

Fiche::get_gestion_title ( )

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

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

References $r, ATTR_DEF_FIRST_NAME, and h.

◆ get_id()

Fiche::get_id ( )

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

100 {
101 return $this->id;
102 }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

References Card_Property\load().

Referenced by 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 286 of file fiche.class.php.

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

89 : string
90 {
92 }
$display_mode
Definition: fiche.class.php:47

References $display_mode.

◆ getLabelCategory()

Fiche::getLabelCategory ( )
Returns
string with the category

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

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

References cn.

◆ getName()

Fiche::getName ( )

return the name of a card

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

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

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

Referenced by 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 964 of file fiche.class.php.

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

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

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

References $_REQUEST, $hid, $id, $p_array, HtmlInput\array_to_hidden(), HtmlInput\hidden(), HtmlInput\print_window(), and HtmlInput\submit().

+ Here is the call graph for this function:

◆ 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
$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 \verb example av_text1=>'name' \endverb

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

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

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

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

References $count, $qcode, $sql, ATTR_DEF_QUICKCODE, and cn.

Referenced by remove().

◆ load()

Fiche::load ( )

Synonum of fiche::getAttribut.

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

643 :void
644 {
645 $this->getAttribut();
646 }

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

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

References cn.

◆ remove()

Fiche::remove (   $silent = false)

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

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

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

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

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

References $res, $sql, and cn.

◆ set_f_enable()

Fiche::set_f_enable (   $f_enable)

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

127 {
128 $this->f_enable=$f_enable;
129 return $this;
130 }

References $f_enable.

Referenced by update().

◆ set_fiche_def()

Fiche::set_fiche_def (   $p_fiche_def)

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

94 {
95 $this->fiche_def=$p_fiche_def;
96 return $this;
97 }

◆ set_fiche_def_ref()

Fiche::set_fiche_def_ref (   $fiche_def_ref)

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

121 {
122 $this->fiche_def_ref=$fiche_def_ref;
123 return $this;
124 }

References $fiche_def_ref.

◆ set_id()

Fiche::set_id (   $id)

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

115 {
116 $this->id=$id;
117 return $this;
118 }

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

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

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

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

◆ ShowTable()

Fiche::ShowTable ( )

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

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

◆ strAttribut()

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

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

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

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

Referenced by cmp_name(), Acc_Ledger_Purchase\compute_no_deductible(), get_row(), get_row_date(), HtmlTableDetail(), Acc_Ledger_Purchase\insert_no_deductible(), update(), and Card_Property\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 1308 of file fiche.class.php.

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

References $_REQUEST, $accounting, $amount, $bar, $cred, $deb, $e, $exercice, $filter_year, $g_parameter, $g_user, $gDossier, $http, $i, $max, $min, $offset, $p_action, $page, $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, id, 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 1763 of file fiche.class.php.

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

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

330 {
331 $a_return=[];
332 if ( empty ($this->attribut)) {
333 $this->getAttribut();
334 }
335 foreach ($this->attribut as $attr)
336 {
337 $a_return['av_text'.$attr->ad_id]=$attr->av_text;
338 }
339 $a_return['f_enable']=$this->get_f_enable();
340 return $a_return;
341 }
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 549 of file fiche.class.php.

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

◆ $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(), and insert().

◆ $fiche_def_ref

Fiche::$fiche_def_ref

< $attribut array of attribut object $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_id(), and set_id().

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

Fiche::$row

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

Referenced by Customer\get_by_account(), Supplier\get_by_account(), and get_row_date().

◆ $tot_cred

Fiche::$tot_cred

◆ $tot_deb

Fiche::$tot_deb

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