Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2014-09-05 21:12:22 +02:00
commit 7bbeca147b
5 changed files with 134 additions and 34 deletions

View File

@ -240,7 +240,7 @@ if ($action == 'create')
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("Ref").'</td>'; print '<tr><td valign="top" class="fieldrequired" width="25%">'.$langs->trans("Ref").'</td>';
print '<td colspan="3"><input size="8" type="text" class="flat" name="ref" value="'.($_POST["ref"]?$_POST["ref"]:$account->ref).'" maxlength="12"></td></tr>'; print '<td colspan="3"><input size="8" type="text" class="flat" name="ref" value="'.($_POST["ref"]?$_POST["ref"]:$account->ref).'" maxlength="12"></td></tr>';
// Label // Label
@ -307,10 +307,14 @@ if ($action == 'create')
$doleditor->Create(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';
// Sold print '</table>';
print '<tr><td colspan="4"><b>'.$langs->trans("InitialBankBalance").'...</b></td></tr>';
print '<tr><td valign="top">'.$langs->trans("InitialBankBalance").'</td>'; print '<br>';
print '<table class="border" width="100%">';
// Sold
print '<tr><td valign="top" width="25%">'.$langs->trans("InitialBankBalance").'</td>';
print '<td colspan="3"><input size="12" type="text" class="flat" name="solde" value="'.($_POST["solde"]?$_POST["solde"]:price2num($account->solde)).'"></td></tr>'; print '<td colspan="3"><input size="12" type="text" class="flat" name="solde" value="'.($_POST["solde"]?$_POST["solde"]:price2num($account->solde)).'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans("Date").'</td>'; print '<tr><td valign="top">'.$langs->trans("Date").'</td>';
@ -332,12 +336,12 @@ if ($action == 'create')
// Accountancy code // Accountancy code
if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED))
{ {
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("AccountancyCode").'</td>'; print '<tr><td valign="top" class="fieldrequired" width="25%">'.$langs->trans("AccountancyCode").'</td>';
print '<td colspan="3"><input type="text" name="account_number" value="'.$account->account_number.'"></td></tr>'; print '<td colspan="3"><input type="text" name="account_number" value="'.$account->account_number.'"></td></tr>';
} }
else else
{ {
print '<tr><td valign="top">'.$langs->trans("AccountancyCode").'</td>'; print '<tr><td valign="top" width="25%">'.$langs->trans("AccountancyCode").'</td>';
print '<td colspan="3"><input type="text" name="account_number" value="'.$account->account_number.'"></td></tr>'; print '<td colspan="3"><input type="text" name="account_number" value="'.$account->account_number.'"></td></tr>';
} }
@ -506,7 +510,6 @@ else
$account->fetch(GETPOST('id','int')); $account->fetch(GETPOST('id','int'));
print_fiche_titre($langs->trans("EditFinancialAccount")); print_fiche_titre($langs->trans("EditFinancialAccount"));
print "<br>";
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
{ {
@ -528,7 +531,7 @@ else
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("Ref").'</td>'; print '<tr><td valign="top" class="fieldrequired" width="25%">'.$langs->trans("Ref").'</td>';
print '<td colspan="3"><input size="8" type="text" class="flat" name="ref" value="'.(isset($_POST["ref"])?$_POST["ref"]:$account->ref).'"></td></tr>'; print '<td colspan="3"><input size="8" type="text" class="flat" name="ref" value="'.(isset($_POST["ref"])?$_POST["ref"]:$account->ref).'"></td></tr>';
// Label // Label
@ -612,27 +615,32 @@ else
$doleditor->Create(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';
print '</table>';
print '<br>';
print '<table class="border" width="100%">';
// Accountancy code // Accountancy code
if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED))
{ {
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("AccountancyCode").'</td>'; print '<tr><td valign="top" class="fieldrequired" width="25%">'.$langs->trans("AccountancyCode").'</td>';
print '<td colspan="3"><input type="text" name="account_number" value="'.(isset($_POST["account_number"])?$_POST["account_number"]:$account->account_number).'"></td></tr>'; print '<td colspan="3"><input type="text" name="account_number" value="'.(isset($_POST["account_number"])?$_POST["account_number"]:$account->account_number).'"></td></tr>';
} }
else else
{ {
print '<tr><td valign="top">'.$langs->trans("AccountancyCode").'</td>'; print '<tr><td valign="top" width="25%">'.$langs->trans("AccountancyCode").'</td>';
print '<td colspan="3"><input type="text" name="account_number" value="'.(isset($_POST["account_number"])?$_POST["account_number"]:$account->account_number).'"></td></tr>'; print '<td colspan="3"><input type="text" name="account_number" value="'.(isset($_POST["account_number"])?$_POST["account_number"]:$account->account_number).'"></td></tr>';
} }
// Accountancy journal // Accountancy journal
print '<tr><td valign="top">'.$langs->trans("AccountancyJournalCode").'</td>'; print '<tr><td valign="top">'.$langs->trans("AccountancyJournal").'</td>';
print '<td colspan="3"><input type="text" name="accountancy_journal" value="'.(isset($_POST["accountancy_journal"])?$_POST["accountancy_journal"]:$account->accountancy_journal).'"></td></tr>'; print '<td colspan="3"><input type="text" name="accountancy_journal" value="'.(isset($_POST["accountancy_journal"])?$_POST["accountancy_journal"]:$account->accountancy_journal).'"></td></tr>';
print '<tr><td align="center" colspan="4"><input value="'.$langs->trans("Modify").'" type="submit" class="button">';
print ' &nbsp; <input name="cancel" value="'.$langs->trans("Cancel").'" type="submit" class="button">';
print '</td></tr>';
print '</table>'; print '</table>';
print '<center><br><input value="'.$langs->trans("Modify").'" type="submit" class="button">';
print ' &nbsp; <input name="cancel" value="'.$langs->trans("Cancel").'" type="submit" class="button"></center>';
print '</form>'; print '</form>';
} }

View File

@ -240,3 +240,5 @@ PricingRule=Pricing Rules
AddCustomerPrice=Add price by customers AddCustomerPrice=Add price by customers
ForceUpdateChildPriceSoc=Set same price on customer subsidiaries ForceUpdateChildPriceSoc=Set same price on customer subsidiaries
PriceByCustomerLog=Price by customer log PriceByCustomerLog=Price by customer log
MinimumPriceLimit=Minimum price can't be lower that %s
MinimumRecommendedPrice=Minimum recommended price is : %s

View File

@ -239,3 +239,5 @@ PricingRule=Règle de prix
AddCustomerPrice=Ajouter prix par clients AddCustomerPrice=Ajouter prix par clients
ForceUpdateChildPriceSoc=Définir le même prix sur les filiales des clients ForceUpdateChildPriceSoc=Définir le même prix sur les filiales des clients
PriceByCustomerLog=Trace des prix par clients PriceByCustomerLog=Trace des prix par clients
MinimumPriceLimit=Le prix minimum ne peut être inférieur à %s
MinimumRecommendedPrice=Le prix minimum conseillé est de : %s

View File

@ -9,6 +9,7 @@
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> * Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
* Copyright (C) 2014 Henry Florian <florian.henry@open-concept.pro> * Copyright (C) 2014 Henry Florian <florian.henry@open-concept.pro>
* Copyright (C) 2014 Philippe Grand <philippe.grand@atoo-net.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -3513,4 +3514,35 @@ class Product extends CommonObject
} }
} }
} }
/**
* Return minimum product recommended price
*
* @return void
*/
function min_recommended_price()
{
global $conf;
if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE))
{
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
$product_fourn = new ProductFournisseur($this->db);
$product_fourn_list = $product_fourn->list_product_fournisseur_price($this->id, '', '');
$maxpricesupplier=0;
if (is_array($product_fourn_list) && count($product_fourn_list)>0)
{
foreach($product_fourn_list as $productfourn)
{
if ($productfourn->fourn_unitprice>$maxpricesupplier)
{
$maxpricesupplier = $productfourn->fourn_unitprice;
}
}
$maxpricesupplier*=$conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE;
}
return $maxpricesupplier;
}
}
} }

View File

@ -6,6 +6,7 @@
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Philippe Grand <philippe.grand@atoo-net.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -52,6 +53,8 @@ $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product
$object = new Product($db); $object = new Product($db);
$error=0;
/* /*
* Actions * Actions
*/ */
@ -59,6 +62,9 @@ $object = new Product($db);
if ($action == 'update_price' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { if ($action == 'update_price' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$result = $object->fetch($id); $result = $object->fetch($id);
$error=0;
$maxpricesupplier = $object->min_recommended_price();
// MultiPrix // MultiPrix
if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->PRODUIT_MULTIPRICES))
{ {
@ -93,6 +99,13 @@ if ($action == 'update_price' && ! $_POST ["cancel"] && ($user->rights->produit-
$newpsq = empty($newpsq) ? 0 : $newpsq; $newpsq = empty($newpsq) ? 0 : $newpsq;
} }
if ($newprice_min<$maxpricesupplier && !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE))
{
setEventMessage($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')),'errors');
$error++;
$action='edit_price';
}
if ($object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq) > 0) { if ($object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq) > 0) {
$action = ''; $action = '';
setEventMessage($langs->trans("RecordSaved")); setEventMessage($langs->trans("RecordSaved"));
@ -198,6 +211,9 @@ if ($action == 'delete_all_price_by_qty') {
*/ */
if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$error=0;
$maxpricesupplier = $object->min_recommended_price();
$update_child_soc = GETPOST('updatechildprice'); $update_child_soc = GETPOST('updatechildprice');
$result = $object->fetch($id); $result = $object->fetch($id);
@ -211,6 +227,14 @@ if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->ri
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx")); $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0); $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
if ($prodcustprice->price_min<$maxpricesupplier && !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE))
{
setEventMessage($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')),'errors');
$error++;
$action='add_customer_price';
}
if (empty($error)) {
$result = $prodcustprice->create($user, 0, $update_child_soc); $result = $prodcustprice->create($user, 0, $update_child_soc);
if ($result < 0) { if ($result < 0) {
@ -221,6 +245,7 @@ if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->ri
$action = ''; $action = '';
} }
}
if ($action == 'delete_customer_price' && ($user->rights->produit->supprimer || $user->rights->service->supprimer)) { if ($action == 'delete_customer_price' && ($user->rights->produit->supprimer || $user->rights->service->supprimer)) {
// Delete price by customer // Delete price by customer
@ -237,6 +262,11 @@ if ($action == 'delete_customer_price' && ($user->rights->produit->supprimer ||
if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$result = $object->fetch($id);
$error=0;
$maxpricesupplier = $object->min_recommended_price();
$update_child_soc = GETPOST('updatechildprice'); $update_child_soc = GETPOST('updatechildprice');
$prodcustprice->fetch(GETPOST('lineid', 'int')); $prodcustprice->fetch(GETPOST('lineid', 'int'));
@ -248,6 +278,13 @@ if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user-
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx")); $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0); $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
if ($prodcustprice->price_min<$maxpricesupplier && !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE))
{
setEventMessage($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')),'errors');
$error++;
$action='update_customer_price';
}
if (empty($error)) {
$result = $prodcustprice->update($user, 0, $update_child_soc); $result = $prodcustprice->update($user, 0, $update_child_soc);
if ($result < 0) { if ($result < 0) {
@ -258,6 +295,7 @@ if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user-
$action = ''; $action = '';
} }
}
/* /*
* View * View
@ -613,6 +651,10 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
} else { } else {
print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">'; print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">';
} }
if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE))
{
print '<td align="left">'.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier,0,'',1,-1,-1,'auto')).' '.img_warning().'</td>';
}
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
@ -660,6 +702,10 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->
} else { } else {
print '<td><input name="price_min_' . $i . '" size="10" value="' . price($object->multiprices_min ["$i"]) . '">'; print '<td><input name="price_min_' . $i . '" size="10" value="' . price($object->multiprices_min ["$i"]) . '">';
} }
if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE))
{
print '<td align="left">'.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier,0,'',1,-1,-1,'auto')).' '.img_warning().'</td>';
}
print '</td></tr>'; print '</td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="' . $langs->trans("Save") . '">&nbsp;'; print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="' . $langs->trans("Save") . '">&nbsp;';
@ -806,6 +852,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
if ($action == 'add_customer_price') { if ($action == 'add_customer_price') {
// Create mode // Create mode
$maxpricesupplier = $object->min_recommended_price();
print_fiche_titre($langs->trans('PriceByCustomer')); print_fiche_titre($langs->trans('PriceByCustomer'));
@ -856,6 +903,10 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
} else { } else {
print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">'; print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">';
} }
if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE))
{
print '<td align="left">'.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier,0,'',1,-1,-1,'auto')).' '.img_warning().'</td>';
}
print '</td></tr>'; print '</td></tr>';
// Update all child soc // Update all child soc
@ -876,6 +927,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
} elseif ($action == 'edit_customer_price') { } elseif ($action == 'edit_customer_price') {
// Edit mode // Edit mode
$maxpricesupplier = $object->min_recommended_price();
print_fiche_titre($langs->trans('PriceByCustomer')); print_fiche_titre($langs->trans('PriceByCustomer'));
@ -893,11 +945,11 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<td>' . $langs->trans('ThirdParty') . '</td>'; print '<td>' . $langs->trans('ThirdParty') . '</td>';
$staticsoc = new Societe($db); $staticsoc = new Societe($db);
$staticsoc->fetch($prodcustprice->fk_soc); $staticsoc->fetch($prodcustprice->fk_soc);
print "<td>" . $staticsoc->getNomUrl(1) . "</td>"; print "<td colspan='2'>" . $staticsoc->getNomUrl(1) . "</td>";
print '</tr>'; print '</tr>';
// VAT // VAT
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>'; print '<tr><td>' . $langs->trans("VATRate") . '</td><td colspan="2">';
print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $object->id, $prodcustprice->recuperableonly); print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $object->id, $prodcustprice->recuperableonly);
print '</td></tr>'; print '</td></tr>';
@ -931,6 +983,10 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
} else { } else {
print '<td><input name="price_min" size="10" value="' . price($prodcustprice->price_min) . '">'; print '<td><input name="price_min" size="10" value="' . price($prodcustprice->price_min) . '">';
} }
if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE))
{
print '<td align="left">'.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier,0,'',1,-1,-1,'auto')).' '.img_warning().'</td>';
}
print '</td></tr>'; print '</td></tr>';
// Update all child soc // Update all child soc