Enhance the IK module
This commit is contained in:
parent
84cc04a2c6
commit
718497915c
@ -200,48 +200,6 @@ if (empty($reshook))
|
|||||||
$permissiontodelete = $user->rights->expensereport->supprimer;
|
$permissiontodelete = $user->rights->expensereport->supprimer;
|
||||||
$uploaddir = $conf->expensereport->dir_output;
|
$uploaddir = $conf->expensereport->dir_output;
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
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);
|
dol_banner_tab($fuser, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
|
||||||
|
|
||||||
print '<div class="fichecenter">';
|
|
||||||
print '<div class="underbanner clearboth"></div>';
|
|
||||||
|
|
||||||
if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
|
|
||||||
{
|
|
||||||
print '<table class="border centpercent">';
|
|
||||||
|
|
||||||
if ($action == 'edit')
|
|
||||||
{
|
|
||||||
print '<tr><td class="titlefield">'.$langs->trans("DefaultCategoryCar").'</td>';
|
|
||||||
print '<td>';
|
|
||||||
print $form->selectExpenseCategories($fuser->default_c_exp_tax_cat, 'default_c_exp_tax_cat', 1);
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("DefaultRangeNumber").'</td>';
|
|
||||||
print '<td>';
|
|
||||||
$maxRangeNum = ExpenseReportIk::getMaxRangeNumber($fuser->default_c_exp_tax_cat);
|
|
||||||
print $form->selectarray('default_range', range(0, $maxRangeNum), $fuser->default_range);
|
|
||||||
print '</td></tr>';
|
|
||||||
} else {
|
|
||||||
print '<tr><td class="titlefield">'.$langs->trans("DefaultCategoryCar").'</td>';
|
|
||||||
print '<td class="fk_c_exp_tax_cat">';
|
|
||||||
print dol_getIdFromCode($db, $fuser->default_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label');
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("DefaultRangeNumber").'</td>';
|
|
||||||
print '<td>';
|
|
||||||
print $fuser->default_range;
|
|
||||||
print '</td></tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</table>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
/*if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
|
|
||||||
{
|
|
||||||
print '<div class="underbanner clearboth"></div>';
|
|
||||||
|
|
||||||
print '<br>';
|
|
||||||
|
|
||||||
showMyBalance($holiday, $user_id);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
|
|
||||||
if ($action != 'edit')
|
if ($action != 'edit')
|
||||||
{
|
{
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
|
|
||||||
{
|
|
||||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$user_id.'" class="butAction">'.$langs->trans("Modify").'</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$childids = $user->getAllChildIds(1);
|
$childids = $user->getAllChildIds(1);
|
||||||
|
|
||||||
$canedit = ((in_array($user_id, $childids) && $user->rights->expensereport->creer)
|
$canedit = ((in_array($user_id, $childids) && $user->rights->expensereport->creer)
|
||||||
|| ($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->expensereport->writeall_advance));
|
|| ($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->expensereport->writeall_advance));
|
||||||
|
|
||||||
// Buttons for actions
|
// Buttons for actions
|
||||||
if ($canedit)
|
if ($canedit) {
|
||||||
{
|
|
||||||
print '<a href="'.DOL_URL_ROOT.'/expensereport/card.php?action=create&fk_user_author='.$fuser->id.'" class="butAction">'.$langs->trans("AddTrip").'</a>';
|
print '<a href="'.DOL_URL_ROOT.'/expensereport/card.php?action=create&fk_user_author='.$fuser->id.'" class="butAction">'.$langs->trans("AddTrip").'</a>';
|
||||||
|
} else {
|
||||||
|
print '<a href="#" class="butActionRefused" title="'.$langs->trans("NotEnoughPermission").'">'.$langs->trans("AddTrip").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|||||||
@ -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.
|
//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');
|
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).'."<br>\n".'$_SERVER[REQUEST_URI] = '.$_SERVER['REQUEST_URI'].' $_SERVER[REQUEST_METHOD] = '.$_SERVER['REQUEST_METHOD'].' GETPOST(token) = '.GETPOST('token', 'alpha').' $_SESSION[token] = '.$_SESSION['token'], 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).'."<br>\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);
|
unset($_POST);
|
||||||
|
$_POST['id'] = ((int) $savid);
|
||||||
unset($_GET['confirm']);
|
unset($_GET['confirm']);
|
||||||
unset($_GET['action']);
|
unset($_GET['action']);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,6 +114,49 @@ if ($action == 'update' && !$cancel)
|
|||||||
{
|
{
|
||||||
$account->userid = $object->id;
|
$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->bank = GETPOST('bank', 'alpha');
|
||||||
$account->label = GETPOST('label', 'alpha');
|
$account->label = GETPOST('label', 'alpha');
|
||||||
$account->courant = GETPOST('courant', 'alpha');
|
$account->courant = GETPOST('courant', 'alpha');
|
||||||
@ -155,6 +198,23 @@ if ($action == 'setpersonal_mobile')
|
|||||||
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
|
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
|
* View
|
||||||
@ -223,6 +283,51 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
|
||||||
|
{
|
||||||
|
print '<tr class="nowrap">';
|
||||||
|
print '<td>';
|
||||||
|
print $form->editfieldkey("DefaultCategoryCar", 'default_c_exp_tax_cat', $object->default_c_exp_tax_cat, $object, $user->rights->user->user->creer);
|
||||||
|
print '</td><td>';
|
||||||
|
if ($action == 'editdefault_c_exp_tax_cat') {
|
||||||
|
$ret = '<form method="post" action="'.$_SERVER["PHP_SELF"].($moreparam ? '?'.$moreparam : '').'">';
|
||||||
|
$ret .= '<input type="hidden" name="action" value="setdefault_c_exp_tax_cat">';
|
||||||
|
$ret .= '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
|
$ret .= '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||||
|
$ret .= $form->selectExpenseCategories($object->default_c_exp_tax_cat, 'default_c_exp_tax_cat', 1);
|
||||||
|
$ret .= '<input type="submit" class="button" name="modify" value="'.$langs->trans("Modify").'"> ';
|
||||||
|
$ret .= '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||||
|
$ret .= '</form>';
|
||||||
|
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 '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
print '<tr class="nowrap">';
|
||||||
|
print '<td>';
|
||||||
|
print $form->editfieldkey("DefaultRangeNumber", 'default_range', $object->default_range, $object, $user->rights->user->user->creer);
|
||||||
|
print '</td><td>';
|
||||||
|
if ($action == 'editdefault_range') {
|
||||||
|
$ret = '<form method="post" action="'.$_SERVER["PHP_SELF"].($moreparam ? '?'.$moreparam : '').'">';
|
||||||
|
$ret .= '<input type="hidden" name="action" value="setdefault_range">';
|
||||||
|
$ret .= '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
|
$ret .= '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||||
|
$maxRangeNum = ExpenseReportIk::getMaxRangeNumber($object->default_c_exp_tax_cat);
|
||||||
|
$ret .= $form->selectarray('default_range', range(0, $maxRangeNum), $object->default_range);
|
||||||
|
$ret .= '<input type="submit" class="button" name="modify" value="'.$langs->trans("Modify").'"> ';
|
||||||
|
$ret .= '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||||
|
$ret .= '</form>';
|
||||||
|
print $ret;
|
||||||
|
} else {
|
||||||
|
print $object->default_range;
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||||
|
|||||||
@ -1507,7 +1507,7 @@ class User extends CommonObject
|
|||||||
if (empty($this->login))
|
if (empty($this->login))
|
||||||
{
|
{
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$this->error = $langs->trans("ErrorFieldRequired", $this->login);
|
$this->error = $langs->trans("ErrorFieldRequired", 'Login');
|
||||||
return -1;
|
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 .= ", 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 .= ", fk_warehouse = ".($this->fk_warehouse ? "'".$this->db->escape($this->fk_warehouse)."'" : "null");
|
||||||
$sql .= ", lang = ".($this->lang ? "'".$this->db->escape($this->lang)."'" : "null");
|
$sql .= ", lang = ".($this->lang ? "'".$this->db->escape($this->lang)."'" : "null");
|
||||||
|
|
||||||
$sql .= " WHERE rowid = ".$this->id;
|
$sql .= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user