FIX Several fixes on the management of minimal amount for orders

This commit is contained in:
Laurent Destailleur 2018-09-06 17:37:02 +02:00
parent b25a0ca672
commit ff05997f0a
6 changed files with 33 additions and 26 deletions

View File

@ -181,7 +181,7 @@ if (empty($reshook))
if ($action == 'setorder_min_amount')
{
$object->fetch($id);
$object->order_min_amount=GETPOST('order_min_amount');
$object->order_min_amount=price2num(GETPOST('order_min_amount','alpha'));
$result=$object->update($object->id, $user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
@ -423,15 +423,21 @@ if ($object->id > 0)
print '</td>';
print '</tr>';
}
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer);
print '</td><td>';
print $form->editfieldval("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->order_min_amount != '' ? price($object->order_min_amount) : ''));
print '</td>';
print '</tr>';
if ($object->client)
{
if (! empty($conf->commande->enabled) && ! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT))
{
print '<!-- Minimim amount for orders -->'."\n";
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer);
print '</td><td>';
print $form->editfieldval("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->order_min_amount != '' ? price($object->order_min_amount) : ''));
print '</td>';
print '</tr>';
}
}

View File

@ -2387,7 +2387,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Total HT
$alert = '';
if($object->total_ht < $object->thirdparty->order_min_amount) {
if (! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->order_min_amount) {
$alert = ' ' . img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount));
}
print '<tr><td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>';

View File

@ -109,7 +109,7 @@ if (empty($reshook))
if ($action == 'setsupplier_order_min_amount')
{
$object->fetch($id);
$object->supplier_order_min_amount=GETPOST('supplier_order_min_amount');
$object->supplier_order_min_amount=price2num(GETPOST('supplier_order_min_amount','alpha'));
$result=$object->update($object->id, $user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
@ -298,15 +298,17 @@ if ($object->id > 0)
print '</td>';
print '</tr>';
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer);
print '</td><td>';
$limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount';
print $form->editfieldval("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->supplier_order_min_amount != '' ? price($object->supplier_order_min_amount) : ''));
print '</td>';
print '</tr>';
if (! empty($conf->fournisseur->enabled) && ! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT))
{
print '<tr class="nowrap">';
print '<td>';
print $form->editfieldkey("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer);
print '</td><td>';
$limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount';
print $form->editfieldval("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->supplier_order_min_amount != '' ? price($object->supplier_order_min_amount) : ''));
print '</td>';
print '</tr>';
}
// Categories
if (! empty($conf->categorie->enabled))

View File

@ -2116,7 +2116,7 @@ elseif (! empty($object->id))
// Total
$alert = '';
if($object->total_ht < $object->thirdparty->supplier_order_min_amount) {
if (! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->supplier_order_min_amount) {
$alert = ' ' . img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->supplier_order_min_amount));
}
print '<tr><td class="titlefieldmiddle">'.$langs->trans("AmountHT").'</td>';

View File

@ -424,11 +424,10 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region. code_region
// We'll need this table joined to the select in order to filter by categ
if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ
if (! empty($search_categ_sup)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ
$sql.= " ,".MAIN_DB_PREFIX."c_stcomm as st";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id";
// We'll need this table joined to the select in order to filter by sale
if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.fk_stcomm = st.id";
$sql.= " AND s.entity IN (".getEntity('societe').")";
$sql.= " WHERE s.entity IN (".getEntity('societe').")";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid;
if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale

View File

@ -23,10 +23,10 @@ if (empty($conf) || ! is_object($conf))
}
// Sale representative
print '<tr><td>';
print '<tr><td class="titlefield">';
print $langs->trans('SalesRepresentatives');
print '</td>';
print '<td colspan="3">';
print '<td>';
$listsalesrepresentatives=$object->getSalesRepresentatives($user);
$nbofsalesrepresentative=count($listsalesrepresentatives);