Skip to content

Commit

Permalink
FIX Several fixes on the management of minimal amount for orders
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Sep 6, 2018
1 parent b25a0ca commit ff05997
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 26 deletions.
24 changes: 15 additions & 9 deletions htdocs/comm/card.php
Expand Up @@ -181,7 +181,7 @@
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');
}
Expand Down Expand Up @@ -423,15 +423,21 @@

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>';
}
}


Expand Down
2 changes: 1 addition & 1 deletion htdocs/commande/card.php
Expand Up @@ -2387,7 +2387,7 @@

// 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>';
Expand Down
22 changes: 12 additions & 10 deletions htdocs/fourn/card.php
Expand Up @@ -109,7 +109,7 @@
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');
}
Expand Down Expand Up @@ -298,15 +298,17 @@
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))
Expand Down
2 changes: 1 addition & 1 deletion htdocs/fourn/commande/card.php
Expand Up @@ -2116,7 +2116,7 @@

// 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>';
Expand Down
5 changes: 2 additions & 3 deletions htdocs/societe/list.php
Expand Up @@ -424,11 +424,10 @@
// 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
Expand Down
4 changes: 2 additions & 2 deletions htdocs/societe/tpl/linesalesrepresentative.tpl.php
Expand Up @@ -23,10 +23,10 @@
}

// 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);
Expand Down

0 comments on commit ff05997

Please sign in to comment.