';
$disabled=0;
- if (! empty($conf->global->CASHDESK_ID_WAREHOUSE)) $disabled=1; // If a particular stock is defined, we disable choice
+ if ($conf->global->CASHDESK_ID_WAREHOUSE > 0) $disabled=1; // If a particular stock is defined, we disable choice
print $formproduct->selectWarehouses((GETPOST('warehouseid')?GETPOST('warehouseid'):(empty($conf->global->CASHDESK_ID_WAREHOUSE)?'ifone':$conf->global->CASHDESK_ID_WAREHOUSE)),'warehouseid','',!$disabled,$disabled);
//print '';
print '
';
diff --git a/htdocs/cashdesk/index_verif.php b/htdocs/cashdesk/index_verif.php
index c96b4f2b6f1..3079de5e003 100644
--- a/htdocs/cashdesk/index_verif.php
+++ b/htdocs/cashdesk/index_verif.php
@@ -36,11 +36,11 @@ $langs->load("cashdesk");
$username = GETPOST("txtUsername");
$password = GETPOST("pwdPassword");
-$thirdpartyid = (GETPOST('socid','int')!='')?GETPOST('socid','int'):$conf->global->CASHDESK_ID_THIRDPARTY;
-$warehouseid = (GETPOST("warehouseid")!='')?GETPOST("warehouseid"):$conf->global->CASHDESK_ID_WAREHOUSE;
-$bankid_cash = (GETPOST("CASHDESK_ID_BANKACCOUNT_CASH")!='')?GETPOST("CASHDESK_ID_BANKACCOUNT_CASH"):$conf->global->CASHDESK_ID_BANKACCOUNT_CASH;
-$bankid_cheque = (GETPOST("CASHDESK_ID_BANKACCOUNT_CHEQUE")!='')?GETPOST("CASHDESK_ID_BANKACCOUNT_CHEQUE"):$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE;
-$bankid_cb = (GETPOST("CASHDESK_ID_BANKACCOUNT_CB")!='')?GETPOST("CASHDESK_ID_BANKACCOUNT_CB"):$conf->global->CASHDESK_ID_BANKACCOUNT_CB;
+$thirdpartyid = (GETPOST('socid','int') > 0)?GETPOST('socid','int'):$conf->global->CASHDESK_ID_THIRDPARTY;
+$warehouseid = (GETPOST("warehouseid") > 0)?GETPOST("warehouseid",'int'):$conf->global->CASHDESK_ID_WAREHOUSE;
+$bankid_cash = (GETPOST("CASHDESK_ID_BANKACCOUNT_CASH") > 0)?GETPOST("CASHDESK_ID_BANKACCOUNT_CASH",'int'):$conf->global->CASHDESK_ID_BANKACCOUNT_CASH;
+$bankid_cheque = (GETPOST("CASHDESK_ID_BANKACCOUNT_CHEQUE") > 0)?GETPOST("CASHDESK_ID_BANKACCOUNT_CHEQUE",'int'):$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE;
+$bankid_cb = (GETPOST("CASHDESK_ID_BANKACCOUNT_CB") > 0)?GETPOST("CASHDESK_ID_BANKACCOUNT_CB",'int'):$conf->global->CASHDESK_ID_BANKACCOUNT_CB;
// Check username
if (empty($username))
@@ -58,15 +58,15 @@ if (! ($thirdpartyid > 0))
}
// If we setup stock module to ask movement on invoices, we must not allow access if required setup not finished.
-if (! empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_BILL && ! ($warehouseid > 0))
+if (! empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK) && ! ($warehouseid > 0))
{
- $retour=$langs->trans("CashDeskSetupStock");
+ $retour=$langs->trans("CashDeskYouDidNotDisableStockDecease");
header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb);
exit;
}
// If stock decrease on bill validation, check user has stock edit permissions
-if (! empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_BILL && ! empty($username))
+if (! empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK) && ! empty($username))
{
$testuser=new User($db);
$testuser->fetch(0,$username);
diff --git a/htdocs/cashdesk/tpl/menu.tpl.php b/htdocs/cashdesk/tpl/menu.tpl.php
index 4ee52ce0da6..ce38bb7d7e8 100644
--- a/htdocs/cashdesk/tpl/menu.tpl.php
+++ b/htdocs/cashdesk/tpl/menu.tpl.php
@@ -72,7 +72,7 @@ print $langs->trans("CashDeskThirdParty").': '.$companyLink.' ';
/*print $langs->trans("CashDeskBankCash").': '.$bankcashLink.' ';
print $langs->trans("CashDeskBankCB").': '.$bankcbLink.' ';
print $langs->trans("CashDeskBankCheque").': '.$bankchequeLink.' ';*/
-if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && ! empty($conf->stock->enabled))
+if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && ! empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK))
{
print $langs->trans("CashDeskWarehouse").': '.$warehouseLink;
}
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 9a284748de1..3e20d071cee 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -1483,11 +1483,14 @@ ClickToDialDesc=This module allows to add an icon after phone numbers. A click o
##### Point Of Sales (CashDesk) #####
CashDesk=Point of sales
CashDeskSetup=Point of sales module setup
-CashDeskThirdPartyForSell=Generic third party to use for sells
+CashDeskThirdPartyForSell=Default generic third party to use for sells
CashDeskBankAccountForSell=Default account to use to receive cash payments
CashDeskBankAccountForCheque= Default account to use to receive payments by cheque
CashDeskBankAccountForCB= Default account to use to receive payments by credit cards
-CashDeskIdWareHouse=Warehouse to use for sells
+CashDeskDoNotDecreaseStock=Disable stock decrease when a sell is done from Point of Sale
+CashDeskIdWareHouse=Force and restrict warehouse to use for stock decrease
+StockDecreaseForPointOfSaleDisabled=Stock decrease from Point Of Sale disabled
+CashDeskYouDidNotDisableStockDecease=You did not disable stock decrease when making a sell from Point Of Sale. So a warehouse is required.
##### Bookmark #####
BookmarkSetup=Bookmark module setup
BookmarkDesc=This module allows you to manage bookmarks. You can also add shortcuts to any Dolibarr pages or externale web sites on your left menu.
diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php
index 051a0575aaa..4c8ac74c463 100644
--- a/htdocs/product/stock/card.php
+++ b/htdocs/product/stock/card.php
@@ -45,6 +45,8 @@ $id = GETPOST("id",'int');
if (! $sortfield) $sortfield="p.ref";
if (! $sortorder) $sortorder="DESC";
+$backtopage=GETPOST("backtopage");
+
// Security check
$result=restrictedArea($user,'stock');
@@ -71,16 +73,29 @@ if ($action == 'add' && $user->rights->stock->creer)
$object->town = GETPOST("town");
$object->country_id = GETPOST("country_id");
- if (! empty($object->libelle)) {
+ if (! empty($object->libelle))
+ {
$id = $object->create($user);
if ($id > 0)
{
- header("Location: card.php?id=".$id);
- exit;
+ setEventMessage($langs->trans("RecordSaved"));
+
+ if (! empty($backtopage))
+ {
+ header("Location: ".$backtopage);
+ exit;
+ }
+ else
+ {
+ header("Location: card.php?id=".$id);
+ exit;
+ }
+ }
+ else
+ {
+ $action = 'create';
+ setEventMessage($object->error, 'errors');
}
-
- $action = 'create';
- setEventMessage($object->error, 'errors');
}
else {
setEventMessage($langs->trans("ErrorWarehouseRefRequired"), 'errors');
@@ -164,7 +179,10 @@ if ($action == 'create')
print "';
}