NEW Keep a link between user created from recruitment and application
This commit is contained in:
parent
f3a3a8b854
commit
93022a406c
@ -93,3 +93,6 @@ ALTER TABLE llx_ecm_files ADD COLUMN share_pass varchar(32) after share;
|
||||
|
||||
ALTER TABLE llx_prelevement_demande ADD COLUMN type varchar(12) DEFAULT '';
|
||||
UPDATE llx_prelevement_demande SET type = 'ban' WHERE ext_payment_id IS NULL AND type = '';
|
||||
|
||||
ALTER TABLE llx_recruitment_recruitmentcandidature ADD COLUMN fk_user integer;
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ CREATE TABLE llx_recruitment_recruitmentcandidature(
|
||||
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
fk_user_creat integer NOT NULL,
|
||||
fk_user_modif integer,
|
||||
fk_user integer, -- Id of user created from the job application
|
||||
import_key varchar(14),
|
||||
model_pdf varchar(255),
|
||||
status smallint NOT NULL,
|
||||
|
||||
@ -129,6 +129,7 @@ class RecruitmentCandidature extends CommonObject
|
||||
'description' => array('type'=>'html', 'label'=>'Description', 'enabled'=>'1', 'position'=>300, 'notnull'=>0, 'visible'=>3, 'cssview'=>'wordbreak'),
|
||||
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-4, 'csslist'=>'nowraponall'),
|
||||
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2, 'csslist'=>'nowraponall'),
|
||||
'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'LinkedToDolibarrUser', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax100'),
|
||||
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
|
||||
'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
|
||||
'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'default'=>0, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Received', '3'=>'ContractProposed', '5'=>'ContractSigned', '8'=>'Refused', '9'=>'Canceled')),
|
||||
@ -144,6 +145,7 @@ class RecruitmentCandidature extends CommonObject
|
||||
public $tms;
|
||||
public $fk_user_creat;
|
||||
public $fk_user_modif;
|
||||
public $fk_user;
|
||||
public $lastname;
|
||||
public $firstname;
|
||||
public $email;
|
||||
|
||||
@ -202,38 +202,46 @@ if (empty($reshook)) {
|
||||
|
||||
// Create user from a member
|
||||
if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) {
|
||||
if ($result > 0) {
|
||||
$jobposition = new RecruitmentJobPosition($db);
|
||||
$jobposition->fetch($object->fk_recruitmentjobposition);
|
||||
$jobposition = new RecruitmentJobPosition($db);
|
||||
$jobposition->fetch($object->fk_recruitmentjobposition);
|
||||
|
||||
// Creation user
|
||||
$nuser = new User($db);
|
||||
$nuser->login = GETPOST('login', 'alphanohtml');
|
||||
$nuser->fk_soc = 0;
|
||||
$nuser->employee = 1;
|
||||
$nuser->firstname = $object->firstname;
|
||||
$nuser->lastname = $object->lastname;
|
||||
$nuser->email = '';
|
||||
$nuser->personal_email = $object->email;
|
||||
$nuser->personal_mobile = $object->phone;
|
||||
$nuser->birth = $object->date_birth;
|
||||
$nuser->salary = $object->remuneration_proposed;
|
||||
$nuser->fk_user = $jobposition->fk_user_supervisor; // Supervisor
|
||||
$nuser->email = $object->email;
|
||||
$db->begin();
|
||||
|
||||
$result = $nuser->create($user);
|
||||
// Creation user
|
||||
$nuser = new User($db);
|
||||
$nuser->login = GETPOST('login', 'alphanohtml');
|
||||
$nuser->fk_soc = 0;
|
||||
$nuser->employee = 1;
|
||||
$nuser->firstname = $object->firstname;
|
||||
$nuser->lastname = $object->lastname;
|
||||
$nuser->email = '';
|
||||
$nuser->personal_email = $object->email;
|
||||
$nuser->personal_mobile = $object->phone;
|
||||
$nuser->birth = $object->date_birth;
|
||||
$nuser->salary = $object->remuneration_proposed;
|
||||
$nuser->fk_user = $jobposition->fk_user_supervisor; // Supervisor
|
||||
$nuser->email = $object->email;
|
||||
|
||||
if ($result < 0) {
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans($nuser->error), null, 'errors');
|
||||
$action = 'create_user';
|
||||
} else {
|
||||
setEventMessages($langs->trans("NewUserCreated", $nuser->login), null, 'mesgs');
|
||||
$action = '';
|
||||
}
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$result = $nuser->create($user);
|
||||
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans($nuser->error), null, 'errors');
|
||||
$action = 'create_user';
|
||||
} else {
|
||||
$object->fk_user = $result;
|
||||
|
||||
$object->update($user);
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
|
||||
setEventMessages($langs->trans("NewUserCreated", $nuser->login), null, 'mesgs');
|
||||
$action = '';
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
@ -572,8 +580,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
// Button to convert into a user
|
||||
if ($object->status == $object::STATUS_CONTRACT_SIGNED) {
|
||||
if ($user->rights->user->user->creer) {
|
||||
// TODO Check if a user already exists
|
||||
$useralreadyexists = 0;
|
||||
$useralreadyexists = $object->fk_user;
|
||||
if (empty($useralreadyexists)) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a></div>';
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user