From d3b32ce22f630bffe0bbbdd9b98c392ac577b622 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Fri, 28 Nov 2014 19:49:42 +0100
Subject: [PATCH 01/11] Fixed: Bad function/picto for information messages (not
a star)
---
htdocs/admin/modules.php | 2 +-
htdocs/admin/perms.php | 2 +-
htdocs/admin/stock.php | 5 +++++
htdocs/core/lib/admin.lib.php | 2 +-
htdocs/langs/en_US/admin.lang | 9 +++++----
htdocs/user/perms.php | 2 +-
6 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php
index fd3f74c06c2..9ce93a6bc26 100644
--- a/htdocs/admin/modules.php
+++ b/htdocs/admin/modules.php
@@ -534,7 +534,7 @@ dol_fiche_end();
// Show warning about external users
-if ($mode != 'marketplace') print '
'.showModulesExludedForExternal($modules).'
'."\n";
+if ($mode != 'marketplace') print info_admin(showModulesExludedForExternal($modules))."\n";
llxFooter();
diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php
index 74a9b8c8434..907ed389b38 100644
--- a/htdocs/admin/perms.php
+++ b/htdocs/admin/perms.php
@@ -116,7 +116,7 @@ foreach ($modulesdir as $dir)
$db->commit();
// Show warning about external users
-print showModulesExludedForExternal($modules).' '."\n";
+print info_admin(showModulesExludedForExternal($modules)).' '."\n";
print " \n";
diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php
index d0582a91630..d9c5a3f616a 100644
--- a/htdocs/admin/stock.php
+++ b/htdocs/admin/stock.php
@@ -193,6 +193,11 @@ if (! empty($conf->expedition->enabled))
print "\n\n\n";
}
print '';
+
+if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT))
+{
+ print info_admin($langs->trans("IfYouUsePointOfSaleCheckModule"));
+}
print ' ';
// Title rule for stock increase
diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php
index 075baf41161..dd1615d7427 100644
--- a/htdocs/core/lib/admin.lib.php
+++ b/htdocs/core/lib/admin.lib.php
@@ -1193,7 +1193,7 @@ function showModulesExludedForExternal($modules)
$text .= $langs->trans('Module'.$module->numero.'Name');
}
}
- return img_picto($langs->trans('InfoAdmin'), 'star').' '.$text;
+ return $text;
}
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index fec89ae5bcd..9a284748de1 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -702,8 +702,8 @@ Permission701=Read donations
Permission702=Create/modify donations
Permission703=Delete donations
Permission1001=Read stocks
-Permission1002=Create/modify stocks
-Permission1003=Delete stocks
+Permission1002=Create/modify warehouses
+Permission1003=Delete warehouses
Permission1004=Read stock movements
Permission1005=Create/modify stock movements
Permission1101=Read delivery orders
@@ -1416,8 +1416,9 @@ OSCommerceTestOk=Connection to server '%s' on database '%s' with user '%s' succe
OSCommerceTestKo1=Connection to server '%s' succeed but database '%s' could not be reached.
OSCommerceTestKo2=Connection to server '%s' with user '%s' failed.
##### Stock #####
-StockSetup=Configuration module stock
-UserWarehouse=Use user personal stocks
+StockSetup=Warehouse module setup
+UserWarehouse=Use user personal warehouses
+IfYouUsePointOfSaleCheckModule=If you use a Point of Sale module (POS module provided by default or another external module), check also setup of this module: Most point of sales modules are designed to create immediatly an invoice. If you need to have a stock decrease when registering a sell from your Point Of Sale whatever is the option set here, check your POS module is set up for that.
##### Menu #####
MenuDeleted=Menu deleted
TreeMenu=Tree menus
diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php
index f9dbb54f8f4..b63b3e65ffc 100644
--- a/htdocs/user/perms.php
+++ b/htdocs/user/perms.php
@@ -276,7 +276,7 @@ print ' ';
if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules"), 0, 1).' ';
// Show warning about external users
-if (empty($user->societe_id)) print showModulesExludedForExternal($modules).'
';
$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 "';
}
From cdd256e20618e80dd692522bbef59accb466d595 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sat, 29 Nov 2014 12:00:42 +0100
Subject: [PATCH 03/11] Add info to help understand debug
---
htdocs/main.inc.php | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index cf01d5d0364..1182752eace 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -1300,7 +1300,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='')
{
global $user, $conf, $langs, $db;
- global $dolibarr_main_authentication;
+ global $dolibarr_main_authentication, $dolibarr_main_demo;
global $hookmanager,$menumanager;
// Instantiate hooks of thirdparty module
@@ -1410,7 +1410,6 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
$logintext.='>'.$user->login.'';
if ($user->societe_id) $logintext.=$companylink;
$logintext.='';
-
$loginhtmltext.=''.$langs->trans("User").'';
$loginhtmltext.=' '.$langs->trans("Name").': '.$user->getFullName($langs);
$loginhtmltext.=' '.$langs->trans("Login").': '.$user->login;
@@ -1422,9 +1421,9 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a
$loginhtmltext.=' ';
$loginhtmltext.=' '.$langs->trans("Connection").'';
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $loginhtmltext.=' '.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')';
+ $loginhtmltext.=' '.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo)?'':' (demo)');
$loginhtmltext.=' '.$langs->trans("ConnectedSince").': '.dol_print_date($user->datelastlogin,"dayhour");
$loginhtmltext.=' '.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin,"dayhour");
- $loginhtmltext.=' '.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"];
$loginhtmltext.=' '.$langs->trans("CurrentTheme").': '.$conf->theme;
$loginhtmltext.=' '.$langs->trans("CurrentMenuManager").': '.$menumanager->name;
$s=picto_from_langcode($langs->getDefaultLang());
From e118d9af2233feabc460b0223fd3feab82bc64e5 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sat, 29 Nov 2014 12:11:12 +0100
Subject: [PATCH 04/11] Fixed: Protection to lock language setup in demo mode
was not working
---
htdocs/core/class/html.formadmin.class.php | 5 +++--
htdocs/user/param_ihm.php | 6 +++---
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php
index 042474781d7..30ecadedb55 100644
--- a/htdocs/core/class/html.formadmin.class.php
+++ b/htdocs/core/class/html.formadmin.class.php
@@ -53,9 +53,10 @@ class FormAdmin
* @param array $filter Array of keys to exclude in list
* @param int $showempty Add empty value
* @param int $showwarning Show a warning if language is not complete
+ * @param int $disabled Disable edit of select
* @return string Return HTML select string with list of languages
*/
- function select_language($selected='',$htmlname='lang_id',$showauto=0,$filter=0,$showempty=0,$showwarning=0)
+ function select_language($selected='',$htmlname='lang_id',$showauto=0,$filter=0,$showempty=0,$showwarning=0,$disabled=0)
{
global $langs;
@@ -63,7 +64,7 @@ class FormAdmin
$out='';
- $out.= '
';
// Taille max des listes
@@ -190,7 +190,7 @@ if ($action == 'edit')
print '
';
From c7420662e6d13e089639ee9807af687bd21cda84 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sat, 29 Nov 2014 12:40:45 +0100
Subject: [PATCH 05/11] Fixed: Module for target emailing must not be visible
when modules is disabled.
---
htdocs/comm/mailing/cibles.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php
index 49d2f1befa2..75f2399017b 100644
--- a/htdocs/comm/mailing/cibles.php
+++ b/htdocs/comm/mailing/cibles.php
@@ -276,7 +276,8 @@ if ($object->fetch($id) >= 0)
$obj = new $classname($db);
- $qualified=1;
+ // Check dependencies
+ $qualified=(isset($obj->enabled)?$obj->enabled:1);
foreach ($obj->require_module as $key)
{
if (! $conf->$key->enabled || (! $user->admin && $obj->require_admin))
From 3fe2db6c8dfc012af796f467635f817f5ee54a6d Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sat, 29 Nov 2014 13:50:41 +0100
Subject: [PATCH 06/11] Try to find a solution to fight against spam sending
from dolibarr when phpmail is set. No time to find a better solution so i add
just a hidden option to disable phpmail function.
---
htdocs/comm/mailing/card.php | 26 ++++++++++++++++++++++----
htdocs/langs/en_US/mails.lang | 5 ++++-
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php
index 678ea8f622d..ef9f29815c4 100644
--- a/htdocs/comm/mailing/card.php
+++ b/htdocs/comm/mailing/card.php
@@ -94,6 +94,13 @@ $object->substitutionarrayfortest=array(
//,'__PERSONALIZED__' => 'TESTPersonalized' // Not used yet
);
+// List of sending methods
+$listofmethods=array();
+$listofmethods['mail']='PHP mail function';
+//$listofmethods['simplemail']='Simplemail class';
+$listofmethods['smtps']='SMTP/SMTPS socket library';
+
+
/*
* Actions
@@ -741,10 +748,21 @@ else
{
// Define message to recommand from command line
- // Pour des raisons de securite, on ne permet pas cette fonction via l'IHM,
- // on affiche donc juste un message
+ $sendingmode=$conf->global->MAIN_MAIL_SENDMODE;
+ if (empty($sendingmode)) $sendingmode='mail'; // If not defined, we use php mail function
- if (empty($conf->global->MAILING_LIMIT_SENDBYWEB))
+ if (! empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail')
+ {
+ // EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent.
+ // You ensure that every user is using its own SMTP server.
+ $linktoadminemailbefore='';
+ $linktoadminemailend='';
+ setEventMessage($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), 'warnings');
+ setEventMessage($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), 'warnings');
+ if (! empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessage($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), 'warnings');
+ $_GET["action"]='';
+ }
+ else if (empty($conf->global->MAILING_LIMIT_SENDBYWEB))
{
// Pour des raisons de securite, on ne permet pas cette fonction via l'IHM,
// on affiche donc juste un message
@@ -764,7 +782,7 @@ else
}
$text.=$langs->trans('ConfirmSendingEmailing').' ';
$text.=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB);
- print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('SendMailing'),$text,'sendallconfirmed',$formquestion,'',1,260);
+ print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id,$langs->trans('SendMailing'),$text,'sendallconfirmed',$formquestion,'',1,270);
}
}
diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang
index 44027b4cc20..6fffc35bb08 100644
--- a/htdocs/langs/en_US/mails.lang
+++ b/htdocs/langs/en_US/mails.lang
@@ -115,7 +115,7 @@ SentBy=Sent by
MailingNeedCommand=For security reason, sending an emailing is better when performed from command line. If you have one, ask your server administrator to launch the following command to send the emailing to all recipients:
MailingNeedCommand2=You can however send them online by adding parameter MAILING_LIMIT_SENDBYWEB with value of max number of emails you want to send by session. For this, go on Home - Setup - Other.
ConfirmSendingEmailing=If you can't or prefer sending them with your www browser, please confirm you are sure you want to send emailing now from your browser ?
-LimitSendingEmailing=Note: On line sending of emailings are limited for security and timeout reasons to %s recipients by sending session.
+LimitSendingEmailing=Note: Sending of emailings from web interface is done in several times for security and timeout reasons, %s recipients at a time for each sending session.
TargetsReset=Clear list
ToClearAllRecipientsClickHere=Click here to clear the recipient list for this emailing
ToAddRecipientsChooseHere=Add recipients by choosing from the lists
@@ -136,3 +136,6 @@ SomeNotificationsWillBeSent=%s notifications will be sent by email
AddNewNotification=Activate a new email notification target
ListOfActiveNotifications=List all active email notification targets
ListOfNotificationsDone=List all email notifications sent
+MailSendSetupIs=Configuration of email sending has been setup to '%s'. This mode can't be used to send mass emailing.
+MailSendSetupIs2=You must first go, with an admin account, into menu %sHome - Setup - EMails%s to change parameter '%s' to use mode '%s'. With this mode, you can enter setup of the SMTP server provided by your Internet Service Provider and use Mass emailing feature.
+MailSendSetupIs3=If you have any questions on how to setup your SMTP server, you can ask to %s.
From b9ea7d4d13c5e4995e3118b830c2dd26c78e5de4 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sat, 29 Nov 2014 17:38:12 +0100
Subject: [PATCH 07/11] Fix: Stock decrease from POS
---
htdocs/cashdesk/admin/cashdesk.php | 2 -
htdocs/cashdesk/include/environnement.php | 1 +
htdocs/cashdesk/index.php | 3 +-
htdocs/cashdesk/index_verif.php | 6 +-
htdocs/cashdesk/validation_verif.php | 56 ++++++++++++++++++-
htdocs/compta/facture/class/facture.class.php | 4 +-
htdocs/langs/en_US/agenda.lang | 7 ++-
7 files changed, 65 insertions(+), 14 deletions(-)
diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php
index 46e7611b6ed..1ddde37b98b 100644
--- a/htdocs/cashdesk/admin/cashdesk.php
+++ b/htdocs/cashdesk/admin/cashdesk.php
@@ -50,8 +50,6 @@ if (GETPOST('action','alpha') == 'set')
$db->begin();
if (GETPOST('socid','int') < 0) $_POST["socid"]='';
- /*if (GETPOST("CASHDESK_ID_BANKACCOUNT") < 0) $_POST["CASHDESK_ID_BANKACCOUNT"]='';
- if (GETPOST("CASHDESK_ID_WAREHOUSE") < 0) $_POST["CASHDESK_ID_WAREHOUSE"]='';*/
$res = dolibarr_set_const($db,"CASHDESK_ID_THIRDPARTY",(GETPOST('socid','int') > 0 ? GETPOST('socid','int') : ''),'chaine',0,'',$conf->entity);
$res = dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CASH",(GETPOST('CASHDESK_ID_BANKACCOUNT_CASH','alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH','alpha') : ''),'chaine',0,'',$conf->entity);
diff --git a/htdocs/cashdesk/include/environnement.php b/htdocs/cashdesk/include/environnement.php
index f0545181ff0..7411b998272 100644
--- a/htdocs/cashdesk/include/environnement.php
+++ b/htdocs/cashdesk/include/environnement.php
@@ -32,6 +32,7 @@ $conf_db_base = $dolibarr_main_db_name;
$conf_fksoc = (! empty($_SESSION["CASHDESK_ID_THIRDPARTY"]))?$_SESSION["CASHDESK_ID_THIRDPARTY"]:($conf->global->CASHDESK_ID_THIRDPARTY>0?$conf->global->CASHDESK_ID_THIRDPARTY:0);
// Identifiant unique correspondant a l'entrepot a utiliser
$conf_fkentrepot = (! empty($_SESSION["CASHDESK_ID_WAREHOUSE"]))?$_SESSION["CASHDESK_ID_WAREHOUSE"]:($conf->global->CASHDESK_ID_WAREHOUSE>0?$conf->global->CASHDESK_ID_WAREHOUSE:0);
+if (! empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) $conf_fkentrepot = 0; // If option to disable stock decrease is on, we set warehouse id to 0.
// Identifiant unique correspondant au compte caisse / liquide
$conf_fkaccount_cash = (! empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]))?$_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]:($conf->global->CASHDESK_ID_BANKACCOUNT_CASH>0?$conf->global->CASHDESK_ID_BANKACCOUNT_CASH:0);
diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php
index 26dd0f941ef..fa1c6723d20 100644
--- a/htdocs/cashdesk/index.php
+++ b/htdocs/cashdesk/index.php
@@ -107,8 +107,7 @@ if (! empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_
print '
';
$disabled=0;
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 $formproduct->selectWarehouses((GETPOST('warehouseid')?GETPOST('warehouseid','int'):(empty($conf->global->CASHDESK_ID_WAREHOUSE)?'ifone':$conf->global->CASHDESK_ID_WAREHOUSE)),'warehouseid','',!$disabled,$disabled);
print '
';
print "\n";
}
diff --git a/htdocs/cashdesk/index_verif.php b/htdocs/cashdesk/index_verif.php
index 3079de5e003..db80866a77f 100644
--- a/htdocs/cashdesk/index_verif.php
+++ b/htdocs/cashdesk/index_verif.php
@@ -117,8 +117,9 @@ if ( $retour >= 0 )
$_SESSION['uname'] = $username;
$_SESSION['lastname'] = $tab['lastname'];
$_SESSION['firstname'] = $tab['firstname'];
- $_SESSION['CASHDESK_ID_THIRDPARTY'] = $thirdpartyid;
- $_SESSION['CASHDESK_ID_WAREHOUSE'] = $warehouseid;
+ $_SESSION['CASHDESK_ID_THIRDPARTY'] = ($thirdpartyid > 0 ? $thirdpartyid : '');
+ $_SESSION['CASHDESK_ID_WAREHOUSE'] = ($warehouseid > 0 ? $warehouseid : '');
+
$_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] = ($bankid_cash > 0 ? $bankid_cash : '');
$_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] = ($bankid_cheque > 0 ? $bankid_cheque : '');
$_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] = ($bankid_cb > 0 ? $bankid_cb : '');
@@ -131,7 +132,6 @@ if ( $retour >= 0 )
{
dol_print_error($db);
}
-
}
else
{
diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php
index 173c1894555..a03256bfed4 100644
--- a/htdocs/cashdesk/validation_verif.php
+++ b/htdocs/cashdesk/validation_verif.php
@@ -218,7 +218,33 @@ switch ($action)
$resultcreate=$invoice->create($user,0,dol_stringtotime($obj_facturation->paiementLe()));
if ($resultcreate > 0)
{
- $resultvalid=$invoice->validate($user, $obj_facturation->numInvoice(), (isset($_SESSION["CASHDESK_ID_WAREHOUSE"])?$_SESSION["CASHDESK_ID_WAREHOUSE"]:0));
+ $warehouseidtodecrease=(isset($_SESSION["CASHDESK_ID_WAREHOUSE"])?$_SESSION["CASHDESK_ID_WAREHOUSE"]:0);
+ if (! empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) $warehouseidtodecrease=0; // If a particular stock is defined, we disable choice
+
+ $resultvalid=$invoice->validate($user, $obj_facturation->numInvoice(), 0);
+
+ if ($warehouseidtodecrease > 0)
+ {
+ // Decrease
+ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
+ $langs->load("agenda");
+ // Loop on each line
+ $cpt=count($invoice->lines);
+ for ($i = 0; $i < $cpt; $i++)
+ {
+ if ($invoice->lines[$i]->fk_product > 0)
+ {
+ $mouvP = new MouvementStock($this->db);
+ $mouvP->origin = &$invoice;
+ // We decrease stock for product
+ if ($invoice->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $invoice->lines[$i]->fk_product, $idwarehouse, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
+ else $result=$mouvP->livraison($user, $invoice->lines[$i]->fk_product, $idwarehouse, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
+ if ($result < 0) {
+ $error++;
+ }
+ }
+ }
+ }
}
else
{
@@ -232,7 +258,33 @@ switch ($action)
$resultcreate=$invoice->create($user,0,0);
if ($resultcreate > 0)
{
- $resultvalid=$invoice->validate($user, $obj_facturation->numInvoice(), (isset($_SESSION["CASHDESK_ID_WAREHOUSE"])?$_SESSION["CASHDESK_ID_WAREHOUSE"]:0));
+ $warehouseidtodecrease=(isset($_SESSION["CASHDESK_ID_WAREHOUSE"])?$_SESSION["CASHDESK_ID_WAREHOUSE"]:0);
+ if (! empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) $warehouseidtodecrease=0; // If a particular stock is defined, we disable choice
+
+ $resultvalid=$invoice->validate($user, $obj_facturation->numInvoice(), 0);
+
+ if ($warehouseidtodecrease > 0)
+ {
+ // Decrease
+ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
+ $langs->load("agenda");
+ // Loop on each line
+ $cpt=count($invoice->lines);
+ for ($i = 0; $i < $cpt; $i++)
+ {
+ if ($invoice->lines[$i]->fk_product > 0)
+ {
+ $mouvP = new MouvementStock($this->db);
+ $mouvP->origin = &$invoice;
+ // We decrease stock for product
+ if ($invoice->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $invoice->lines[$i]->fk_product, $idwarehouse, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
+ else $result=$mouvP->livraison($user, $invoice->lines[$i]->fk_product, $idwarehouse, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
+ if ($result < 0) {
+ $error++;
+ }
+ }
+ }
+ }
$id = $invoice->id;
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index a6877ad9ed8..b924b059bfd 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1600,7 +1600,7 @@ class Facture extends CommonInvoice
*
* @param User $user Object user that validate
* @param string $force_number Reference to force on invoice
- * @param int $idwarehouse Id of warehouse to use for stock decrease
+ * @param int $idwarehouse Id of warehouse to use for stock decrease if option to decreasenon stock is on (0=no decrease)
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK
*/
@@ -1728,7 +1728,7 @@ class Facture extends CommonInvoice
$result=$this->client->set_as_client();
// Si active on decremente le produit principal et ses composants a la validation de facture
- if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL))
+ if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0)
{
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
$langs->load("agenda");
diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang
index 45f5017671f..5781d5e3ac0 100644
--- a/htdocs/langs/en_US/agenda.lang
+++ b/htdocs/langs/en_US/agenda.lang
@@ -41,9 +41,10 @@ AutoActions= Automatic filling
AgendaAutoActionDesc= Define here events for which you want Dolibarr to create automatically an event in agenda. If nothing is checked (by default), only manual actions will be included in agenda.
AgendaSetupOtherDesc= This page provides options to allow export of your Dolibarr events into an external calendar (thunderbird, google calendar, ...)
AgendaExtSitesDesc=This page allows to declare external sources of calendars to see their events into Dolibarr agenda.
-ActionsEvents= Events for which Dolibarr will create an action in agenda automatically
-PropalValidatedInDolibarr= Proposal %s validated
-InvoiceValidatedInDolibarr= Invoice %s validated
+ActionsEvents=Events for which Dolibarr will create an action in agenda automatically
+PropalValidatedInDolibarr=Proposal %s validated
+InvoiceValidatedInDolibarr=Invoice %s validated
+InvoiceValidatedInDolibarrFromPos=Invoice %s validated from POS
InvoiceBackToDraftInDolibarr=Invoice %s go back to draft status
InvoiceDeleteDolibarr=Invoice %s deleted
OrderValidatedInDolibarr= Order %s validated
From 730398361031db6cf563ff26ba7db84588458c30 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 30 Nov 2014 01:35:58 +0100
Subject: [PATCH 08/11] Fixed: Ton of old bugs when debugging POS.
---
htdocs/admin/stock.php | 8 ++++----
htdocs/cashdesk/affContenu.php | 15 +++++++++++----
htdocs/cashdesk/css/style.css | 9 +++++----
htdocs/cashdesk/facturation_verif.php | 11 ++++++-----
htdocs/cashdesk/tpl/facturation1.tpl.php | 3 ++-
htdocs/cashdesk/tpl/liste_articles.tpl.php | 2 --
htdocs/cashdesk/tpl/validation1.tpl.php | 6 ++++--
htdocs/cashdesk/tpl/validation2.tpl.php | 3 ++-
htdocs/cashdesk/validation_verif.php | 12 ++++++------
htdocs/langs/en_US/admin.lang | 2 +-
htdocs/product/stock/product.php | 4 ++++
11 files changed, 45 insertions(+), 30 deletions(-)
diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php
index d9c5a3f616a..a3109647939 100644
--- a/htdocs/admin/stock.php
+++ b/htdocs/admin/stock.php
@@ -194,10 +194,10 @@ if (! empty($conf->expedition->enabled))
}
print '';
-if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT))
-{
- print info_admin($langs->trans("IfYouUsePointOfSaleCheckModule"));
-}
+//if (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) || ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT))
+//{
+print info_admin($langs->trans("IfYouUsePointOfSaleCheckModule"));
+//}
print ' ';
// Title rule for stock increase
diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php
index 9940e70cc93..dd57a2fd988 100644
--- a/htdocs/cashdesk/affContenu.php
+++ b/htdocs/cashdesk/affContenu.php
@@ -45,7 +45,17 @@ else
-// Left area with selected articles (shopping cart)
+$obj_facturation->calculTotaux(); // Redefine prix_total_ttc, prix_total_ht et montant_tva from $_SESSION['poscart']
+
+$total_ttc = $obj_facturation->prixTotalTtc();
+
+/*var_dump($obj_facturation);
+var_dump($_SESSION['poscart']);
+var_dump($total_ttc);
+exit;*/
+
+
+// Left area with selected articles (area for article, amount and payments)
print '
diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php
index a03256bfed4..fa943acda96 100644
--- a/htdocs/cashdesk/validation_verif.php
+++ b/htdocs/cashdesk/validation_verif.php
@@ -234,11 +234,11 @@ switch ($action)
{
if ($invoice->lines[$i]->fk_product > 0)
{
- $mouvP = new MouvementStock($this->db);
+ $mouvP = new MouvementStock($db);
$mouvP->origin = &$invoice;
// We decrease stock for product
- if ($invoice->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $invoice->lines[$i]->fk_product, $idwarehouse, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
- else $result=$mouvP->livraison($user, $invoice->lines[$i]->fk_product, $idwarehouse, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
+ if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
+ else $result=$mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
if ($result < 0) {
$error++;
}
@@ -274,11 +274,11 @@ switch ($action)
{
if ($invoice->lines[$i]->fk_product > 0)
{
- $mouvP = new MouvementStock($this->db);
+ $mouvP = new MouvementStock($db);
$mouvP->origin = &$invoice;
// We decrease stock for product
- if ($invoice->type == self::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $invoice->lines[$i]->fk_product, $idwarehouse, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
- else $result=$mouvP->livraison($user, $invoice->lines[$i]->fk_product, $idwarehouse, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
+ if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
+ else $result=$mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos",$invoice->newref));
if ($result < 0) {
$error++;
}
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 3e20d071cee..5d1a2323ff0 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -1418,7 +1418,7 @@ OSCommerceTestKo2=Connection to server '%s' with user '%s' failed.
##### Stock #####
StockSetup=Warehouse module setup
UserWarehouse=Use user personal warehouses
-IfYouUsePointOfSaleCheckModule=If you use a Point of Sale module (POS module provided by default or another external module), check also setup of this module: Most point of sales modules are designed to create immediatly an invoice. If you need to have a stock decrease when registering a sell from your Point Of Sale whatever is the option set here, check your POS module is set up for that.
+IfYouUsePointOfSaleCheckModule=If you use a Point of Sale module (POS module provided by default or another external module), this setup may be ignored by your Point Of Sale module. Most point of sales modules are designed to create immediatly an invoice and decrease stock by default whatever are options here. So, if you need or not to have a stock decrease when registering a sell from your Point Of Sale, check also your POS module set up.
##### Menu #####
MenuDeleted=Menu deleted
TreeMenu=Tree menus
diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php
index 5bd7999e2e3..f53931955d3 100644
--- a/htdocs/product/stock/product.php
+++ b/htdocs/product/stock/product.php
@@ -627,12 +627,14 @@ if ($resql)
print '
';
if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($totalvaluesell,'MT'),1);
else print $langs->trans("Variable");
From da841e28cdf14c5065dcff099f783e0dc3450f82 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 30 Nov 2014 01:39:24 +0100
Subject: [PATCH 09/11] Add warning
---
ChangeLog | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index c567d47a9bc..ed4498c342a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -162,7 +162,8 @@ Dolibarr better:
creation of a pdf or odt, hook "afterPDFCreation" or "afterODTCreation" must be used instead.
- A lot of pages called fiche.php were renamed into card.php
- A lot of pages called liste.php were renamed into list.php
-
+- If you used warehouse/stock module, recheck setup of stock increase/decrease rules of the
+ warehouse module and your Point Of Sale module if you use one.
***** ChangeLog for 3.6.2 compared to 3.6.1 *****
From 20e76aa4e66e1f47371a003ed591f9170b4a37f4 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 30 Nov 2014 02:05:45 +0100
Subject: [PATCH 10/11] Fixed: Use constant to hide a feature that will
probably be broken. Also it is a superfluous feature.
---
htdocs/core/class/commonobject.class.php | 39 +++++++++++++-----------
htdocs/theme/eldy/style.css.php | 4 +++
2 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 87ee2f1a1d2..1b0438bdea1 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -3016,30 +3016,33 @@ abstract class CommonObject
$marginInfo = $this->getMarginInfos($force_price);
- print $langs->trans('ShowMarginInfos').' : ';
- $hidemargininfos = $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW'];
- print ''.img_picto($langs->trans("Disabled"),'switch_off').'';
- print ''.img_picto($langs->trans("Enabled"),'switch_on').'';
+ if (! empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) // FIXME Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better
+ {
+ print $langs->trans('ShowMarginInfos').' : ';
+ $hidemargininfos = $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW'];
+ print ''.img_picto($langs->trans("Disabled"),'switch_off').'';
+ print ''.img_picto($langs->trans("Enabled"),'switch_on').'';
- print '';
- if (!empty($hidemargininfos)) print '';
-
- print '