diff --git a/dev/initdemo/updatedemo.php b/dev/initdemo/updatedemo.php index 84abd12c6d0..9c453096904 100755 --- a/dev/initdemo/updatedemo.php +++ b/dev/initdemo/updatedemo.php @@ -68,6 +68,7 @@ $tables=array( 'facture'=>array(0=>'datef', 1=>'date_valid', 2=>'date_lim_reglement'), 'paiement'=>array(0=>'datep'), 'bank'=>array(0=>'datev', 1=>'dateo'), + 'commande_fournisseur'=>array(0=>'date_commande', 1=>'date_valid', 3=>'date_creation', 4=>'date_approve', 5=>'date_approve2', 6=>'date_livraison'), 'supplier_proposal'=>array(0=>'datec', 1=>'date_valid', 2=>'date_cloture') ); diff --git a/htdocs/langs/en_US/margins.lang b/htdocs/langs/en_US/margins.lang index 12a61c146be..64e1a87864d 100644 --- a/htdocs/langs/en_US/margins.lang +++ b/htdocs/langs/en_US/margins.lang @@ -41,3 +41,4 @@ rateMustBeNumeric=Rate must be a numeric value markRateShouldBeLesserThan100=Mark rate should be lower than 100 ShowMarginInfos=Show margin infos CheckMargins=Margins detail +MarginPerSaleRepresentativeWarning=The report of margin per user use the link between thirdparties and sale representatives to calculate the margin of each user. Because some thirdparties may not be linked to any sale representative and some thirdparties may be linked to several users, some margins may not appears in these report or may appears in several different lines. diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index e9142d463ff..e7924c56cf7 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -59,6 +59,8 @@ SellingPriceHT=Selling price (net of tax) SellingPriceTTC=Selling price (inc. tax) CostPriceDescription=This price (net of tax) can be used to store the average amount this product cost to your company. It may be any price you calculate yourself, for example from the average buying price plus average production and distribution cost. CostPriceUsage=In a future version, this value could be used for margin calculation. +SoldAmount=Sold amount +PurchasedAmount=Purchased amount NewPrice=New price MinPrice=Min. selling price CantBeLessThanMinPrice=The selling price can't be lower than minimum allowed for this product (%s without tax). This message can also appears if you type a too important discount. diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 3b31cee302b..0cd8243f7a8 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -91,12 +91,10 @@ dol_fiche_head($head, 'agentMargins', $titre, 0, $picto); print '
'; print ''; -if ($user->rights->margins->read->all) { - print ''; - print ''; -} +print ''; +print ''; // Start date print ''; @@ -153,6 +151,11 @@ $sql.=$db->order($sortfield,$sortorder); // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); + +print '
'; +print img_info('').' '.$langs->trans("MarginPerSaleRepresentativeWarning").'
'; + + dol_syslog('margin::agentMargins.php', LOG_DEBUG); $result = $db->query($sql); if ($result) diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 83e173ca0ce..7f6d5a951c2 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -261,7 +261,7 @@ if ($result) $companystatic->id=$objp->socid; $companystatic->name=$objp->name; $companystatic->client=$objp->client; - print "\n"; + print "\n"; } print "\n"; @@ -282,16 +282,16 @@ if ($result) // affichage totaux marges $var=!$var; $totalMargin = $cumul_vente - $cumul_achat; - if ($totalMargin < 0) + /*if ($totalMargin < 0) { $marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):''; $markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):''; } else - { + {*/ $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; $markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):''; - } + //} print ''; if ($client) diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index d604ed5ed22..b4609633447 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -295,16 +295,16 @@ if ($result) // affichage totaux marges $var=!$var; $totalMargin = $cumul_vente - $cumul_achat; - if ($totalMargin < 0) + /*if ($totalMargin < 0) { $marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):''; $markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):''; } else - { + {*/ $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; $markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):''; - } + //} print ''; if ($id > 0) print ''; print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&socid=".$_REQUEST["socid"],'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&socid=".$_REQUEST["socid"],'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buying_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("SoldAmount"),$_SERVER["PHP_SELF"],"selling_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PurchasedAmount"),$_SERVER["PHP_SELF"],"buying_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder); @@ -221,8 +221,8 @@ if ($socid > 0) print ''; print "\n"; $i++; - $cumul_achat += $objp->buying_price; $cumul_vente += $objp->selling_price; + $cumul_achat += ($objp->type == 2 ? -1 : 1) * $objp->buying_price; } } @@ -239,6 +239,8 @@ if ($socid > 0) $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; $markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):''; } + + // Total print ''; print '"; print "\n"; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 39c1f494d31..b3205d3fb44 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1869,7 +1869,12 @@ class Societe extends CommonObject $label.= '' . $langs->trans("ShowCategorySupplier") . ''; $link = ''; + $link = '
'.$langs->trans('SalesRepresentative').''; - print $form->select_dolusers($agentid, 'agentid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - print '
'.$langs->trans('SalesRepresentative').''; +print $form->select_dolusers($agentid, 'agentid', 1, '', $user->rights->margins->read->all ? 0 : 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); +print '
'.$langs->trans('DateStart').' ('.$langs->trans("DateValidation").')".$companystatic->getNomUrl(1,'customer')."".$companystatic->getNomUrl(1,'margin')."".price($pv, null, null, null, null, $rounding)."
'; diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 369d226414a..35bd8e85155 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -225,7 +225,7 @@ if ($id > 0 || ! empty($ref)) $markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):''; } else - { + { $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; $markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):''; } diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index cd12539c2f7..29bdd16b21e 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -176,8 +176,8 @@ if ($socid > 0) print '
'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'
'.$langs->trans('TotalMargin')."".price($cumul_vente, null, null, null, null, $rounding)."