From e5c2027dbb69d16eefcc28ae03104f32f30a9685 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Apr 2019 01:16:29 +0200 Subject: [PATCH] NEW Add accounting code for eec sales and export sales on products --- htdocs/core/class/extrafields.class.php | 2 +- htdocs/langs/en_US/products.lang | 2 +- htdocs/product/card.php | 119 +++++++++++------------- htdocs/product/list.php | 46 +++++++-- 4 files changed, 94 insertions(+), 75 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 865aa50b679..26acdf50fcc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1837,7 +1837,7 @@ class ExtraFields $out=''; // Only if something to display (perf) - if ($value) // If we have -1 here, pb is into sert, not into ouptu + if ($value) // If we have -1 here, pb is into insert, not into ouptut (fix insert instead of changing code here to compensate) { $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 3304ab3b3ef..e69d771fa79 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -294,7 +294,7 @@ ProductSheet=Product sheet ServiceSheet=Service sheet PossibleValues=Possible values GoOnMenuToCreateVairants=Go on menu %s - %s to prepare attribute variants (like colors, size, ...) -UseProductFournDesc=Use vendor descriptions of products in vendor documents +UseProductFournDesc=Add a feature to define the descriptions of products defined by the vendors in addition to descriptions for customers ProductSupplierDescription=Vendor description for the product #Attributes VariantAttributes=Variant attributes diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 50c0d4ab5c9..2c8b70efbd1 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1218,21 +1218,19 @@ else print ''; print ''; - if ($conf->global->MAIN_FEATURES_LEVEL) + // Accountancy_code_sell_intra + if ($mysoc->isInEEC()) { - // Accountancy_code_sell_intra - if ($mysoc->isInEEC()) { - print ''.$langs->trans("ProductAccountancySellIntraCode").''; - print ''; - print ''; - } - - // Accountancy_code_sell_export - print ''.$langs->trans("ProductAccountancySellExportCode").''; - print ''; + print ''.$langs->trans("ProductAccountancySellIntraCode").''; + print ''; print ''; } + // Accountancy_code_sell_export + print ''.$langs->trans("ProductAccountancySellExportCode").''; + print ''; + print ''; + // Accountancy_code_buy print ''.$langs->trans("ProductAccountancyBuyCode").''; print ''; @@ -1514,24 +1512,21 @@ else print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1); print ''; - if ($conf->global->MAIN_FEATURES_LEVEL) + // Accountancy_code_sell_intra + if ($mysoc->isInEEC()) { - // Accountancy_code_sell_intra - if ($mysoc->isInEEC()) - { - print ''.$langs->trans("ProductAccountancySellIntraCode").''; - print ''; - print $formaccounting->select_account($object->accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, '', 1, 1); - print ''; - } - - // Accountancy_code_sell_export - print ''.$langs->trans("ProductAccountancySellExportCode").''; + print ''.$langs->trans("ProductAccountancySellIntraCode").''; print ''; - print $formaccounting->select_account($object->accountancy_code_sell_export, 'accountancy_code_sell_export', 1, '', 1, 1); + print $formaccounting->select_account($object->accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, '', 1, 1); print ''; } + // Accountancy_code_sell_export + print ''.$langs->trans("ProductAccountancySellExportCode").''; + print ''; + print $formaccounting->select_account($object->accountancy_code_sell_export, 'accountancy_code_sell_export', 1, '', 1, 1); + print ''; + // Accountancy_code_buy print ''.$langs->trans("ProductAccountancyBuyCode").''; print ''; @@ -1545,22 +1540,19 @@ else print ''; print ''; - if ($conf->global->MAIN_FEATURES_LEVEL) + // Accountancy_code_sell_intra + if ($mysoc->isInEEC()) { - // Accountancy_code_sell_intra - if ($mysoc->isInEEC()) - { - print ''.$langs->trans("ProductAccountancySellIntraCode").''; - print ''; - print ''; - } - - // Accountancy_code_sell_export - print ''.$langs->trans("ProductAccountancySellExportCode").''; - print ''; + print ''.$langs->trans("ProductAccountancySellIntraCode").''; + print ''; print ''; } + // Accountancy_code_sell_export + print ''.$langs->trans("ProductAccountancySellExportCode").''; + print ''; + print ''; + // Accountancy_code_buy print ''.$langs->trans("ProductAccountancyBuyCode").''; print ''; @@ -1687,48 +1679,45 @@ else } print ''; - if ($conf->global->MAIN_FEATURES_LEVEL) + // Accountancy sell code intra-community + if ($mysoc->isInEEC()) { - // Accountancy sell code intra-community - if ($mysoc->isInEEC()) - { - print ''; - print $langs->trans("ProductAccountancySellIntraCode"); - print ''; - if (! empty($conf->accounting->enabled)) - { - if (! empty($object->accountancy_code_sell_intra)) - { - $accountingaccount2 = new AccountingAccount($db); - $accountingaccount2->fetch('', $object->accountancy_code_sell_intra, 1); - - print $accountingaccount2->getNomUrl(0, 1, 1, '', 1); - } - } else { - print $object->accountancy_code_sell_intra; - } - print ''; - } - - // Accountancy sell code export print ''; - print $langs->trans("ProductAccountancySellExportCode"); + print $langs->trans("ProductAccountancySellIntraCode"); print ''; if (! empty($conf->accounting->enabled)) { - if (! empty($object->accountancy_code_sell_export)) + if (! empty($object->accountancy_code_sell_intra)) { - $accountingaccount3 = new AccountingAccount($db); - $accountingaccount3->fetch('', $object->accountancy_code_sell_export, 1); + $accountingaccount2 = new AccountingAccount($db); + $accountingaccount2->fetch('', $object->accountancy_code_sell_intra, 1); - print $accountingaccount3->getNomUrl(0, 1, 1, '', 1); + print $accountingaccount2->getNomUrl(0, 1, 1, '', 1); } } else { - print $object->accountancy_code_sell_export; + print $object->accountancy_code_sell_intra; } print ''; } + // Accountancy sell code export + print ''; + print $langs->trans("ProductAccountancySellExportCode"); + print ''; + if (! empty($conf->accounting->enabled)) + { + if (! empty($object->accountancy_code_sell_export)) + { + $accountingaccount3 = new AccountingAccount($db); + $accountingaccount3->fetch('', $object->accountancy_code_sell_export, 1); + + print $accountingaccount3->getNomUrl(0, 1, 1, '', 1); + } + } else { + print $object->accountancy_code_sell_export; + } + print ''; + // Accountancy buy code print ''; print $langs->trans("ProductAccountancyBuyCode"); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 56d8b0bc504..39e98730365 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -62,6 +62,8 @@ $fourn_id = GETPOST("fourn_id", 'int'); $catid = GETPOST('catid', 'int'); $search_tobatch = GETPOST("search_tobatch", 'int'); $search_accountancy_code_sell = GETPOST("search_accountancy_code_sell", 'alpha'); +$search_accountancy_code_sell_intra = GETPOST("search_accountancy_code_sell_intra", 'alpha'); +$search_accountancy_code_sell_export = GETPOST("search_accountancy_code_sell_export", 'alpha'); $search_accountancy_code_buy = GETPOST("search_accountancy_code_buy", 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $type=GETPOST("type", "int"); @@ -154,6 +156,8 @@ if (empty($conf->global->PRODUIT_MULTIPRICES)) } } +$isInEEC=isInEEC($mysoc); + // Definition of fields for lists $arrayfields=array( 'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), @@ -175,8 +179,10 @@ $arrayfields=array( 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), 'stock_virtual'=>array('label'=>$langs->trans("VirtualStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service' && $virtualdiffersfromphysical)), 'p.tobatch'=>array('label'=>$langs->trans("ManageLotSerial"), 'checked'=>0, 'enabled'=>(! empty($conf->productbatch->enabled))), - 'p.accountancy_code_sell'=>array('label'=>$langs->trans("ProductAccountancySellCode"), 'checked'=>0), - 'p.accountancy_code_buy'=>array('label'=>$langs->trans("ProductAccountancyBuyCode"), 'checked'=>0), + 'p.accountancy_code_sell'=>array('label'=>$langs->trans("ProductAccountancySellCode"), 'checked'=>0, 'position'=>400), + 'p.accountancy_code_sell_intra'=>array('label'=>$langs->trans("ProductAccountancySellIntraCode"), 'checked'=>0, 'enabled'=>$isInEEC, 'position'=>401), + 'p.accountancy_code_sell_export'=>array('label'=>$langs->trans("ProductAccountancySellExportCode"), 'checked'=>0, 'position'=>402), + 'p.accountancy_code_buy'=>array('label'=>$langs->trans("ProductAccountancyBuyCode"), 'checked'=>0, 'position'=>403), 'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), 'p.tosell'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Sell").')', 'checked'=>1, 'position'=>1000), @@ -227,6 +233,8 @@ if (empty($reshook)) $show_childproducts = ''; $search_accountancy_code_sell=''; + $search_accountancy_code_sell_intra=''; + $search_accountancy_code_sell_export=''; $search_accountancy_code_buy=''; $search_array_options=array(); } @@ -321,8 +329,10 @@ if ($search_categ > 0) $sql.= " AND cp.fk_categorie = ".$db->escape($search_ca if ($search_categ == -2) $sql.= " AND cp.fk_categorie IS NULL"; if ($fourn_id > 0) $sql.= " AND pfp.fk_soc = ".$fourn_id; if ($search_tobatch != '' && $search_tobatch >= 0) $sql.= " AND p.tobatch = ".$db->escape($search_tobatch); -if ($search_accountancy_code_sell) $sql.= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); -if ($search_accountancy_code_buy) $sql.= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); +if ($search_accountancy_code_sell) $sql.= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); +if ($search_accountancy_code_sell_intra) $sql.= natural_search('p.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); +if ($search_accountancy_code_sell_export) $sql.= natural_search('p.accountancy_code_sell_export', $search_accountancy_code_sell_export); +if ($search_accountancy_code_buy) $sql.= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -418,6 +428,8 @@ if ($resql) if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); if ($search_tobatch) $param="&search_ref_supplier=".urlencode($search_ref_supplier); if ($search_accountancy_code_sell) $param="&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell); + if ($search_accountancy_code_sell_intra) $param="&search_accountancy_code_sell_intra=".urlencode($search_accountancy_code_sell_intra); + if ($search_accountancy_code_sell_export) $param="&search_accountancy_code_sell_export=".urlencode($search_accountancy_code_sell_export); if ($search_accountancy_code_buy) $param="&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -630,8 +642,10 @@ if ($resql) // To batch if (! empty($arrayfields['p.tobatch']['checked'])) print ''.$form->selectyesno($search_tobatch, '', '', '', 1).''; // Accountancy code sell - if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; - // Accountancy code sell + if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print ''; + if (! empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) print ''; + if (! empty($arrayfields['p.accountancy_code_sell_export']['checked'])) print ''; + // Accountancy code buy if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -723,7 +737,13 @@ if ($resql) if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) { print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell", "", $param, '', $sortfield, $sortorder); } - if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) { + if (! empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) { + print_liste_field_titre($arrayfields['p.accountancy_code_sell_intra']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell_intra", "", $param, '', $sortfield, $sortorder); + } + if (! empty($arrayfields['p.accountancy_code_sell_export']['checked'])) { + print_liste_field_titre($arrayfields['p.accountancy_code_sell_export']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_sell_export", "", $param, '', $sortfield, $sortorder); + } + if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) { print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_buy", "", $param, '', $sortfield, $sortorder); } // Extra fields @@ -1032,7 +1052,17 @@ if ($resql) print ''.$obj->accountancy_code_sell.''; if (! $i) $totalarray['nbfield']++; } - // Accountancy code sell + if (! empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) + { + print ''.$obj->accountancy_code_sell_intra.''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['p.accountancy_code_sell_export']['checked'])) + { + print ''.$obj->accountancy_code_sell_export.''; + if (! $i) $totalarray['nbfield']++; + } + // Accountancy code buy if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) { print ''.$obj->accountancy_code_buy.'';