diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php
index cb47e436cbd..2975c7de3c0 100644
--- a/htdocs/accountancy/customer/list.php
+++ b/htdocs/accountancy/customer/list.php
@@ -532,10 +532,12 @@ if ($result) {
}
// Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding)
- if (!empty($objp->company_code_sell)) {
- $objp->code_sell_t = $objp->company_code_sell;
- $objp->aarowid_suggest = $objp->aarowid_thirdparty;
- $suggestedaccountingaccountfor = '';
+ if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
+ if (!empty($objp->company_code_sell)) {
+ $objp->code_sell_t = $objp->company_code_sell;
+ $objp->aarowid_suggest = $objp->aarowid_thirdparty;
+ $suggestedaccountingaccountfor = '';
+ }
}
// Manage Deposit
@@ -616,25 +618,32 @@ if ($result) {
{
print '
';
$s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
- $shelp = '';
+ $shelp = ''; $ttype = 'help';
if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountfor == 'eecwithvat') $shelp = $langs->trans("SaleEECWithVAT");
- elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $shelp = $langs->trans("SaleEECWithoutVATNumber");
+ elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') {
+ $shelp = $langs->trans("SaleEECWithoutVATNumber");
+ $ttype = 'warning';
+ }
elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport");
$s .= (empty($objp->code_sell_p) ? ''.$langs->trans("NotDefined").'' : length_accountg($objp->code_sell_p));
- print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
+ print $form->textwithpicto($s, $shelp, 1, $ttype, '', 0, 2, '', 1);
} else {
+ if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
+ print '
';
+ $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
+ $shelp = '';
+ $s .= $langs->trans("NotDefined");
+ print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
+ }
+ }
+ if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
print '
';
- $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
+ $s = '3. '.(($objp->type_l == 1) ? $langs->trans("ServiceForThisThirdparty") : $langs->trans("ProductForThisThirdparty")).': ';
$shelp = '';
- $s .= $langs->trans("NotDefined");
+ $s .= ($objp->code_sell_t > 0 ? length_accountg($objp->code_sell_t) : ''.$langs->trans("NotDefined").'');
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
}
- print '
';
- $s = '3. '.(($objp->type_l == 1) ? $langs->trans("ServiceForThisThirdparty") : $langs->trans("ProductForThisThirdparty")).': ';
- $shelp = '';
- $s .= ($objp->code_sell_t > 0 ? length_accountg($objp->code_sell_t) : ''.$langs->trans("NotDefined").'');
- print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
print '';
// Suggested accounting account
diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php
index 2f0ae952ba7..3b06cf275a5 100644
--- a/htdocs/societe/card.php
+++ b/htdocs/societe/card.php
@@ -489,8 +489,8 @@ if (empty($reshook))
$object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
$object->webservices_key = GETPOST('webservices_key', 'san_alpha');
- $object->accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
- $object->accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
+ if (GETPOSTISSET('accountancy_code_sell')) $object->accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
+ if (GETPOSTISSET('accountancy_code_buy')) $object->accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
// Incoterms
if (!empty($conf->incoterm->enabled))
@@ -1062,8 +1062,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$object->commercial_id = GETPOST('commercial_id', 'int');
$object->default_lang = GETPOST('default_lang');
- $object->accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
- $object->accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
+ if (GETPOSTISSET('accountancy_code_sell')) $object->accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
+ if (GETPOSTISSET('accountancy_code_buy')) $object->accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
$object->logo = (isset($_FILES['photo']) ?dol_sanitizeFileName($_FILES['photo']['name']) : '');
@@ -1614,37 +1614,40 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print ''."\n";
// Accountancy codes
- print '
';
+ if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
+ print '';
- if (! empty($conf->accounting->enabled))
- {
- // Accountancy_code_sell
- print '| '.$langs->trans("ProductAccountancySellCode").' | ';
- print '';
- $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
- print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, null, 1, 1, '');
- print ' |
';
+ if (! empty($conf->accounting->enabled))
+ {
+ // Accountancy_code_sell
+ print '| '.$langs->trans("ProductAccountancySellCode").' | ';
+ print '';
+ $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
+ print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, null, 1, 1, '');
+ print ' |
';
- // Accountancy_code_buy
- print '| '.$langs->trans("ProductAccountancyBuyCode").' | ';
- print '';
- $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
- print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, null, 1, 1, '');
- print ' |
';
+ // Accountancy_code_buy
+ print '| '.$langs->trans("ProductAccountancyBuyCode").' | ';
+ print '';
+ $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
+ print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, null, 1, 1, '');
+ print ' |
';
+ }
+ else // For external software
+ {
+ // Accountancy_code_sell
+ print '| '.$langs->trans("ProductAccountancySellCode").' | ';
+ print '';
+ print ' |
';
+
+ // Accountancy_code_buy
+ print '| '.$langs->trans("ProductAccountancyBuyCode").' | ';
+ print '';
+ print ' |
';
+ }
+
+ print '
';
}
- else // For external software
- {
- // Accountancy_code_sell
- print '| '.$langs->trans("ProductAccountancySellCode").' | ';
- print '';
- print ' |
';
-
- // Accountancy_code_buy
- print '| '.$langs->trans("ProductAccountancyBuyCode").' | ';
- print '';
- print ' |
';
- }
- print '
';
print dol_get_fiche_end();
@@ -1760,8 +1763,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
$object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
$object->webservices_key = GETPOST('webservices_key', 'san_alpha');
- $object->accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
- $object->accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
+ if (GETPOSTISSET('accountancy_code_sell')) $object->accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
+ if (GETPOSTISSET('accountancy_code_buy')) $object->accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
//Incoterms
if (!empty($conf->incoterm->enabled))
@@ -2294,37 +2297,39 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print '';
- print '
';
+ if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
+ print '
';
+ print '';
- print '';
+ if (! empty($conf->accounting->enabled))
+ {
+ // Accountancy_code_sell
+ print '| '.$langs->trans("ProductAccountancySellCode").' | ';
+ print '';
+ print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1);
+ print ' |
';
- if (! empty($conf->accounting->enabled))
- {
- // Accountancy_code_sell
- print '| '.$langs->trans("ProductAccountancySellCode").' | ';
- print '';
- print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1);
- print ' |
';
+ // Accountancy_code_buy
+ print '| '.$langs->trans("ProductAccountancyBuyCode").' | ';
+ print '';
+ print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1);
+ print ' |
';
+ }
+ else // For external software
+ {
+ // Accountancy_code_sell
+ print '| '.$langs->trans("ProductAccountancySellCode").' | ';
+ print '';
+ print ' |
';
- // Accountancy_code_buy
- print '| '.$langs->trans("ProductAccountancyBuyCode").' | ';
- print '';
- print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1);
- print ' |
';
+ // Accountancy_code_buy
+ print '| '.$langs->trans("ProductAccountancyBuyCode").' | ';
+ print '';
+ print ' |
';
+ }
+ print '
';
}
- else // For external software
- {
- // Accountancy_code_sell
- print '| '.$langs->trans("ProductAccountancySellCode").' | ';
- print '';
- print ' |
';
- // Accountancy_code_buy
- print '| '.$langs->trans("ProductAccountancyBuyCode").' | ';
- print '';
- print ' |
';
- }
- print '
';
print '';
print dol_get_fiche_end();
@@ -2705,41 +2710,43 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print '';
}
- // Accountancy sell code
- print '| ';
- print $langs->trans("ProductAccountancySellCode");
- print ' | ';
- if (! empty($conf->accounting->enabled))
- {
- if (! empty($object->accountancy_code_sell))
+ if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
+ // Accountancy sell code
+ print ' |
| ';
+ print $langs->trans("ProductAccountancySellCode");
+ print ' | ';
+ if (! empty($conf->accounting->enabled))
{
- $accountingaccount = new AccountingAccount($db);
- $accountingaccount->fetch('', $object->accountancy_code_sell, 1);
+ if (! empty($object->accountancy_code_sell))
+ {
+ $accountingaccount = new AccountingAccount($db);
+ $accountingaccount->fetch('', $object->accountancy_code_sell, 1);
- print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
+ print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
+ }
+ } else {
+ print $object->accountancy_code_sell;
}
- } else {
- print $object->accountancy_code_sell;
- }
- print ' |
';
+ print '';
- // Accountancy buy code
- print '| ';
- print $langs->trans("ProductAccountancyBuyCode");
- print ' | ';
- if (! empty($conf->accounting->enabled))
- {
- if (! empty($object->accountancy_code_buy))
+ // Accountancy buy code
+ print ' |
| ';
+ print $langs->trans("ProductAccountancyBuyCode");
+ print ' | ';
+ if (! empty($conf->accounting->enabled))
{
- $accountingaccount2 = new AccountingAccount($db);
- $accountingaccount2->fetch('', $object->accountancy_code_buy, 1);
+ if (! empty($object->accountancy_code_buy))
+ {
+ $accountingaccount2 = new AccountingAccount($db);
+ $accountingaccount2->fetch('', $object->accountancy_code_buy, 1);
- print $accountingaccount2->getNomUrl(0, 1, 1, '', 1);
+ print $accountingaccount2->getNomUrl(0, 1, 1, '', 1);
+ }
+ } else {
+ print $object->accountancy_code_buy;
}
- } else {
- print $object->accountancy_code_buy;
+ print ' |
';
}
- print '';
// Other attributes
$parameters = array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');