diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 85b4e3bb728..69f647e0757 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -518,20 +518,23 @@ if (empty($reshook))
}
}
- $qualified_for_stock_change = 0;
- if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
- $qualified_for_stock_change = $object->hasProductsOrServices(2);
- } else {
- $qualified_for_stock_change = $object->hasProductsOrServices(1);
- }
-
// Check for warehouse
- if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change)
+ if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL))
{
- if (! $idwarehouse || $idwarehouse == - 1) {
- $error++;
- setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
- $action = '';
+ $qualified_for_stock_change = 0;
+ if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
+ $qualified_for_stock_change = $object->hasProductsOrServices(2);
+ } else {
+ $qualified_for_stock_change = $object->hasProductsOrServices(1);
+ }
+
+ if ($qualified_for_stock_change)
+ {
+ if (! $idwarehouse || $idwarehouse == - 1) {
+ $error++;
+ setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
+ $action = '';
+ }
}
}
@@ -575,20 +578,23 @@ if (empty($reshook))
$object->fetch($id);
$object->fetch_thirdparty();
- $qualified_for_stock_change = 0;
- if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
- $qualified_for_stock_change = $object->hasProductsOrServices(2);
- } else {
- $qualified_for_stock_change = $object->hasProductsOrServices(1);
- }
-
// Check parameters
- if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change)
+ if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL))
{
- if (! $idwarehouse || $idwarehouse == - 1) {
- $error++;
- setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
- $action = '';
+ $qualified_for_stock_change = 0;
+ if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
+ $qualified_for_stock_change = $object->hasProductsOrServices(2);
+ } else {
+ $qualified_for_stock_change = $object->hasProductsOrServices(1);
+ }
+
+ if ($qualified_for_stock_change))
+ {
+ if (! $idwarehouse || $idwarehouse == - 1) {
+ $error++;
+ setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
+ $action = '';
+ }
}
}
@@ -3426,28 +3432,35 @@ elseif ($id > 0 || ! empty($ref))
$text = $langs->trans('ConfirmDeleteBill', $object->ref);
$formquestion = array();
- $qualified_for_stock_change = 0;
- if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
- $qualified_for_stock_change = $object->hasProductsOrServices(2);
- } else {
- $qualified_for_stock_change = $object->hasProductsOrServices(1);
- }
-
- if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change && $object->statut >= 1)
+ if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->statut >= 1)
{
- $langs->load("stocks");
- require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
- $formproduct = new FormProduct($db);
- $label = $object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease");
- $forcecombo=0;
- if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
- $formquestion = array(
- // 'text' => $langs->trans("ConfirmClone"),
- // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
- // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
- array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, $langs->trans("NoStockAction"), 0, $forcecombo))
- );
- $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', $formquestion, "yes", 1);
+ $qualified_for_stock_change = 0;
+ if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
+ $qualified_for_stock_change = $object->hasProductsOrServices(2);
+ } else {
+ $qualified_for_stock_change = $object->hasProductsOrServices(1);
+ }
+
+ if ($qualified_for_stock_change)
+ {
+ $langs->load("stocks");
+ require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
+ $formproduct = new FormProduct($db);
+ $label = $object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease");
+ $forcecombo=0;
+ if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
+ $formquestion = array(
+ // 'text' => $langs->trans("ConfirmClone"),
+ // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
+ // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
+ array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, $langs->trans("NoStockAction"), 0, $forcecombo))
+ );
+ $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', $formquestion, "yes", 1);
+ }
+ else
+ {
+ $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', '', 'no', 1);
+ }
} else {
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', '', 'no', 1);
}
@@ -3496,35 +3509,38 @@ elseif ($id > 0 || ! empty($ref))
}
$formquestion = array();
- $qualified_for_stock_change = 0;
- if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
- $qualified_for_stock_change = $object->hasProductsOrServices(2);
- } else {
- $qualified_for_stock_change = $object->hasProductsOrServices(1);
- }
-
- if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change)
+ if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL))
{
- $langs->load("stocks");
- require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
- require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
- $formproduct = new FormProduct($db);
- $warehouse = new Entrepot($db);
- $warehouse_array = $warehouse->list_array();
- if (count($warehouse_array) == 1) {
- $label = $object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockIncrease", current($warehouse_array)) : $langs->trans("WarehouseForStockDecrease", current($warehouse_array));
- $value = '';
+ $qualified_for_stock_change = 0;
+ if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
+ $qualified_for_stock_change = $object->hasProductsOrServices(2);
} else {
- $label = $object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockIncrease") : $langs->trans("SelectWarehouseForStockDecrease");
- $value = $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1);
+ $qualified_for_stock_change = $object->hasProductsOrServices(1);
+ }
+
+ if ($qualified_for_stock_change)
+ {
+ $langs->load("stocks");
+ require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
+ require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
+ $formproduct = new FormProduct($db);
+ $warehouse = new Entrepot($db);
+ $warehouse_array = $warehouse->list_array();
+ if (count($warehouse_array) == 1) {
+ $label = $object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockIncrease", current($warehouse_array)) : $langs->trans("WarehouseForStockDecrease", current($warehouse_array));
+ $value = '';
+ } else {
+ $label = $object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockIncrease") : $langs->trans("SelectWarehouseForStockDecrease");
+ $value = $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1);
+ }
+ $formquestion = array(
+ // 'text' => $langs->trans("ConfirmClone"),
+ // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' =>
+ // 1),
+ // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value'
+ // => 1),
+ array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $value));
}
- $formquestion = array(
- // 'text' => $langs->trans("ConfirmClone"),
- // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' =>
- // 1),
- // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value'
- // => 1),
- array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $value));
}
if ($object->type != Facture::TYPE_CREDIT_NOTE && $object->total_ttc < 0) // Can happen only if $conf->global->FACTURE_ENABLE_NEGATIVE is on
{
@@ -3538,33 +3554,38 @@ elseif ($id > 0 || ! empty($ref))
$text = $langs->trans('ConfirmUnvalidateBill', $object->ref);
$formquestion = array();
- $qualified_for_stock_change = 0;
- if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
- $qualified_for_stock_change = $object->hasProductsOrServices(2);
- } else {
- $qualified_for_stock_change = $object->hasProductsOrServices(1);
- }
- if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change) {
- $langs->load("stocks");
- require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
- require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
- $formproduct = new FormProduct($db);
- $warehouse = new Entrepot($db);
- $warehouse_array = $warehouse->list_array();
- if (count($warehouse_array) == 1) {
- $label = $object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockDecrease", current($warehouse_array)) : $langs->trans("WarehouseForStockIncrease", current($warehouse_array));
- $value = '';
+ if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL))
+ {
+ $qualified_for_stock_change = 0;
+ if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
+ $qualified_for_stock_change = $object->hasProductsOrServices(2);
} else {
- $label = $object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease");
- $value = $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1);
+ $qualified_for_stock_change = $object->hasProductsOrServices(1);
+ }
+
+ if ($qualified_for_stock_change)
+ {
+ $langs->load("stocks");
+ require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
+ require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
+ $formproduct = new FormProduct($db);
+ $warehouse = new Entrepot($db);
+ $warehouse_array = $warehouse->list_array();
+ if (count($warehouse_array) == 1) {
+ $label = $object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("WarehouseForStockDecrease", current($warehouse_array)) : $langs->trans("WarehouseForStockIncrease", current($warehouse_array));
+ $value = '';
+ } else {
+ $label = $object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease");
+ $value = $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1);
+ }
+ $formquestion = array(
+ // 'text' => $langs->trans("ConfirmClone"),
+ // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' =>
+ // 1),
+ // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value'
+ // => 1),
+ array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $value));
}
- $formquestion = array(
- // 'text' => $langs->trans("ConfirmClone"),
- // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' =>
- // 1),
- // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value'
- // => 1),
- array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $value));
}
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('UnvalidateBill'), $text, 'confirm_modif', $formquestion, "yes", 1);