From 80d4d8754d5e548902878c50fca8a7571349e2a2 Mon Sep 17 00:00:00 2001
From: Eric Seigne <1468823+rycks@users.noreply.github.com>
Date: Mon, 17 Jun 2019 18:28:11 +0200
Subject: [PATCH] allow zero as accountancy code nomber (replace all empty
tests by != '')
---
.../accountancy/bookkeeping/listbyaccount.php | 2 +-
htdocs/accountancy/class/lettering.class.php | 30 +++++++++---------
htdocs/accountancy/journal/bankjournal.php | 14 ++++-----
.../journal/expensereportsjournal.php | 14 ++++-----
.../accountancy/journal/purchasesjournal.php | 2 +-
htdocs/accountancy/journal/sellsjournal.php | 14 ++++-----
htdocs/compta/journal/purchasesjournal.php | 4 +--
htdocs/compta/journal/sellsjournal.php | 2 +-
.../core/class/html.formaccounting.class.php | 2 +-
htdocs/core/lib/accounting.lib.php | 31 ++++++++++++++-----
.../societe/mod_codecompta_panicum.php | 4 +--
htdocs/societe/class/societe.class.php | 4 +--
12 files changed, 70 insertions(+), 53 deletions(-)
diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php
index d1ef1377994..bacfdcb714a 100644
--- a/htdocs/accountancy/bookkeeping/listbyaccount.php
+++ b/htdocs/accountancy/bookkeeping/listbyaccount.php
@@ -348,7 +348,7 @@ while ($i < min($num, $limit))
$colspan = 9;
print "
";
print '| ';
- if (! empty($line->numero_compte) && $line->numero_compte != '-1') print length_accountg($line->numero_compte) . ' : ' . $object->get_compte_desc($line->numero_compte);
+ if ($line->numero_compte != "" && $line->numero_compte != '-1') print length_accountg($line->numero_compte) . ' : ' . $object->get_compte_desc($line->numero_compte);
else print ''.$langs->trans("Unknown").'';
print ' | ';
print '
';
diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php
index a0c977a8d5a..2a89c6c1c96 100644
--- a/htdocs/accountancy/class/lettering.class.php
+++ b/htdocs/accountancy/class/lettering.class.php
@@ -67,11 +67,11 @@ class Lettering extends BookKeeping
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) ";
$sql .= " WHERE ( ";
- if (! empty($object->code_compta))
+ if ($object->code_compta != "")
$sql .= " bk.subledger_account = '" . $object->code_compta . "' ";
- if (! empty($object->code_compta) && ! empty($object->code_compta_fournisseur))
+ if ($object->code_compta != "" && $object->code_compta_fournisseur != "")
$sql .= " OR ";
- if (! empty($object->code_compta_fournisseur))
+ if ($object->code_compta_fournisseur != "")
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
$sql .= " ) AND (bk.date_lettering ='' OR bk.date_lettering IS NULL) ";
@@ -99,13 +99,13 @@ class Lettering extends BookKeeping
$sql .= " AND facf.entity = ".$conf->entity;
$sql .= " AND code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=4 AND entity=".$conf->entity.") ";
$sql .= " AND ( ";
- if (! empty($object->code_compta)) {
+ if ($object->code_compta != "") {
$sql .= " bk.subledger_account = '" . $object->code_compta . "' ";
}
- if (! empty($object->code_compta) && ! empty($object->code_compta_fournisseur)) {
+ if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR ";
}
- if (! empty($object->code_compta_fournisseur)) {
+ if ($object->code_compta_fournisseur != "") {
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
}
$sql .= " ) ";
@@ -127,13 +127,13 @@ class Lettering extends BookKeeping
$sql .= " WHERE bk.code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=3 AND entity=".$conf->entity.") ";
$sql .= " AND facf.entity = ".$conf->entity;
$sql .= " AND ( ";
- if (! empty($object->code_compta)) {
+ if ($object->code_compta != "") {
$sql .= " bk.subledger_account = '" . $object->code_compta . "' ";
}
- if (! empty($object->code_compta) && ! empty($object->code_compta_fournisseur)) {
+ if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR ";
}
- if (! empty($object->code_compta_fournisseur)) {
+ if ($object->code_compta_fournisseur != "") {
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
}
$sql .= ") ";
@@ -159,13 +159,13 @@ class Lettering extends BookKeeping
$sql .= " AND bk.code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=4 AND entity=".$conf->entity.") ";
$sql .= " AND fac.entity IN (".getEntity('invoice', 0).")";// We don't share object for accountancy
$sql .= " AND ( ";
- if (! empty($object->code_compta)) {
+ if ($object->code_compta != "") {
$sql .= " bk.subledger_account = '" . $object->code_compta . "' ";
}
- if (! empty($object->code_compta) && ! empty($object->code_compta_fournisseur)) {
+ if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR ";
}
- if (! empty($object->code_compta_fournisseur)) {
+ if ($object->code_compta_fournisseur != "") {
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
}
$sql .= " ) ";
@@ -187,13 +187,13 @@ class Lettering extends BookKeeping
$sql .= " WHERE code_journal IN (SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE nature=2 AND entity=".$conf->entity.") ";
$sql .= " AND fac.entity IN (".getEntity('invoice', 0).")";// We don't share object for accountancy
$sql .= " AND ( ";
- if (! empty($object->code_compta)) {
+ if ($object->code_compta != "") {
$sql .= " bk.subledger_account = '" . $object->code_compta . "' ";
}
- if (! empty($object->code_compta) && ! empty($object->code_compta_fournisseur)) {
+ if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR ";
}
- if (! empty($object->code_compta_fournisseur)) {
+ if ($object->code_compta_fournisseur != "") {
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
}
$sql .= " ) ";
diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php
index e4e07831b44..0f22789d630 100644
--- a/htdocs/accountancy/journal/bankjournal.php
+++ b/htdocs/accountancy/journal/bankjournal.php
@@ -171,8 +171,8 @@ if ($result) {
//print $sql;
// Variables
- $account_supplier = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word
- $account_customer = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word
+ $account_supplier = (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "") ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : 'NotDefined'); // NotDefined is a reserved word
+ $account_customer = ($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "") ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined'); // NotDefined is a reserved word
$account_employee = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : 'NotDefined'); // NotDefined is a reserved word
$account_pay_vat = (! empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : 'NotDefined'); // NotDefined is a reserved word
$account_pay_donation = (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : 'NotDefined'); // NotDefined is a reserved word
@@ -218,7 +218,7 @@ if ($result) {
// Set accountancy code for thirdparty
$compta_soc = 'NotDefined';
if ($lineisapurchase > 0)
- $compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $account_supplier);
+ $compta_soc = (($obj->code_compta_fournisseur != "") ? $obj->code_compta_fournisseur : $account_supplier);
if ($lineisasale > 0)
$compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $account_customer);
@@ -938,8 +938,8 @@ if (empty($action) || $action == 'view') {
// Button to write into Ledger
- if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1'
- || empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1'
+ if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1'
+ || ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1'
|| empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') {
print '
'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ''.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'');
@@ -950,8 +950,8 @@ if (empty($action) || $action == 'view') {
if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print '';
- if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1'
- || empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
+ if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1'
+ || ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
print '';
}
else {
diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php
index 4c50015a2ba..d82381533cf 100644
--- a/htdocs/accountancy/journal/expensereportsjournal.php
+++ b/htdocs/accountancy/journal/expensereportsjournal.php
@@ -444,10 +444,10 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
foreach ($taber as $key => $val) {
$date = dol_print_date($val["date"], 'day');
-
+
$userstatic->id = $tabuser[$key]['id'];
$userstatic->name = $tabuser[$key]['name'];
-
+
// Fees
foreach ($tabht[$key] as $k => $mt) {
$accountingaccount = new AccountingAccount($db);
@@ -474,7 +474,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
print "\n";
}
}
-
+
// Third party
foreach ($tabttc[$key] as $k => $mt) {
print '"' . $date . '"' . $sep;
@@ -585,7 +585,7 @@ if (empty($action) || $action == 'view') {
// Account
print "";
$accountoshow = length_accountg($k);
- if (empty($accountoshow) || $accountoshow == 'NotDefined')
+ if (($accountoshow == "") || $accountoshow == 'NotDefined')
{
print ''.$langs->trans("FeeAccountNotDefined").'';
}
@@ -615,7 +615,7 @@ if (empty($action) || $action == 'view') {
// Account
print " | ";
$accountoshow = length_accounta($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT);
- if (empty($accountoshow) || $accountoshow == 'NotDefined')
+ if (($accountoshow == "") || $accountoshow == 'NotDefined')
{
print ''.$langs->trans("MainAccountForUsersNotDefined").'';
}
@@ -624,7 +624,7 @@ if (empty($action) || $action == 'view') {
// Subledger account
print " | ";
$accountoshow = length_accounta($k);
- if (empty($accountoshow) || $accountoshow == 'NotDefined')
+ if (($accountoshow == "") || $accountoshow == 'NotDefined')
{
print ''.$langs->trans("UserAccountNotDefined").'';
}
@@ -652,7 +652,7 @@ if (empty($action) || $action == 'view') {
// Account
print " | ";
$accountoshow = length_accountg($k);
- if (empty($accountoshow) || $accountoshow == 'NotDefined')
+ if (($accountoshow == "") || $accountoshow == 'NotDefined')
{
print ''.$langs->trans("VATAccountNotDefined").'';
}
diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php
index cab5069e1f8..cd82e9f2f27 100644
--- a/htdocs/accountancy/journal/purchasesjournal.php
+++ b/htdocs/accountancy/journal/purchasesjournal.php
@@ -749,7 +749,7 @@ if (empty($action) || $action == 'view') {
}
print '';
if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print ' ';
- if (empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
+ if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
print ' ';
}
else {
diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php
index 8f82fd95afb..3b0607d34a7 100644
--- a/htdocs/accountancy/journal/sellsjournal.php
+++ b/htdocs/accountancy/journal/sellsjournal.php
@@ -146,7 +146,7 @@ if ($result) {
$num = $db->num_rows($result);
// Variables
- $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined';
+ $cptcli = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "")) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : 'NotDefined';
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : 'NotDefined';
$i = 0;
@@ -679,14 +679,14 @@ if (empty($action) || $action == 'view') {
journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink);
// Button to write into Ledger
- if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
+ if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
print ' ';
print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, ' '.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'');
}
print ' ';
if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) print ' ';
- if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
+ if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
print ' ';
}
else {
@@ -813,7 +813,7 @@ if (empty($action) || $action == 'view') {
// Account
print " ";
$accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER);
- if (empty($accountoshow) || $accountoshow == 'NotDefined')
+ if (($accountoshow == "") || $accountoshow == 'NotDefined')
{
print ''.$langs->trans("MainAccountForCustomersNotDefined").'';
}
@@ -822,7 +822,7 @@ if (empty($action) || $action == 'view') {
// Subledger account
print " | ";
$accountoshow = length_accounta($k);
- if (empty($accountoshow) || $accountoshow == 'NotDefined')
+ if (($accountoshow == "") || $accountoshow == 'NotDefined')
{
print ''.$langs->trans("ThirdpartyAccountNotDefined").'';
}
@@ -849,7 +849,7 @@ if (empty($action) || $action == 'view') {
// Account
print " | ";
$accountoshow = length_accountg($k);
- if (empty($accountoshow) || $accountoshow == 'NotDefined')
+ if (($accountoshow == "") || $accountoshow == 'NotDefined')
{
print ''.$langs->trans("ProductNotDefined").'';
}
@@ -884,7 +884,7 @@ if (empty($action) || $action == 'view') {
// Account
print " | ";
$accountoshow = length_accountg($k);
- if (empty($accountoshow) || $accountoshow == 'NotDefined')
+ if (($accountoshow == "") || $accountoshow == 'NotDefined')
{
print ''.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Sale").')'.'';
}
diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php
index cd3bf06f43a..5b4e54fd807 100644
--- a/htdocs/compta/journal/purchasesjournal.php
+++ b/htdocs/compta/journal/purchasesjournal.php
@@ -123,7 +123,7 @@ if ($result)
{
$num = $db->num_rows($result);
// les variables
- $cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)?$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER:$langs->trans("CodeNotDef"));
+ $cptfour = (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER != "")?$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER:$langs->trans("CodeNotDef"));
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)?$conf->global->ACCOUNTING_VAT_BUY_ACCOUNT:$langs->trans("CodeNotDef"));
$tabfac = array();
@@ -139,7 +139,7 @@ if ($result)
{
$obj = $db->fetch_object($result);
// contrĂ´les
- $compta_soc = (! empty($obj->code_compta_fournisseur)?$obj->code_compta_fournisseur:$cptfour);
+ $compta_soc = (($obj->code_compta_fournisseur != "")?$obj->code_compta_fournisseur:$cptfour);
$compta_prod = $obj->accountancy_code_buy;
if (empty($compta_prod))
{
diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php
index fe51665163e..123bb3c7770 100644
--- a/htdocs/compta/journal/sellsjournal.php
+++ b/htdocs/compta/journal/sellsjournal.php
@@ -146,7 +146,7 @@ if ($result)
{
$obj = $db->fetch_object($result);
// les variables
- $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)?$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER:$langs->trans("CodeNotDef"));
+ $cptcli = (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER != "")?$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER:$langs->trans("CodeNotDef"));
$compta_soc = (! empty($obj->code_compta)?$obj->code_compta:$cptcli);
$compta_prod = $obj->accountancy_code_sell;
if (empty($compta_prod))
diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php
index 87b32902684..cf95e471ddd 100644
--- a/htdocs/core/class/html.formaccounting.class.php
+++ b/htdocs/core/class/html.formaccounting.class.php
@@ -392,7 +392,7 @@ class FormAccounting extends Form
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
- if (!empty($obj->code_compta_fournisseur)) {
+ if ($obj->code_compta_fournisseur != "") {
$aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->nom.')';
}
}
diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php
index 889d9da8a2c..4b5345da62b 100644
--- a/htdocs/core/lib/accounting.lib.php
+++ b/htdocs/core/lib/accounting.lib.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2013-2014 Olivier Geffroy
* Copyright (C) 2013-2017 Alexandre Spangaro
* Copyright (C) 2014 Florian Henry
+ * Copyright (C) 2019 Eric Seigne
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,6 +24,22 @@
* \brief Library of accountancy functions
*/
+ /**
+ * Check if a value is empty with some options
+ *
+ * @param allow_false : setting this to true will make the function consider a boolean value of false as NOT empty. This parameter is false by default.
+ * @param allow_ws : setting this to true will make the function consider a string with nothing but white space as NOT empty. This parameter is false by default.
+ * @return array Bool
+ * @author Michael - https://www.php.net/manual/fr/function.empty.php#90767
+ */
+ function is_empty($var, $allow_false = false, $allow_ws = false) {
+ if (!isset($var) || is_null($var) || ($allow_ws == false && trim($var) == "" && !is_bool($var)) || ($allow_false === false && is_bool($var) && $var === false) || (is_array($var) && empty($var))) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
/**
* Prepare array with list of tabs
*
@@ -75,12 +92,12 @@ function length_accountg($account)
{
global $conf;
- if ($account < 0 || empty($account)) return '';
+ if ($account < 0 || is_empty($account)) return '';
- if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account;
+ if (! is_empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account;
$g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT;
- if (! empty($g)) {
+ if (! is_empty($g)) {
// Clean parameters
$i = strlen($account);
@@ -110,12 +127,12 @@ function length_accounta($accounta)
{
global $conf;
- if ($accounta < 0 || empty($accounta)) return '';
+ if ($accounta < 0 || is_empty($accounta)) return '';
- if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta;
+ if (! is_empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta;
$a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT;
- if (! empty($a)) {
+ if (! is_empty($a)) {
// Clean parameters
$i = strlen($accounta);
@@ -158,7 +175,7 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build
print "\n\n\n";
- if(! empty($varlink)) $varlink = '?'.$varlink;
+ if(! is_empty($varlink)) $varlink = '?'.$varlink;
$head=array();
$h=0;
diff --git a/htdocs/core/modules/societe/mod_codecompta_panicum.php b/htdocs/core/modules/societe/mod_codecompta_panicum.php
index 4c5ffcd66c5..f3106cef761 100644
--- a/htdocs/core/modules/societe/mod_codecompta_panicum.php
+++ b/htdocs/core/modules/societe/mod_codecompta_panicum.php
@@ -96,8 +96,8 @@ class mod_codecompta_panicum extends ModeleAccountancyCode
$this->code='';
if (is_object($societe)) {
- if ($type == 'supplier') $this->code = (! empty($societe->code_compta_fournisseur)?$societe->code_compta_fournisseur:'');
- else $this->code = (! empty($societe->code_compta)?$societe->code_compta:'');
+ if ($type == 'supplier') $this->code = (($societe->code_compta_fournisseur != "")?$societe->code_compta_fournisseur:'');
+ else $this->code = (($societe->code_compta != "")?$societe->code_compta:'');
}
return 0; // return ok
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 84bda8abd54..ce7617f003d 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -928,7 +928,7 @@ class Societe extends CommonObject
if (! empty($allowmodcodefournisseur) && ! empty($this->fournisseur))
{
// Attention get_codecompta peut modifier le code suivant le module utilise
- if (empty($this->code_compta_fournisseur))
+ if ($this->code_compta_fournisseur == "")
{
$ret=$this->get_codecompta('supplier');
if ($ret < 0) return -1;
@@ -1085,7 +1085,7 @@ class Societe extends CommonObject
if ($supplier)
{
$sql .= ", code_fournisseur = ".(! empty($this->code_fournisseur)?"'".$this->db->escape($this->code_fournisseur)."'":"null");
- $sql .= ", code_compta_fournisseur = ".(! empty($this->code_compta_fournisseur)?"'".$this->db->escape($this->code_compta_fournisseur)."'":"null");
+ $sql .= ", code_compta_fournisseur = ".(($this->code_compta_fournisseur != "")?"'".$this->db->escape($this->code_compta_fournisseur)."'":"null");
}
$sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id:"null");
$sql .= ", fk_multicurrency = ".(int) $this->fk_multicurrency;
| |