diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php
index bfc5ed64f5e..549f5f93fe6 100644
--- a/htdocs/expensereport/list.php
+++ b/htdocs/expensereport/list.php
@@ -200,48 +200,6 @@ if (empty($reshook))
$permissiontodelete = $user->rights->expensereport->supprimer;
$uploaddir = $conf->expensereport->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
-
- if ($action == 'update' && !$cancel)
- {
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-
- if ($canedituser) // Case we can edit all field
- {
- $error = 0;
-
- if (!$error)
- {
- $objectuser->fetch($id);
-
- $objectuser->oldcopy = clone $objectuser;
-
- $db->begin();
-
- $objectuser->default_range = GETPOST('default_range');
- $objectuser->default_c_exp_tax_cat = GETPOST('default_c_exp_tax_cat');
-
- if (!$error) {
- $ret = $objectuser->update($user);
- if ($ret < 0) {
- $error++;
- if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
- $langs->load("errors");
- setEventMessages($langs->trans("ErrorLoginAlreadyExists", $objectuser->login), null, 'errors');
- } else {
- setEventMessages($objectuser->error, $objectuser->errors, 'errors');
- }
- }
- }
-
- if (!$error && !count($objectuser->errors)) {
- setEventMessages($langs->trans("UserModified"), null, 'mesgs');
- $db->commit();
- } else {
- $db->rollback();
- }
- }
- }
- }
}
@@ -387,71 +345,22 @@ if ($resql)
dol_banner_tab($fuser, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
- print '
';
- print '
';
-
- if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
- {
- print '
';
-
- if ($action == 'edit')
- {
- print '| '.$langs->trans("DefaultCategoryCar").' | ';
- print '';
- print $form->selectExpenseCategories($fuser->default_c_exp_tax_cat, 'default_c_exp_tax_cat', 1);
- print ' |
';
-
- print '| '.$langs->trans("DefaultRangeNumber").' | ';
- print '';
- $maxRangeNum = ExpenseReportIk::getMaxRangeNumber($fuser->default_c_exp_tax_cat);
- print $form->selectarray('default_range', range(0, $maxRangeNum), $fuser->default_range);
- print ' |
';
- } else {
- print '| '.$langs->trans("DefaultCategoryCar").' | ';
- print '';
- print dol_getIdFromCode($db, $fuser->default_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label');
- print ' |
';
-
- print '| '.$langs->trans("DefaultRangeNumber").' | ';
- print '';
- print $fuser->default_range;
- print ' |
';
- }
-
- print '
';
- }
-
- print '
';
-
- /*if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
- {
- print '';
-
- print '
';
-
- showMyBalance($holiday, $user_id);
- }*/
-
dol_fiche_end();
if ($action != 'edit')
{
print '';
- if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
- {
- print '
'.$langs->trans("Modify").'';
- }
-
$childids = $user->getAllChildIds(1);
$canedit = ((in_array($user_id, $childids) && $user->rights->expensereport->creer)
|| ($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->expensereport->writeall_advance));
// Buttons for actions
- if ($canedit)
- {
+ if ($canedit) {
print '
'.$langs->trans("AddTrip").'';
+ } else {
+ print '
'.$langs->trans("AddTrip").'';
}
print '
';
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 60bac4dcfb4..1065073b13c 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -380,7 +380,9 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl
//print 'Unset POST by CSRF protection in main.inc.php.'; // Do not output anything because this create problems when using the BACK button on browsers.
setEventMessages('SecurityTokenHasExpiredSoActionHasBeenCanceledPleaseRetry', null, 'warnings');
//if ($conf->global->MAIN_FEATURES_LEVEL >= 1) setEventMessages('Unset POST and GET params by CSRF protection in main.inc.php (Token provided was not generated by the previous page).'."
\n".'$_SERVER[REQUEST_URI] = '.$_SERVER['REQUEST_URI'].' $_SERVER[REQUEST_METHOD] = '.$_SERVER['REQUEST_METHOD'].' GETPOST(token) = '.GETPOST('token', 'alpha').' $_SESSION[token] = '.$_SESSION['token'], null, 'warnings');
+ $savid = ((int) $_POST['id']);
unset($_POST);
+ $_POST['id'] = ((int) $savid);
unset($_GET['confirm']);
unset($_GET['action']);
}
diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php
index 5363ec728c2..af7aa162790 100644
--- a/htdocs/user/bank.php
+++ b/htdocs/user/bank.php
@@ -114,6 +114,49 @@ if ($action == 'update' && !$cancel)
{
$account->userid = $object->id;
+ /*
+ if ($action == 'update' && !$cancel)
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+
+ if ($canedituser) // Case we can edit all field
+ {
+ $error = 0;
+
+ if (!$error)
+ {
+ $objectuser->fetch($id);
+
+ $objectuser->oldcopy = clone $objectuser;
+
+ $db->begin();
+
+ $objectuser->default_range = GETPOST('default_range');
+ $objectuser->default_c_exp_tax_cat = GETPOST('default_c_exp_tax_cat');
+
+ if (!$error) {
+ $ret = $objectuser->update($user);
+ if ($ret < 0) {
+ $error++;
+ if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
+ $langs->load("errors");
+ setEventMessages($langs->trans("ErrorLoginAlreadyExists", $objectuser->login), null, 'errors');
+ } else {
+ setEventMessages($objectuser->error, $objectuser->errors, 'errors');
+ }
+ }
+ }
+
+ if (!$error && !count($objectuser->errors)) {
+ setEventMessages($langs->trans("UserModified"), null, 'mesgs');
+ $db->commit();
+ } else {
+ $db->rollback();
+ }
+ }
+ }
+ }*/
+
$account->bank = GETPOST('bank', 'alpha');
$account->label = GETPOST('label', 'alpha');
$account->courant = GETPOST('courant', 'alpha');
@@ -155,6 +198,23 @@ if ($action == 'setpersonal_mobile')
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
+// update default_c_exp_tax_cat
+if ($action == 'setdefault_c_exp_tax_cat')
+{
+ $object->default_c_exp_tax_cat = GETPOST('default_c_exp_tax_cat', 'int');
+ $result = $object->update($user);
+ if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
+}
+
+// update default range
+if ($action == 'setdefault_range')
+{
+ $object->default_range = GETPOST('default_range', 'int');
+ $result = $object->update($user);
+ if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
+}
+
+
/*
* View
@@ -223,6 +283,51 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
print '';
print '';
+ if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
+ {
+ print '';
+ print '| ';
+ print $form->editfieldkey("DefaultCategoryCar", 'default_c_exp_tax_cat', $object->default_c_exp_tax_cat, $object, $user->rights->user->user->creer);
+ print ' | ';
+ if ($action == 'editdefault_c_exp_tax_cat') {
+ $ret = '';
+ print $ret;
+ } else {
+ print dol_getIdFromCode($db, $object->default_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label');
+ //print $form->editfieldval("DefaultCategoryCar", 'default_c_exp_tax_cat', $object->default_c_exp_tax_cat, $object, $user->rights->user->user->creer, 'string', ($object->default_c_exp_tax_cat != '' ? $object->default_c_exp_tax_cat : ''));
+ }
+ print ' | ';
+ print '
';
+
+ print '';
+ print '| ';
+ print $form->editfieldkey("DefaultRangeNumber", 'default_range', $object->default_range, $object, $user->rights->user->user->creer);
+ print ' | ';
+ if ($action == 'editdefault_range') {
+ $ret = '';
+ print $ret;
+ } else {
+ print $object->default_range;
+ }
+ print ' | ';
+ print '
';
+ }
+
print '';
print '';
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index 6f650d4a312..de0b73d6aec 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -1507,7 +1507,7 @@ class User extends CommonObject
if (empty($this->login))
{
$langs->load("errors");
- $this->error = $langs->trans("ErrorFieldRequired", $this->login);
+ $this->error = $langs->trans("ErrorFieldRequired", 'Login');
return -1;
}
@@ -1558,7 +1558,6 @@ class User extends CommonObject
$sql .= ", default_c_exp_tax_cat = ".($this->default_c_exp_tax_cat > 0 ? $this->default_c_exp_tax_cat : 'null');
$sql .= ", fk_warehouse = ".($this->fk_warehouse ? "'".$this->db->escape($this->fk_warehouse)."'" : "null");
$sql .= ", lang = ".($this->lang ? "'".$this->db->escape($this->lang)."'" : "null");
-
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);