diff --git a/ChangeLog b/ChangeLog index b8aa6195d61..7905186faaa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -101,6 +101,9 @@ parameter. All methods addline in this case were modified to remove this paramet ***** ChangeLog for 3.4.1 compared to 3.4.0 ***** +Fix: Display buying price on line edit when no supplier price is defined +Fix: Retrieving of margin info when invoice created automatically from order +Fix: Reordering supplier products in list by supplier or supplier ref was crashing Fix: [ bug #1029 ] Tulip numbering mask Fix: Supplier invoice and supplier order are not displayed into object link into agenda event card Fix: [ bug #1033 ] SUPPLIER REF disappeared @@ -108,7 +111,8 @@ Fix: update extrafield do not display immediatly after update Fix: Fix bug with canvas thirdparty Fix: [ bug #1037 ] Consumption> Supplier invoices related Fix: User group name do not display in card (view or edit mode) - +Fix: Link "Show all supplier invoice" on suplier card not working +Fix: [ bug #1039 ] Pre-defined invoices conversion ***** ChangeLog for 3.4 compared to 3.3.* ***** For users: diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index df8b7e5a517..61385ed5f89 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -2,7 +2,8 @@ /* Copyright (C) 2002-2003 Rodolphe Quiedeville * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Juanjo Menent * * 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 @@ -115,7 +116,7 @@ if ($action == 'create') { print_fiche_titre($langs->trans("CreateRepeatableInvoice")); - $object = new FactureRec($db); // Source invoice + $object = new Facture($db); // Source invoice $product_static = new Product($db); if ($object->fetch($id) > 0) @@ -602,4 +603,4 @@ else llxFooter(); $db->close(); -?> \ No newline at end of file +?> diff --git a/htdocs/core/tpl/objectline_add.tpl.php b/htdocs/core/tpl/objectline_add.tpl.php index 5f4c83a1a71..6e1c3c687f9 100644 --- a/htdocs/core/tpl/objectline_add.tpl.php +++ b/htdocs/core/tpl/objectline_add.tpl.php @@ -41,17 +41,31 @@ if (! empty($conf->margin->enabled)) { ?> trans('BuyingPrice'); ?> global->DISPLAY_MARGIN_RATES)) { - $colspan++; - $colspan2++; - } - if (! empty($conf->global->DISPLAY_MARK_RATES)) { - $colspan++; - $colspan2++; - } - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - $colspan2++; - } + if ($user->rights->margins->creer) + { + if(! empty($conf->global->DISPLAY_MARGIN_RATES)) + { + echo ''.$langs->trans('MarginRate').''; + } + if(! empty($conf->global->DISPLAY_MARK_RATES)) + { + echo ''.$langs->trans('MarkRate').''; + } + } + else + { + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { + $colspan++; + $colspan2++; + } + if (! empty($conf->global->DISPLAY_MARK_RATES)) { + $colspan++; + $colspan2++; + } + } + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + $colspan2++; + } } ?>   @@ -164,21 +178,35 @@ if (! empty($conf->margin->enabled)) { % -margin->enabled)) { -?> - - - - -global->DISPLAY_MARGIN_RATES)) - $colspan++; - if (! empty($conf->global->DISPLAY_MARK_RATES)) - $colspan++; -} -?> + margin->enabled)) { + ?> + + + + + rights->margins->creer) + { + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { + echo '%'; + } + elseif (! empty($conf->global->DISPLAY_MARK_RATES)) { + echo '%'; + } + } + else + { + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { + $colspan++; + } + if (! empty($conf->global->DISPLAY_MARK_RATES)) { + $colspan++; + } + } + } + ?> @@ -188,12 +216,7 @@ if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 12; else $colspan = 11; -if (! empty($conf->margin->enabled)) { - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - $colspan++; - if (! empty($conf->global->DISPLAY_MARK_RATES)) - $colspan++; -} + ?> > @@ -491,11 +514,7 @@ $(document).ready(function() { }); -}); - - margin->enabled)) { ?> - + var npRate = null; +global->DISPLAY_MARGIN_RATES)) { ?> + npRate = "np_marginRate"; + global->DISPLAY_MARK_RATES)) { ?> + npRate = "np_markRate"; + + +$("form#addproduct").submit(function(e) { + if (npRate) return checkFreeLine(e, npRate); + else return true; +}); +if (npRate == 'np_marginRate') { + $("input[name='np_marginRate']:first").blur(function(e) { + return checkFreeLine(e, npRate); + }); +} +else { + if (npRate == 'np_markRate') { + $("input[name='np_markRate']:first").blur(function(e) { + return checkFreeLine(e, npRate); + }); + } +} + +function checkFreeLine(e, npRate) +{ + var buying_price = $("input[name='buying_price']:first"); + var remise = $("input[name='remise_percent']:first"); + + var rate = $("input[name='"+npRate+"']:first"); + if (rate.val() == '') + return true; + if (! $.isNumeric(rate.val().replace(',','.'))) + { + alert('trans("rateMustBeNumeric"); ?>'); + e.stopPropagation(); + setTimeout(function () { rate.focus() }, 50); + return false; + } + if (npRate == "np_markRate" && rate.val() >= 100) + { + alert('trans("markRateShouldBeLesserThan100"); ?>'); + e.stopPropagation(); + setTimeout(function () { rate.focus() }, 50); + return false; + } + + var np_price = 0; + if (remise.val().replace(',','.') != 100) + { + if (npRate == "np_marginRate") + np_price = ((buying_price.val().replace(',','.') * (1 + rate.val().replace(',','.') / 100)) / (1 - remise.val().replace(',','.') / 100)); + else { + if (npRate == "np_markRate") + np_price = ((buying_price.val().replace(',','.') / (1 - rate.val().replace(',','.') / 100)) / (1 - remise.val().replace(',','.') / 100)); + } + } + $("input[name='price_ht']:first").val(formatFloat(np_price)); + update_price('price_ht', 'price_ttc'); + + return true; +} +function roundFloat(num) { + var main_max_dec_shown = global->MAIN_MAX_DECIMALS_SHOWN; ?>; + var main_rounding = global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); ?>; + + var amount = num.toString().replace(',','.'); // should be useless + var nbdec = 0; + var rounding = main_rounding; + var pos = amount.indexOf('.'); + var decpart = ''; + if (pos >= 0) + decpart = amount.substr(pos+1).replace('/0+$/i',''); // Supprime les 0 de fin de partie decimale + nbdec = decpart.length; + if (nbdec > rounding) + rounding = nbdec; + // Si on depasse max + if (rounding > main_max_dec_shown) + { + rounding = main_max_dec_shown; + } + //amount = parseFloat(amount) + (1 / Math.pow(100, rounding)); // to avoid floating-point errors + return parseFloat(amount).toFixed(rounding); +} + +function formatFloat(num) { + return roundFloat(num).replace('.', ','); +} +}); + + diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 328964bc0df..ac05f71b901 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -28,7 +28,7 @@ ?> -
id; ?>" method="POST"> +id; ?>" method="POST"> @@ -133,11 +133,25 @@ if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { margin->enabled)) { ?> - - - - - + + + + + rights->margins->creer) { + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) + { + $margin_rate = (isset($_POST["marginRate"])?$_POST["marginRate"]:(($line->pa_ht == 0)?'':price($line->marge_tx))); + echo '%'; + $coldisplay++; + } + elseif (! empty($conf->global->DISPLAY_MARK_RATES)) + { + $mark_rate = (isset($_POST["markRate"])?$_POST["markRate"]:price($line->marque_tx)); + echo '%'; + $coldisplay++; + } + } + } ?> ">
@@ -386,5 +400,96 @@ $(document).ready(function() { }, 'json'); }); + var npRate = null; +global->DISPLAY_MARGIN_RATES)) { ?> + npRate = "marginRate"; + global->DISPLAY_MARK_RATES)) { ?> + npRate = "markRate"; + + +$("form#editproduct").submit(function(e) { + if (npRate) return checkEditLine(e, npRate); + else return true; +}); +if (npRate == 'marginRate') { + $("input[name='marginRate']:first").blur(function(e) { + return checkEditLine(e, npRate); + }); +} +else { + if (npRate == 'markRate') { + $("input[name='markRate']:first").blur(function(e) { + return checkEditLine(e, npRate); + }); + } +} + +function checkEditLine(e, npRate) +{ + var buying_price = $("input[name='buying_price']:first"); + var remise = $("input[name='remise_percent']:first"); + + var rate = $("input[name='"+npRate+"']:first"); + if (rate.val() == '') + return true; + if (! $.isNumeric(rate.val().replace(',','.'))) + { + alert('trans("rateMustBeNumeric"); ?>'); + e.stopPropagation(); + setTimeout(function () { rate.focus() }, 50); + return false; + } + if (npRate == "markRate" && rate.val() >= 100) + { + alert('trans("markRateShouldBeLesserThan100"); ?>'); + e.stopPropagation(); + setTimeout(function () { rate.focus() }, 50); + return false; + } + + var price = 0; + if (remise.val().replace(',','.') != 100) + { + if (npRate == "marginRate") + price = ((buying_price.val().replace(',','.') * (1 + rate.val().replace(',','.') / 100)) / (1 - remise.val().replace(',','.') / 100)); + else { + if (npRate == "markRate") + price = ((buying_price.val().replace(',','.') / (1 - rate.val().replace(',','.') / 100)) / (1 - remise.val().replace(',','.') / 100)); + } + } + $("input[name='price_ht']:first").val(formatFloat(price)); + + return true; +} +function roundFloat(num) { + var main_max_dec_shown = global->MAIN_MAX_DECIMALS_SHOWN; ?>; + var main_rounding = global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); ?>; + + var amount = num.toString().replace(',','.'); // should be useless + var nbdec = 0; + var rounding = main_rounding; + var pos = amount.indexOf('.'); + var decpart = ''; + if (pos >= 0) + decpart = amount.substr(pos+1).replace('/0+$/i',''); // Supprime les 0 de fin de partie decimale + nbdec = decpart.length; + if (nbdec > rounding) + rounding = nbdec; + // Si on depasse max + if (rounding > main_max_dec_shown) + { + rounding = main_max_dec_shown; + } + //amount = parseFloat(amount) + (1 / Math.pow(100, rounding)); // to avoid floating-point errors + return parseFloat(amount).toFixed(rounding); +} + +function formatFloat(num) { + return roundFloat(num).replace('.', ','); +} + diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index a5a4abcd440..fb16e5cbadf 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -755,7 +755,7 @@ class Export global $conf, $langs; $sql = "SELECT em.rowid, em.field, em.label, em.type, em.filter"; - $sql.= " FROM ".MAIN_DB_PREFIX."export_model"; + $sql.= " FROM ".MAIN_DB_PREFIX."export_model as em"; $sql.= " ORDER BY rowid"; $result = $this->db->query($sql); diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index 029f135a653..b19ddb2996f 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -114,8 +114,8 @@ if (! empty($idprod)) $db->free($result); } } - - echo json_encode($prices); } +echo json_encode($prices); + ?> diff --git a/htdocs/fourn/fiche.php b/htdocs/fourn/fiche.php index c1bb8ede5a2..f813d720569 100644 --- a/htdocs/fourn/fiche.php +++ b/htdocs/fourn/fiche.php @@ -396,7 +396,7 @@ if ($object->fetch($id)) print ''; print ''; - print ''; + print '
'.$langs->trans('LastSuppliersBills',($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans('AllBills').' ('.$num.')
'; print ''; print '
'.$langs->trans('LastSuppliersBills',($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans('AllBills').' ('.$num.')'.img_picto($langs->trans("Statistics"),'stats').'
'; print ''; diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index bb12125a345..459537e1506 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -160,7 +160,7 @@ if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPr if ($agentid > 0) $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname, f.type"; else - $sql.= " GROUP BY u.rowid, s.nom, s.rowid, s.code_client, s.client, u.login, u.lastname, u.firstname, f.type "; + $sql.= " GROUP BY u.rowid"; $sql.= " ORDER BY $sortfield $sortorder "; // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 67bf8cef506..484f86ad9e0 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -178,7 +178,7 @@ if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPr if ($client) $sql.= " GROUP BY f.rowid, s.rowid, s.nom, s.code_client, s.client, f.facnumber, f.total, f.datef, f.paye, f.fk_statut, f.type "; else - $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.facnumber, f.total, f.datef, f.paye, f.fk_statut, f.rowid, f.type "; + $sql.= " GROUP BY s.rowid"; $sql.= " ORDER BY $sortfield $sortorder "; // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); @@ -293,7 +293,7 @@ $db->close();