*
* This program is free software; you can redistribute it and/or modify
@@ -94,7 +94,7 @@ class FormVentilation extends Form
* @param array $event Event options
* @param int $select_in $selectid value is a aa.rowid (0 default) or aa.account_number (1)
* @param int $select_out set value returned by select 0=rowid (default), 1=account_number
- * @param int $aabase set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by
+ * @param int $aabase set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number
*
* @return string String with HTML select
*/
@@ -126,7 +126,7 @@ class FormVentilation extends Form
if ($num) {
while ( $i < $num ) {
$obj = $this->db->fetch_object($resql);
- $label = $obj->account_number . ' - ' . $obj->label;
+ $label = length_accountg($obj->account_number) . ' - ' . $obj->label;
$label = dol_trunc($label, $trunclength);
if ($select_in == 0 ) $select_value_in = $obj->rowid;
if ($select_in == 1 ) $select_value_in = $obj->account_number;
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index 948f73b21ef..29ab2c0018c 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -43,9 +43,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
-if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
-if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
-if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
+if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
+if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
+if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
$langs->load("products");
$langs->load("other");
@@ -155,6 +157,7 @@ if (empty($reshook))
}
}
+ /*
if ($action == 'setaccountancy_code_buy') {
$result = $object->setAccountancyCode('buy', GETPOST('accountancy_code_buy'));
@@ -168,6 +171,7 @@ if (empty($reshook))
if ($result < 0) setEventMessages(join(',',$object->errors), null, 'errors');
$action="";
}
+ */
// Add a product or service
if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service->creer))
@@ -259,8 +263,12 @@ if (empty($reshook))
$object->volume_units = GETPOST('volume_units');
$object->finished = GETPOST('finished');
$object->fk_unit = GETPOST('units');
- $object->accountancy_code_sell = GETPOST('accountancy_code_sell');
- $object->accountancy_code_buy = GETPOST('accountancy_code_buy');
+
+ $accountancy_code_sell = GETPOST('accountancy_code_sell');
+ $accountancy_code_buy = GETPOST('accountancy_code_buy');
+
+ if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; }
+ if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; }
// MultiPrix
if (! empty($conf->global->PRODUIT_MULTIPRICES))
@@ -369,8 +377,11 @@ if (empty($reshook))
$object->barcode_type_coder = $stdobject->barcode_type_coder;
$object->barcode_type_label = $stdobject->barcode_type_label;
- $object->accountancy_code_sell = GETPOST('accountancy_code_sell');
- $object->accountancy_code_buy = GETPOST('accountancy_code_buy');
+ $accountancy_code_sell = GETPOST('accountancy_code_sell');
+ $accountancy_code_buy = GETPOST('accountancy_code_buy');
+
+ if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell = ''; } else { $object->accountancy_code_sell = $accountancy_code_sell; }
+ if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; }
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
@@ -729,6 +740,7 @@ llxHeader('', $title, $helpurl);
$form = new Form($db);
$formproduct = new FormProduct($db);
+if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
@@ -1013,20 +1025,34 @@ else
}
print '';
+
+ if (! empty($conf->accounting->enabled))
+ {
+ // Accountancy_code_sell
+ print '| '.$langs->trans("ProductAccountancySellCode").' | ';
+ print '';
+ print $formaccountancy->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 0, 1);
+ print ' |
';
- // Accountancy_code_sell
- print '| '.$langs->trans("ProductAccountancySellCode").' | ';
- print '';
- print ' |
';
+ // Accountancy_code_buy
+ print '| '.$langs->trans("ProductAccountancyBuyCode").' | ';
+ print '';
+ print $formaccountancy->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 0, 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 '
';
-
- print '
';
+ // Accountancy_code_buy
+ print '| '.$langs->trans("ProductAccountancyBuyCode").' | ';
+ print '';
+ print ' |
';
+ }
+ print '';
dol_fiche_end();
@@ -1273,14 +1299,24 @@ else
print '
';
- /*if (empty($conf->accounting->enabled) && empty($conf->comptabilite->enabled) && empty($conf->accountingexpert->enabled))
- {
- // Don't show accounting field when accounting id disabled.
- }
- else
- {*/
- print '';
+ print '';
+ if (! empty($conf->accounting->enabled))
+ {
+ // Accountancy_code_sell
+ print '| '.$langs->trans("ProductAccountancySellCode").' | ';
+ print '';
+ print $formaccountancy->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1);
+ print ' |
';
+
+ // Accountancy_code_buy
+ print '| '.$langs->trans("ProductAccountancyBuyCode").' | ';
+ print '';
+ print $formaccountancy->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 '';
@@ -1290,9 +1326,8 @@ else
print ' |
| '.$langs->trans("ProductAccountancyBuyCode").' | ';
print '';
print ' |
';
-
- print '
';
- //}
+ }
+ print '
';
dol_fiche_end();
@@ -1340,7 +1375,7 @@ else
print '| ';
print '';
print ' | ';
@@ -1361,7 +1396,7 @@ else
print ' |
| ';
print '';
print ' | ';
@@ -1382,13 +1417,23 @@ else
}
// Accountancy sell code
- print ' |
| '.$form->editfieldkey("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer,'string').' | ';
- print $form->editfieldval("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer,'string');
+ print ' |
';
+ print '| ';
+ print $langs->trans("ProductAccountancySellCode");
+ print ' | ';
+ print ' ';
+ print ' | ';
+ print length_accountg($object->accountancy_code_sell);
print ' |
';
// Accountancy buy code
- print '| '.$form->editfieldkey("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer,'string').' | ';
- print $form->editfieldval("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer,'string');
+ print ' |
';
+ print '| ';
+ print $langs->trans("ProductAccountancyBuyCode");
+ print ' | ';
+ print ' ';
+ print ' | ';
+ print length_accountg($object->accountancy_code_buy);
print ' |
';
// Status (to sell)