Merge pull request #10617 from wdammak/patch-29
NEW Add Default Warehouse to user record (if module stock is on)
This commit is contained in:
commit
727c4b787b
@ -48,6 +48,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
if (! empty($conf->ldap->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
|
||||
if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
||||
|
||||
$id = GETPOST('id', 'int');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
@ -91,7 +92,7 @@ $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
||||
if ($user->id <> $id && ! $canreaduser) accessforbidden();
|
||||
|
||||
// Load translation files required by page
|
||||
$langs->loadLangs(array('users', 'companies', 'ldap', 'admin', 'hrm'));
|
||||
$langs->loadLangs(array('users', 'companies', 'ldap', 'admin', 'hrm', 'stocks'));
|
||||
|
||||
$object = new User($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
@ -238,6 +239,8 @@ if (empty($reshook)) {
|
||||
$dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth'), GETPOST('dateemploymentendday'), GETPOST('dateemploymentendyear'));
|
||||
$object->dateemploymentend = $dateemploymentend;
|
||||
|
||||
$object->fk_warehouse = GETPOST('fk_warehouse', 'int');
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
||||
if ($ret < 0) {
|
||||
@ -385,7 +388,12 @@ if (empty($reshook)) {
|
||||
$object->dateemployment = $dateemployment;
|
||||
$dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth', 'int'), GETPOST('dateemploymentendday', 'int'), GETPOST('dateemploymentendyear', 'int'));
|
||||
$object->dateemploymentend = $dateemploymentend;
|
||||
|
||||
|
||||
if (! empty($conf->stock->enabled))
|
||||
{
|
||||
$object->fk_warehouse = GETPOST('fk_warehouse', 'int');
|
||||
}
|
||||
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
{
|
||||
if (! empty($_POST["superadmin"]))
|
||||
@ -642,6 +650,7 @@ $form = new Form($db);
|
||||
$formother=new FormOther($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
$formfile = new FormFile($db);
|
||||
if (! empty($conf->stock->enabled)) $formproduct = new FormProduct($db);
|
||||
|
||||
llxHeader('', $langs->trans("UserCard"));
|
||||
|
||||
@ -1185,6 +1194,13 @@ if ($action == 'create' || $action == 'adduserldap')
|
||||
print '<input class="maxwidth200" type="text" name="job" value="'.GETPOST('job').'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Default warehouse
|
||||
if (! empty($conf->stock->enabled))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>';
|
||||
print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
|
||||
|| (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read)))
|
||||
@ -1537,6 +1553,17 @@ else
|
||||
print '<tr><td>'.$langs->trans("PostOrFunction").'</td>';
|
||||
print '<td>'.$object->job.'</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
// Default warehouse
|
||||
if (! empty($conf->stock->enabled))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT .'/product/stock/class/entrepot.class.php';
|
||||
$warehousestatic=new Entrepot($db);
|
||||
$warehousestatic->fetch($object->fk_warehouse);
|
||||
print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>';
|
||||
print $warehousestatic->getNomUrl();
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
//$childids = $user->getAllChildIds(1);
|
||||
|
||||
@ -2555,6 +2582,15 @@ else
|
||||
print $object->job;
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Default warehouse
|
||||
if (! empty($conf->stock->enabled))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>';
|
||||
print $formproduct->selectWarehouses($object->fk_warehouse, 'fk_warehouse', 'warehouseopen', 1);
|
||||
print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit').'">'.$langs->trans("AddWarehouse").'</a>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
|
||||
|| (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read)))
|
||||
|
||||
@ -174,6 +174,8 @@ class User extends CommonObject
|
||||
|
||||
public $default_c_exp_tax_cat;
|
||||
public $default_range;
|
||||
|
||||
public $fk_warehouse;
|
||||
|
||||
public $fields = array(
|
||||
'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
|
||||
@ -249,6 +251,7 @@ class User extends CommonObject
|
||||
$sql.= " u.weeklyhours,";
|
||||
$sql.= " u.color,";
|
||||
$sql.= " u.dateemployment, u.dateemploymentend,";
|
||||
$sql.= " u.fk_warehouse,";
|
||||
$sql.= " u.ref_int, u.ref_ext,";
|
||||
$sql.= " u.default_range, u.default_c_exp_tax_cat,"; // Expense report default mode
|
||||
$sql.= " c.code as country_code, c.label as country,";
|
||||
@ -370,6 +373,7 @@ class User extends CommonObject
|
||||
|
||||
$this->default_range = $obj->default_range;
|
||||
$this->default_c_exp_tax_cat = $obj->default_c_exp_tax_cat;
|
||||
$this->fk_warehouse = $obj->fk_warehouse;
|
||||
|
||||
// Protection when module multicompany was set, admin was set to first entity and then, the module was disabled,
|
||||
// in such case, this admin user must be admin for ALL entities.
|
||||
@ -1486,6 +1490,7 @@ class User extends CommonObject
|
||||
$this->color = empty($this->color)?'':$this->color;
|
||||
$this->dateemployment = empty($this->dateemployment)?'':$this->dateemployment;
|
||||
$this->dateemploymentend = empty($this->dateemploymentend)?'':$this->dateemploymentend;
|
||||
$this->fk_warehouse = trim(empty($this->fk_warehouse)?'':$this->fk_warehouse);
|
||||
|
||||
// Check parameters
|
||||
if (! empty($conf->global->USER_MAIL_REQUIRED) && ! isValidEMail($this->email))
|
||||
@ -1544,6 +1549,7 @@ class User extends CommonObject
|
||||
$sql.= ", entity = '".$this->db->escape($this->entity)."'";
|
||||
$sql.= ", default_range = ".($this->default_range > 0 ? $this->default_range : '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.= " WHERE rowid = ".$this->id;
|
||||
|
||||
@ -1984,7 +1990,7 @@ class User extends CommonObject
|
||||
dol_syslog(get_class($this)."::send_password changelater is on, url=".$url);
|
||||
}
|
||||
|
||||
$mailfile = new CMailFile(
|
||||
$mailfile = new CMailFile(
|
||||
$subject,
|
||||
$this->email,
|
||||
$conf->global->MAIN_MAIL_EMAIL_FROM,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user