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).'

'."\n"; +if (empty($user->societe_id)) print info_admin(showModulesExludedForExternal($modules)).'

'."\n"; // For multicompany transversal mode // TODO Place a hook here From 7f0a01936edc502b82370825a054de184714c41b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Nov 2014 20:41:52 +0100 Subject: [PATCH 02/11] Fix a very old bug of conflicth into decrease stock when using point of sale, not compatible with option defined into stock module. --- htdocs/cashdesk/admin/cashdesk.php | 31 +++++++++++++++++++------ htdocs/cashdesk/index.php | 4 ++-- htdocs/cashdesk/index_verif.php | 16 ++++++------- htdocs/cashdesk/tpl/menu.tpl.php | 2 +- htdocs/langs/en_US/admin.lang | 7 ++++-- htdocs/product/stock/card.php | 36 +++++++++++++++++++++++------- 6 files changed, 68 insertions(+), 28 deletions(-) diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php index 277dc81820b..46e7611b6ed 100644 --- a/htdocs/cashdesk/admin/cashdesk.php +++ b/htdocs/cashdesk/admin/cashdesk.php @@ -53,11 +53,12 @@ if (GETPOST('action','alpha') == 'set') /*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'),'chaine',0,'',$conf->entity); - $res = dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CASH",GETPOST('CASHDESK_ID_BANKACCOUNT_CASH','alpha'),'chaine',0,'',$conf->entity); - $res = dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CHEQUE",GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE','alpha'),'chaine',0,'',$conf->entity); - $res = dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CB",GETPOST('CASHDESK_ID_BANKACCOUNT_CB','alpha'),'chaine',0,'',$conf->entity); - $res = dolibarr_set_const($db,"CASHDESK_ID_WAREHOUSE",GETPOST('CASHDESK_ID_WAREHOUSE','alpha'),'chaine',0,'',$conf->entity); + $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); + $res = dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CHEQUE",(GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE','alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE','alpha') : ''),'chaine',0,'',$conf->entity); + $res = dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CB",(GETPOST('CASHDESK_ID_BANKACCOUNT_CB','alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CB','alpha') : ''),'chaine',0,'',$conf->entity); + $res = dolibarr_set_const($db,"CASHDESK_ID_WAREHOUSE",(GETPOST('CASHDESK_ID_WAREHOUSE','alpha') > 0 ? GETPOST('CASHDESK_ID_WAREHOUSE','alpha') : ''),'chaine',0,'',$conf->entity); + $res = dolibarr_set_const($db,"CASHDESK_NO_DECREASE_STOCK",GETPOST('CASHDESK_NO_DECREASE_STOCK','alpha'),'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db,"CASHDESK_SERVICES", GETPOST('CASHDESK_SERVICES','alpha'),'chaine',0,'',$conf->entity); dol_syslog("admin/cashdesk: level ".GETPOST('level','alpha')); @@ -129,9 +130,25 @@ if (! empty($conf->banque->enabled)) if (! empty($conf->stock->enabled)) { $var=!$var; - print ''.$langs->trans("CashDeskIdWareHouse").''; + print ''.$langs->trans("CashDeskDoNotDecreaseStock").''; // Force warehouse (this is not a default value) print ''; - print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE,'CASHDESK_ID_WAREHOUSE','',1); + print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK',$conf->global->CASHDESK_NO_DECREASE_STOCK,1); + print ''; + + $disabled=$conf->global->CASHDESK_NO_DECREASE_STOCK; + + $var=!$var; + print ''.$langs->trans("CashDeskIdWareHouse").''; // Force warehouse (this is not a default value) + print ''; + if (! $disabled) + { + print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE,'CASHDESK_ID_WAREHOUSE','',1,$disabled); + print ' ('.$langs->trans("Create").')'; + } + else + { + print $langs->trans("StockDecreaseForPointOfSaleDisabled"); + } print ''; } diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php index a2eb40f2932..26dd0f941ef 100644 --- a/htdocs/cashdesk/index.php +++ b/htdocs/cashdesk/index.php @@ -99,14 +99,14 @@ print $form->select_company(GETPOST('socid','int')?GETPOST('socid','int'):$conf- print ''; print "\n"; -if (! empty($conf->stock->enabled)) +if (! empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) { $langs->load("stocks"); print ""; print ''.$langs->trans("Warehouse").''; print ''; $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 "
\n"; print ''; print ''; - + print ''; + + dol_fiche_head(); + print ''; // Ref @@ -206,7 +224,9 @@ if ($action == 'create') print '
'; - print '

'; + dol_fiche_end(); + + print '
'; 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.= ''; if ($showempty) { $out.= '