From 9f890c28ddbb052551bb78e14bd56ffcec23e57b Mon Sep 17 00:00:00 2001 From: atm-greg Date: Mon, 29 Oct 2018 15:37:17 +0100 Subject: [PATCH] add ability to edit price ht before adding a line --- htdocs/core/tpl/objectline_create.tpl.php | 18 ++++++++++++++++-- htdocs/langs/en_US/admin.lang | 1 + htdocs/product/admin/product.php | 11 +++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 23640216cd9..5430eb0ad46 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -646,8 +646,19 @@ jQuery(document).ready(function() { setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva jQuery('#trlinefordates').show(); - + global->EDIT_PREDEF_PRICEHT)) + { + ?> + // get the HT price for the product and display it + $.post('/product/ajax/products.php?action=fetch', { 'id': $(this).val(), 'socid' : socid; ?> }, function(data) { + jQuery("#price_ht").val(data.price_ht); + }, + 'json'); + rights->margins->creer) { $langs->load('stocks'); @@ -831,7 +842,10 @@ function setforpredef() { jQuery("#prod_entry_mode_free").prop('checked',false).change(); jQuery("#prod_entry_mode_predef").prop('checked',true).change(); - jQuery("#price_ht").val('').hide(); + global->EDIT_PREDEF_PRICEHT)) + {?> + jQuery("#price_ht").val('').hide(); + jQuery("#multicurrency_price_ht").hide(); jQuery("#price_ttc").hide(); // May no exists jQuery("#fourn_ref").hide(); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 190b7cded97..ba6989d6288 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1447,6 +1447,7 @@ ServiceSetup=Services module setup ProductServiceSetup=Products and Services modules setup NumberOfProductShowInSelect=Max number of products in combos select lists (0=no limit) ViewProductDescInFormAbility=Display product descriptions in forms (otherwise as popup tooltip) +EditPredifinedPriceHTAbility=Add the ability to edit price ht before adding a line on documents MergePropalProductCard=Activate in product/service Attached Files tab an option to merge product PDF document to proposal PDF azur if product/service is in the proposal ViewProductDescInThirdpartyLanguageAbility=Display products descriptions in the language of the third party UseSearchToSelectProductTooltip=Also if you have a large number of products (> 100 000), you can increase speed by setting constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 45f938431c3..a8116314dda 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -155,6 +155,9 @@ if ($action == 'other') $resql_new = $db->query($sql_new); } } + + $value = GETPOST('activate_EditPredifinedPriceHT','alpha'); + $res = dolibarr_set_const($db, "EDIT_PREDEF_PRICEHT", $value,'chaine',0,'',$conf->entity); } if ($action == 'specimen') // For products @@ -675,6 +678,14 @@ if (! empty($conf->fournisseur->enabled)) print ''; } +// Activate price ht edition for predefined product on line add +print ''; +print ''.$langs->trans("EditPredifinedPriceHTAbility").''; +print ''; +print $form->selectyesno("activate_EditPredifinedPriceHT",$conf->global->EDIT_PREDEF_PRICEHT,1); +print ''; +print ''; + if (! empty($conf->global->PRODUCT_CANVAS_ABILITY)) { // Add canvas feature