From 44bdf91715d9bf065d9e71de9f24f71299f80556 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 May 2017 12:43:45 +0200 Subject: [PATCH 1/5] Add badge with nb of imported calendard on user tab --- htdocs/core/lib/usergroups.lib.php | 29 +++++++++++++++++++++++------ htdocs/holiday/list.php | 2 +- htdocs/user/agenda_extsites.php | 13 ++++++------- htdocs/user/bank.php | 3 ++- htdocs/user/card.php | 2 +- htdocs/user/clicktodial.php | 3 ++- htdocs/user/document.php | 2 +- htdocs/user/info.php | 2 +- htdocs/user/ldap.php | 2 +- htdocs/user/note.php | 14 +++++++------- htdocs/user/notify/card.php | 3 ++- htdocs/user/perms.php | 2 +- 12 files changed, 48 insertions(+), 29 deletions(-) diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 8936cf98623..3b3cde1d66a 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -59,6 +59,11 @@ function user_prepare_head($object) $h++; } + $head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$object->id; + $head[$h][1] = $langs->trans("UserGUISetup"); + $head[$h][2] = 'guisetup'; + $h++; + if ($canreadperms) { $head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$object->id; @@ -67,15 +72,27 @@ function user_prepare_head($object) $h++; } - $head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$object->id; - $head[$h][1] = $langs->trans("UserGUISetup"); - $head[$h][2] = 'guisetup'; - $h++; - if (! empty($conf->agenda->enabled)) { + if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; + $MAXAGENDA=$conf->global->AGENDA_EXT_NB; + + $i=1; + $nbagenda = 0; + while ($i <= $MAXAGENDA) + { + $key=$i; + $name='AGENDA_EXT_NAME_'.$object->id.'_'.$key; + $src='AGENDA_EXT_SRC_'.$object->id.'_'.$key; + $offsettz='AGENDA_EXT_OFFSETTZ_'.$object->id.'_'.$key; + $color='AGENDA_EXT_COLOR_'.$object->id.'_'.$key; + $i++; + + if (! empty($object->conf->$name)) $nbagenda++; + } + $head[$h][0] = DOL_URL_ROOT.'/user/agenda_extsites.php?id='.$object->id; - $head[$h][1] = $langs->trans("ExtSites"); + $head[$h][1] = $langs->trans("ExtSites").($nbagenda ? ' '.$nbagenda.'' : ''); $head[$h][2] = 'extsites'; $h++; } diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index f91616d0b9a..d35fa9293c3 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -202,7 +202,7 @@ $user_id = $user->id; if ($id > 0) { // Charge utilisateur edite - $fuser->fetch($id); + $fuser->fetch($id, '', '', 1); $fuser->getrights(); $user_id = $fuser->id; } diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index d8aba34a934..e789a8277f3 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -42,7 +42,7 @@ $actiontest=GETPOST('test','alpha'); $actionsave=GETPOST('save','alpha'); if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; -$MAXAGENDA=empty($conf->global->AGENDA_EXT_NB)?5:$conf->global->AGENDA_EXT_NB; +$MAXAGENDA=$conf->global->AGENDA_EXT_NB; // List of available colors $colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5'); @@ -50,7 +50,8 @@ $colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5') // Security check $id = GETPOST('id','int'); $object = new User($db); -$object->fetch($id); +$object->fetch($id, '', '', 1); +$object->getrights(); // Security check $socid=0; @@ -81,12 +82,12 @@ if (empty($reshook)) { if ($actionsave) { $db->begin(); - $i = 1; $errorsaved = 0; $error = 0; $tabparam = array(); // Save agendas + $i = 1; while ($i <= $MAXAGENDA) { $name = trim(GETPOST('AGENDA_EXT_NAME_'.$id.'_'.$i, 'alpha')); $src = trim(GETPOST('AGENDA_EXT_SRC_'.$id.'_'.$i, 'alpha')); @@ -110,7 +111,7 @@ if (empty($reshook)) { $tabparam['AGENDA_EXT_COLOR_'.$id.'_'.$i]=$color; $tabparam['AGENDA_EXT_ENABLED_'.$id.'_'.$i]=$enabled; - $i ++; + $i++; } if (!$error) { @@ -167,7 +168,6 @@ print "
\n"; $selectedvalue=$conf->global->AGENDA_DISABLE_EXT; if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1; -$var=true; print '
'; print ""; @@ -180,7 +180,6 @@ print ''; print ""; $i=1; -$var=true; while ($i <= $MAXAGENDA) { $key=$i; @@ -189,7 +188,7 @@ while ($i <= $MAXAGENDA) $offsettz='AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key; $color='AGENDA_EXT_COLOR_'.$id.'_'.$key; - + print ''; // Nb print '"; diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index c9551cdbc23..9f36bc91e31 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -50,7 +50,8 @@ $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $object = new User($db); if ($id > 0 || ! empty($ref)) { - $result = $object->fetch($id, $ref); + $result = $object->fetch($id, $ref, '', 1); + $object->getrights(); } /* diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 3255dc676cf..675f5748842 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1140,7 +1140,7 @@ else if ($id > 0) { - $object->fetch($id); + $object->fetch($id, '', '', 1); if ($res < 0) { dol_print_error($db,$object->error); exit; } $res=$object->fetch_optionals($object->id,$extralabels); diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 5299f348431..1500a3be55c 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -83,7 +83,8 @@ llxHeader("","ClickToDial"); if ($id > 0) { $object = new User($db); - $object->fetch($id); + $object->fetch($id, '', '', 1); + $object->getrights(); $object->fetch_clicktodial(); diff --git a/htdocs/user/document.php b/htdocs/user/document.php index a8d5000e809..8b055979992 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -86,7 +86,7 @@ if (! $sortfield) $sortfield="name"; $object = new User($db); if ($id > 0 || ! empty($ref)) { - $result = $object->fetch($id, $ref); + $result = $object->fetch($id, $ref, '', 1); $object->getrights(); $entitytouseforuserdir = $object->entity; if (empty($entitytouseforuserdir)) $entitytouseforuserdir=1; diff --git a/htdocs/user/info.php b/htdocs/user/info.php index 86bff7147ff..d20624063f2 100644 --- a/htdocs/user/info.php +++ b/htdocs/user/info.php @@ -34,7 +34,7 @@ $id = GETPOST('id','int'); $object = new User($db); if ($id > 0 || ! empty($ref)) { - $result = $object->fetch($id, $ref); + $result = $object->fetch($id, $ref, '', 1); $object->getrights(); } diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index 0f0cc6b4ed7..252ed9f82b4 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -42,7 +42,7 @@ if ($user->id == $id) $feature2=''; // A user can always read its own card $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $object = new User($db); -$object->fetch($id); +$object->fetch($id, '', '', 1); $object->getrights(); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array diff --git a/htdocs/user/note.php b/htdocs/user/note.php index ca9f821d14c..2844676a465 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -36,7 +36,7 @@ $langs->load("bills"); $langs->load("users"); $object = new User($db); -$object->fetch($id); +$object->fetch($id, '', '', 1); $object->getrights(); // If user is not user read and no permission to read other users, we stop @@ -53,9 +53,9 @@ $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); $hookmanager->initHooks(array('usercard','globalcard')); -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ +/* + * Actions + */ $parameters=array('id'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -76,9 +76,9 @@ if (empty($reshook)) { } -/******************************************************************************/ -/* Affichage fiche */ -/******************************************************************************/ +/* + * View + */ llxHeader(); diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index 4f47578f543..2b7c31d75df 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -122,7 +122,8 @@ if ($action == 'delete') $form = new Form($db); $object = new User($db); -$result=$object->fetch($id); +$result=$object->fetch($id, '', '', 1); +$object->getrights(); $title=$langs->trans("ThirdParty").' - '.$langs->trans("Notification"); if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Notification"); diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index e84cfe09ca8..b40c79f783e 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -68,7 +68,7 @@ $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); if ($user->id <> $id && ! $canreaduser) accessforbidden(); $object = new User($db); -$object->fetch($id); +$object->fetch($id, '', '', 1); $object->getrights(); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array From d948447600f7d6ab6fd546b6c091bb6bf7b3dd78 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 May 2017 17:08:38 +0200 Subject: [PATCH 2/5] Add button to disable all personalized default values in one click. --- htdocs/admin/defaultvalues.php | 22 ++++++++++++++++++++++ htdocs/admin/modules.php | 20 ++++++++++++-------- htdocs/admin/stock.php | 1 + htdocs/core/lib/functions.lib.php | 2 +- htdocs/langs/en_US/admin.lang | 1 + htdocs/product/traduction.php | 7 +++---- 6 files changed, 40 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index ec4c5fd4605..dd37e4987e5 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -84,6 +84,11 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $search_array_options=array(); } +if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES') +{ + if (GETPOST('value')) dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 1, 'chaine', 0, '', $conf->entity); + else dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 0, 'chaine', 0, '', $conf->entity); +} if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify')) { @@ -185,6 +190,23 @@ print load_fiche_titre($langs->trans("DefaultValues"),'','title_setup'); print $langs->trans("DefaultValuesDesc")."
\n"; print "
\n"; +print $langs->trans("EnableDefaultValues").' '; +if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) +{ + // Button off, click to enable + print ''; + print img_picto($langs->trans("Disabled"),'switch_off'); + print ''; +} +else +{ + // Button on, click to disable + print ''; + print img_picto($langs->trans("Activated"),'switch_on'); + print ''; +} +print "

\n"; + $param='&mode='.$mode; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index c47586b2b2a..88944ee589a 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -640,7 +640,8 @@ if ($mode == 'common') { $disableSetup = 0; - print '
'."\n"; - // Config link + // Link config if (! empty($objMod->config_page_url) && !$disableSetup) { if (is_array($objMod->config_page_url)) { - print ''; + print ''; } else { - print ''; + print ''; } } else { - print ''; + print ''; } } else // Module not yet activated { - print '\n"; - print ''; + + // Link config + print ''; } print "\n"; diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index c8204f213c2..72ff0f17a1b 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -149,6 +149,7 @@ if (! empty($conf->productbatch->enabled)) //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 decrease diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 262204b9f72..e3c6cb7d5cd 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -260,7 +260,7 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL) global $conf; // Management of default values - if (! isset($_GET['sortfield']) && empty($conf->global->MAIN_DISABLE_DEFAULT_VALUES)) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_DISABLE_DEFAULT_VALUES is on + if (! isset($_GET['sortfield']) && ! empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_DISABLE_DEFAULT_VALUES is on { if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 14131bddd2c..8425aa2c4c6 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -431,6 +431,7 @@ TheKeyIsTheNameOfHtmlField=This is the name of the HTML field. This need to have PageUrlForDefaultValues=You must enter here the relative url of the page. If you include parameters in URL, the default values will be effective if all parameters are set to same value. Examples: PageUrlForDefaultValuesCreate=
For form to create a new thirdparty, it is %s PageUrlForDefaultValuesList=
For page that list thirdparties, it is %s +EnableDefaultValues=Enable usage of personalized default values GoIntoTranslationMenuToChangeThis=A translation has been found for the key with this code, so to change this value, you must edit it fom Home-Setup-translation. WarningSettingSortOrder=Warning, setting a default sort order may result in a technical error when going on the list page if field is an unknown field. If you experience such an error, come back to this page to remove the default sort order and restore default behavior. Field=Field diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index b5f4b8b34ae..03f7e1c54ac 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -277,16 +277,14 @@ if ($action == 'edit') } else if ($action != 'add') { - //if ($cnt_trans) print '
'; - if (! empty($object->multilangs)) { foreach ($object->multilangs as $key => $value) { $s=picto_from_langcode($key); - //print ''; + + print '
'; print '
'; print '
'.$langs->trans("Color").'
'.$langs->trans("AgendaExtNb",$key)."'; + // Link enable/disabme + print ''; if (! empty($arrayofwarnings[$modName])) { print ''."\n"; @@ -662,12 +663,12 @@ if ($mode == 'common') } print ''; + print ''; $i=0; foreach ($objMod->config_page_url as $page) { @@ -693,22 +694,23 @@ if ($mode == 'common') } else if (preg_match('/^([^@]+)@([^@]+)$/i',$objMod->config_page_url,$regs)) { - print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').''.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').''; + // Link enable/disable + print ''; if (! empty($objMod->always_enabled)) { // Should never happened @@ -754,7 +756,9 @@ if ($mode == 'common') print "\n"; } print "'.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').''.img_picto($langs->trans("NothingToSetup"),"setup",'class="opacitytransp" style="padding-right: 6px"').'
'; print ($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', 'class="valigntextbottom"').''; - //print '
'; print ''; @@ -296,6 +294,7 @@ else if ($action != 'add') print ''; } print '
'.$langs->trans('Label').''.$object->multilangs[$key]["label"].'
'.$langs->trans('Other').' ('.$langs->trans("NotUsed").')'.$object->multilangs[$key]["other"].'
'; + print '
'; } } if (! $cnt_trans && $action != 'add') print '
'. $langs->trans('NoTranslation').'
'; From 910a92516711a006ad0f7424b4d3f44ce2de7594 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 May 2017 20:43:14 +0200 Subject: [PATCH 3/5] NEW Add last activation author and ip of modules --- htdocs/admin/modulehelp.php | 18 ++++++++ htdocs/admin/modules.php | 6 +-- htdocs/admin/user.php | 4 +- htdocs/admin/usergroup.php | 2 +- htdocs/comm/mailing/card.php | 2 +- htdocs/core/lib/admin.lib.php | 2 +- htdocs/core/menus/standard/auguria.lib.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/core/modules/DolibarrModules.class.php | 42 ++++++++++++++++-- htdocs/core/tpl/login.tpl.php | 2 +- htdocs/core/tpl/passwordforgotten.tpl.php | 2 +- htdocs/langs/en_US/admin.lang | 4 +- htdocs/societe/admin/contact_extrafields.php | 2 +- htdocs/societe/admin/societe.php | 2 +- htdocs/societe/admin/societe_extrafields.php | 2 +- htdocs/theme/dolibarr_logo.png | Bin 14646 -> 10289 bytes htdocs/theme/eldy/style.css.php | 10 ++++- htdocs/user/admin/group_extrafields.php | 2 +- htdocs/user/admin/user_extrafields.php | 2 +- 19 files changed, 84 insertions(+), 24 deletions(-) mode change 100644 => 100755 htdocs/theme/dolibarr_logo.png diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 94bfa8e05bb..d318566ff61 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -330,6 +330,24 @@ if ($mode == 'desc') else $text.=$langs->trans("Disabled"); $text.='
'; + $tmp = $objMod->getLastActivationInfo(); + $authorid = $tmp['authorid']; + if ($authorid > 0) + { + $tmpuser = new User($db); + $tmpuser->fetch($authorid); + $text.=''.$langs->trans("LastActivationAuthor").': '; + $text.= $tmpuser->getNomUrl(1); + $text.='
'; + } + $ip = $tmp['ip']; + if ($ip) + { + $text.=''.$langs->trans("LastActivationIP").': '; + $text.= $ip; + $text.='
'; + } + $moduledesclong=$objMod->getDescLong(); if ($moduledesclong) $text.='

'.$moduledesclong.'
'; } diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 88944ee589a..433508be908 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -402,9 +402,9 @@ if ($nbofactivatedmodules <= 1) $moreinfo .= ' '.img_warning($langs->trans("YouM print load_fiche_titre($langs->trans("ModulesSetup"),$moreinfo,'title_setup'); // Start to show page -if ($mode=='common') print $langs->trans("ModulesDesc")."
\n"; -if ($mode=='marketplace') print $langs->trans("ModulesMarketPlaceDesc")."
\n"; -if ($mode=='deploy') print $langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."
\n"; +if ($mode=='common') print ''.$langs->trans("ModulesDesc")."
\n"; +if ($mode=='marketplace') print ''.$langs->trans("ModulesMarketPlaceDesc")."
\n"; +if ($mode=='deploy') print ''.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."
\n"; $h = 0; diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index 42feea8f8ec..0c7574b7ec4 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -167,7 +167,7 @@ print load_fiche_titre($langs->trans("UsersSetup"),$linkback,'title_setup'); $head=user_admin_prepare_head(); -dol_fiche_head($head,'card', $langs->trans("MenuUsersAndGroups"), 0, 'user'); +dol_fiche_head($head,'card', $langs->trans("MenuUsersAndGroups"), -1, 'user'); print ''; print ''; @@ -205,7 +205,7 @@ print ''; print '
'; - +print '
'; $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index db5ef3cbf59..4642e6d3183 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -151,7 +151,7 @@ print load_fiche_titre($langs->trans("UsersSetup"),$linkback,'title_setup'); $head=user_admin_prepare_head(); -dol_fiche_head($head,'usergroupcard', $langs->trans("MenuUsersAndGroups"), 0, 'user'); +dol_fiche_head($head,'usergroupcard', $langs->trans("MenuUsersAndGroups"), -1, 'user'); $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index fe582d56656..0b4c3c239f9 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -1057,7 +1057,7 @@ else // Print mail content print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'title_generic'); - dol_fiche_head(''); + dol_fiche_head('', '', '', -1); print ''; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 4beb49107d2..2016807efe9 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -812,7 +812,7 @@ function activateModule($value,$withdeps=1) return $ret; } - $result=$objMod->init(); + $result=$objMod->init(); // Enable module if ($result <= 0) { $ret['errors'][]=$objMod->error; diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index e95359e5683..d2d8e36b8ca 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -269,7 +269,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM print ''; print ''; print ''; print ''; print ''."\n"; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 4c873830948..b51292a0bb8 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -478,7 +478,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu print ''; print ''; print ''; print ''; print ''."\n"; diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 48ce35f1532..d0559268c52 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -795,6 +795,37 @@ class DolibarrModules // Can not be abstract, because we need to insta } + /** + * Gives the last author of activation + * + * @return array Array array('authorid'=>Id of last activation user, 'lastactivationdate'=>Date of last activation) + */ + function getLastActivationInfo() + { + global $conf; + + $sql = "SELECT tms, note FROM ".MAIN_DB_PREFIX."const"; + $sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->const_name."'"; + $sql.= " AND entity IN (0, ".$conf->entity.")"; + + dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) $err++; + else + { + $obj=$this->db->fetch_object($resql); + $tmp=array(); + if ($obj->note) + { + $tmp=json_decode($obj->note, true); + } + if ($obj) return array('authorid'=>$tmp['authorid'], 'ip'=>$tmp['ip'], 'lastactivationdate'=>$this->db->jdate($obj->tms)); + } + + return array(); + } + + /** * Insert constants for module activation * @@ -802,7 +833,7 @@ class DolibarrModules // Can not be abstract, because we need to insta */ function _active() { - global $conf; + global $conf, $user; $err = 0; @@ -817,10 +848,13 @@ class DolibarrModules // Can not be abstract, because we need to insta $resql=$this->db->query($sql); if (! $resql) $err++; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible,entity) VALUES"; + $note=json_encode(array('authorid'=>$user->id, 'ip'=>$_SERVER['REMOTE_ADDR'])); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name, value, visible, entity, note) VALUES"; $sql.= " (".$this->db->encrypt($this->const_name,1); - $sql.= ",".$this->db->encrypt('1',1); - $sql.= ",0,".$entity.")"; + $sql.= ", ".$this->db->encrypt('1',1); + $sql.= ", 0, ".$entity; + $sql.= ", '".$this->db->escape($note)."')"; dol_syslog(get_class($this)."::_active", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 1245041d98a..81e3936d300 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -258,7 +258,7 @@ if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) { -
'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 29dcc413221..947d99af545 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4938,25 +4938,33 @@ abstract class CommonObject if(!empty($id)) $sql.= ' WHERE rowid = '.$id; else $sql.= ' WHERE ref = \''.$this->quote($ref).'\''; - + $res = $this->db->query($sql); - if($obj = $this->db->fetch_object($res)) + if ($res) { - $this->id = $id; - $this->set_vars_by_db($obj); - - $this->datec = $this->db->idate($obj->datec); - $this->tms = $this->db->idate($obj->tms); - - return $this->id; + if ($obj = $this->db->fetch_object($res)) + { + $this->id = $id; + $this->set_vars_by_db($obj); + + $this->datec = $this->db->idate($obj->datec); + $this->tms = $this->db->idate($obj->tms); + + return $this->id; + } + else + { + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + return -1; + } } else { - $this->error = $this->db->lasterror(); - $this->errors[] = $this->error; - return -1; + $this->error = $this->db->lasterror(); + $this->errors[] = $this->error; + return -1; } - } /** diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 021213594f7..1456fb991c2 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -106,14 +106,12 @@ class CoreObject extends CommonObject */ public function fetch($id, $loadChild = true) { - $res = $this->fetchCommon($id); if($res>0) { if ($loadChild) $this->fetchChild(); } return $res; - } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index b51292a0bb8..b7a372e50bd 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1265,7 +1265,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } // Inventory - if ($conf->global->MAIN_LEVEL_FEATURES >= 2) + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (! empty($conf->stock->enabled)) { diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index e80966afb81..be6817062b6 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -117,32 +117,37 @@ class modStock extends DolibarrModules $this->rights[4][4] = 'mouvement'; $this->rights[4][5] = 'creer'; - if ($conf->global->MAIN_LEVEL_FEATURES >= 2) { + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - $this->rights[5][0] = 1006; + $this->rights[5][0] = 1011; $this->rights[5][1] = 'inventoryReadPermission'; // Permission label $this->rights[5][3] = 0; // Permission by default for new user (0/1) - $this->rights[5][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[5][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[5][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[6][0] = 1007; + $this->rights[6][0] = 1012; $this->rights[6][1] = 'inventoryCreatePermission'; // Permission label $this->rights[6][3] = 0; // Permission by default for new user (0/1) - $this->rights[6][4] = 'create'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[6][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[6][5] = 'create'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[7][0] = 1008; + $this->rights[7][0] = 1013; $this->rights[7][1] = 'inventoryWritePermission'; // Permission label $this->rights[7][3] = 0; // Permission by default for new user (0/1) - $this->rights[7][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[7][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[7][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[7][0] = 1009; - $this->rights[7][1] = 'inventoryValidatePermission'; // Permission label - $this->rights[7][3] = 0; // Permission by default for new user (0/1) - $this->rights[7][4] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[8][0] = 1014; + $this->rights[8][1] = 'inventoryValidatePermission'; // Permission label + $this->rights[8][3] = 0; // Permission by default for new user (0/1) + $this->rights[8][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[8][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - $this->rights[7][0] = 1010; - $this->rights[7][1] = 'inventoryChangePMPPermission'; // Permission label - $this->rights[7][3] = 0; // Permission by default for new user (0/1) - $this->rights[7][4] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[9][0] = 1015; + $this->rights[9][1] = 'inventoryChangePMPPermission'; // Permission label + $this->rights[9][3] = 0; // Permission by default for new user (0/1) + $this->rights[9][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[9][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) } diff --git a/htdocs/install/mysql/tables/llx_fichinter.sql b/htdocs/install/mysql/tables/llx_fichinter.sql index b3e2001f9c3..926a05a738e 100644 --- a/htdocs/install/mysql/tables/llx_fichinter.sql +++ b/htdocs/install/mysql/tables/llx_fichinter.sql @@ -43,5 +43,4 @@ create table llx_fichinter note_public text, model_pdf varchar(255), extraparams varchar(255) -- for stock other parameters with json format - )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_inventory.sql b/htdocs/install/mysql/tables/llx_inventory.sql index f906699f5dd..ce1a2c93744 100644 --- a/htdocs/install/mysql/tables/llx_inventory.sql +++ b/htdocs/install/mysql/tables/llx_inventory.sql @@ -1,6 +1,6 @@ -- =================================================================== --- Copyright (C) 2012 Laurent Destailleur --- Copyright (C) 2017 ATM Consulting +-- Copyright (C) 2017 Laurent Destailleur +-- Copyright (C) 2017 ATM Consulting -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -19,13 +19,18 @@ CREATE TABLE llx_inventory ( -rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, -datec datetime DEFAULT NULL, -tms timestamp, -fk_warehouse integer DEFAULT 0, -entity integer DEFAULT 0, -status integer DEFAULT 0, -title varchar(255) NOT NULL, -date_inventory datetime DEFAULT NULL + rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 0, + ref varchar(48), + datec datetime DEFAULT NULL, + tms timestamp, + fk_user_author integer, -- user making creation + fk_user_modif integer, -- user making last change + fk_user_valid integer, -- valideur de la fiche + fk_warehouse integer DEFAULT 0, + status integer DEFAULT 0, + title varchar(255) NOT NULL, + date_inventory datetime DEFAULT NULL, + import_key varchar(14) -- import key ) ENGINE=InnoDB; diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 34e79da8a69..e47891a6d08 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -361,9 +361,9 @@ if ($action == 'create') dol_fiche_end(); print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; echo ''; @@ -373,8 +373,14 @@ if ($action == 'create') if ($action == 'view' || $action == 'edit' || empty($action)) { $object = new Inventory($db); - $object->fetch($id); - + $result = $object->fetch($id); + if ($result < 0) dol_print_error($db, $object->error, $object->errors); + + $warehouse = new Entrepot($db); + $warehouse->fetch($object->fk_warehouse); + + + if($action == 'changePMP') { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ApplyNewPMP'), $langs->trans('ConfirmApplyNewPMP', $object->getTitle()), 'confirm_changePMP', array(),'no',1); @@ -396,18 +402,17 @@ if ($action == 'view' || $action == 'edit' || empty($action)) print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('RegulateStock'),$langs->trans('ConfirmRegulateStock',$object->getTitle()),'confirm_regulate',array(),'no',1); } - $warehouse = new Entrepot($db); - $warehouse->fetch($object->fk_warehouse); - print dol_get_fiche_head(inventoryPrepareHead($object, $langs->trans('inventoryOfWarehouse', $warehouse->libelle), empty($action) ? '': '&action='.$action)); $lines = array(); card_line($object, $lines, $action); - print ''.$langs->trans('inventoryOnDate')." ".$object->getDate('date_inventory').'

'; + print $langs->trans('Ref')." ".$object->ref.'
'; + print $langs->trans('Date')." ".$object->getDate('date_inventory').'

'; $objectTPL = array( - 'id'=> $object->id + 'id'=> $object->id + ,'ref'=> $object->ref ,'date_cre' => $object->getDate('date_cre', 'd/m/Y') ,'date_maj' => $object->getDate('date_maj', 'd/m/Y H:i') ,'fk_warehouse' => $object->fk_warehouse @@ -608,8 +613,8 @@ function _headerList($view) ?>
- - + + barcode->enabled)) { ?> diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 93bbb38f6e7..8cb1f56eb9d 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -69,6 +69,7 @@ class Inventory extends CoreObject */ protected $fields=array( 'fk_warehouse'=>array('type'=>'integer','index'=>true) + ,'ref'=>array('type'=>'string','index'=>true) ,'entity'=>array('type'=>'integer','index'=>true) ,'status'=>array('type'=>'integer','index'=>true) ,'date_inventory'=>array('type'=>'date') @@ -113,7 +114,8 @@ class Inventory extends CoreObject if(!$loadChild) $this->withChild = false; $res = parent::fetch($id, $loadChild); - if($res > 0) + + if ($res > 0) { $this->sortDet(); $this->amount = 0; diff --git a/htdocs/product/inventory/tpl/inventory.tpl.php b/htdocs/product/inventory/tpl/inventory.tpl.php index 2a1c3bc3ee4..05de0f4c002 100644 --- a/htdocs/product/inventory/tpl/inventory.tpl.php +++ b/htdocs/product/inventory/tpl/inventory.tpl.php @@ -80,7 +80,7 @@ - +
@@ -92,7 +92,7 @@ -
  Produittrans('Warehouse'); ?>trans('Product'); ?>trans('Warehouse'); ?> trans('Barcode'); ?>
+