Support trigger in module recruitment
Enhance generic code of automatic recording events
This commit is contained in:
parent
c2e98c7c90
commit
7c39543c72
@ -59,10 +59,11 @@ class InterfaceActionsAuto extends DolibarrTriggers
|
||||
* $object->sendtoid (id of contact or array of ids of contacts)
|
||||
* $object->socid (id of thirdparty)
|
||||
* $object->fk_project
|
||||
* $object->fk_element
|
||||
* $object->elementtype
|
||||
* $object->fk_element (ID of object to link action event to)
|
||||
* $object->elementtype (->element of object to link action to)
|
||||
* $object->module (if defined, elementtype in llx_actioncomm will be elementtype@module)
|
||||
*
|
||||
* @param string $action Event action code
|
||||
* @param string $action Event action code ('CONTRACT_MODIFY', 'RECRUITMENTCANDIDATURE_MODIFIY', ...)
|
||||
* @param Object $object Object
|
||||
* @param User $user Object user
|
||||
* @param Translate $langs Object langs
|
||||
@ -74,6 +75,7 @@ class InterfaceActionsAuto extends DolibarrTriggers
|
||||
if (empty($conf->agenda->enabled)) return 0; // Module not active, we do nothing
|
||||
|
||||
$key = 'MAIN_AGENDA_ACTIONAUTO_'.$action;
|
||||
//var_dump($action.' - '.$conf->global->$key);exit;
|
||||
|
||||
// Do not log events not enabled for this action
|
||||
if (empty($conf->global->$key)) {
|
||||
@ -778,15 +780,29 @@ class InterfaceActionsAuto extends DolibarrTriggers
|
||||
$object->sendtoid = 0;
|
||||
}
|
||||
// TODO Merge all previous cases into this generic one
|
||||
else // $action = BILL_DELETE, TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, CONTACT_SENTBYMAIL, ...
|
||||
else // $action = BILL_DELETE, TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, CONTACT_SENTBYMAIL, RECRUITMENTCANDIDATURE_MODIFY, ...
|
||||
{
|
||||
// Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function).
|
||||
// Note that these key can be set in agenda setup, only if defined into c_action_trigger
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("agenda", "other"));
|
||||
|
||||
if (empty($object->actionmsg2)) $object->actionmsg2 = $langs->transnoentities($action."InDolibarr", $object->ref);
|
||||
if (empty($object->actionmsg)) $object->actionmsg = $langs->transnoentities($action."InDolibarr", $object->ref);
|
||||
if (empty($object->actionmsg2)) {
|
||||
if ($langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)) != $action."InDolibarr") { // specific translation key
|
||||
$langs->loadLangs(array("agenda", "other"));
|
||||
$object->actionmsg2 = $langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref));
|
||||
} else { // generic translation key
|
||||
$tmp = explode('_', $action);
|
||||
$object->actionmsg2 = $langs->transnoentities($tmp[count($tmp)-1]."InDolibarr", ($object->newref ? $object->newref : $object->ref));
|
||||
}
|
||||
}
|
||||
if (empty($object->actionmsg)) {
|
||||
if ($langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref)) != $action."InDolibarr") { // specific translation key
|
||||
$langs->loadLangs(array("agenda", "other"));
|
||||
$object->actionmsg = $langs->transnoentities($action."InDolibarr", ($object->newref ? $object->newref : $object->ref));
|
||||
} else { // generic translation key
|
||||
$tmp = explode('_', $action);
|
||||
$object->actionmsg = $langs->transnoentities($tmp[count($tmp)-1]."InDolibarr", ($object->newref ? $object->newref : $object->ref));
|
||||
}
|
||||
}
|
||||
|
||||
if (! isset($object->sendtoid) || ! is_array($object->sendtoid)) {
|
||||
$object->sendtoid = 0;
|
||||
@ -827,14 +843,15 @@ class InterfaceActionsAuto extends DolibarrTriggers
|
||||
$projectid = isset($object->fk_project) ? $object->fk_project : 0;
|
||||
if ($object->element == 'project') $projectid = $object->id;
|
||||
|
||||
$elementid = $object->id;
|
||||
$elementid = $object->id; // id of object
|
||||
$elementtype = $object->element;
|
||||
$elementmodule = $object->module;
|
||||
if ($object->element == 'subscription')
|
||||
{
|
||||
$elementid = $object->fk_adherent;
|
||||
$elementtype = 'member';
|
||||
}
|
||||
//var_dump($societeforaction);var_dump($contactforaction);exit;
|
||||
//var_dump($societeforaction);var_dump($contactforaction);var_dump($elementid);var_dump($elementtype);exit;
|
||||
|
||||
// Insertion action
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
@ -867,7 +884,7 @@ class InterfaceActionsAuto extends DolibarrTriggers
|
||||
if (!in_array($elementtype, array('societe', 'contact', 'project')))
|
||||
{
|
||||
$actioncomm->fk_element = $elementid;
|
||||
$actioncomm->elementtype = $elementtype;
|
||||
$actioncomm->elementtype = $elementtype.($elementmodule ? '@'.$elementmodule : '');
|
||||
}
|
||||
|
||||
if (property_exists($object, 'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles) > 0) {
|
||||
|
||||
@ -768,7 +768,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
global $langs, $conf, $user;
|
||||
|
||||
$result = '';
|
||||
$label = '<u>'.$langs->trans("ShowOrder").'</u>';
|
||||
$label = '<u>'.$langs->trans("PurchaseOrder").'</u>';
|
||||
if (!empty($this->ref))
|
||||
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
|
||||
if (!empty($this->ref_supplier))
|
||||
|
||||
@ -124,13 +124,23 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_CLOSE','BOM disabled','Executed when a BOM is disabled','bom',652);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_REOPEN','BOM reopen','Executed when a BOM is re-open','bom',653);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_DELETE','BOM deleted','Executed when a BOM deleted','bom',654);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_VALIDATE','MO validated','Executed when a MO is validated','bom',660);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_PRODUCED','MO produced','Executed when a MO is produced','bom',661);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_DELETE','MO deleted','Executed when a MO is deleted','bom',662);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_CANCEL','MO canceled','Executed when a MO is canceled','bom',663);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_VALIDATE','MO validated','Executed when a MO is validated','mrp',660);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_PRODUCED','MO produced','Executed when a MO is produced','mrp',661);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_DELETE','MO deleted','Executed when a MO is deleted','mrp',662);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_CANCEL','MO canceled','Executed when a MO is canceled','mrp',663);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTACT_CREATE','Contact address created','Executed when a contact is created','contact',50);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTACT_SENTBYMAIL','Mails sent from third party card','Executed when you send email from contact adress card','contact',51);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTACT_SENTBYMAIL','Mails sent from third party card','Executed when you send email from contact address record','contact',51);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTACT_DELETE','Contact address deleted','Executed when a contact is deleted','contact',52);
|
||||
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTJOBPOSITION_CREATE','Job created','Executed when a job is created','recruitment',7500);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTJOBPOSITION_MODIFY','Job modified','Executed when a job is modified','recruitment',7502);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTJOBPOSITION_SENTBYMAIL','Mails sent from job record','Executed when you send email from job record','recruitment',7504);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTJOBPOSITION_DELETE','Job deleted','Executed when a job is deleted','recruitment',7506);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTCANDIDATURE_CREATE','Candidature created','Executed when a candidature is created','recruitment',7510);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTCANDIDATURE_MODIFY','Candidature modified','Executed when a candidature is modified','recruitment',7512);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTCANDIDATURE_SENTBYMAIL','Mails sent from candidature record','Executed when you send email from candidature record','recruitment',7514);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTCANDIDATURE_DELETE','Candidature deleted','Executed when a candidature is deleted','recruitment',7516);
|
||||
|
||||
-- actions not enabled by default : they are excluded when we enable the module Agenda (except TASK_...)
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_CREATE','Task created','Executed when a project task is created','project',150);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_MODIFY','Task modified','Executed when a project task is modified','project',151);
|
||||
|
||||
@ -270,3 +270,13 @@ ALTER TABLE llx_ecm_files CHANGE COLUMN date_m tms timestamp;
|
||||
|
||||
INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'recruitment','recruitmentcandidature_send','',0,null,null,'(AnswerCandidature)' ,100,'$conf->recruitment->enabled',1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourCandidature)__', '__(Hello)__ __CANDIDATE_FULLNAME__,<br><br>\n\n__(YourCandidatureAnswer)__<br>\n<br><br>\n__(Sincerely)__<br>__USER_SIGNATURE__',null, 0);
|
||||
|
||||
ALTER TABLE llx_c_action_trigger MODIFY COLUMN code varchar(64) NOT NULL;
|
||||
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTJOBPOSITION_CREATE','Job created','Executed when a job is created','recruitment',7500);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTJOBPOSITION_MODIFY','Job modified','Executed when a job is modified','recruitment',7502);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTJOBPOSITION_SENTBYMAIL','Mails sent from job record','Executed when you send email from job record','recruitment',7504);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTJOBPOSITION_DELETE','Job deleted','Executed when a job is deleted','recruitment',7506);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTCANDIDATURE_CREATE','Candidature created','Executed when a candidature is created','recruitment',7510);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTCANDIDATURE_MODIFY','Candidature modified','Executed when a candidature is modified','recruitment',7512);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTCANDIDATURE_SENTBYMAIL','Mails sent from candidature record','Executed when you send email from candidature record','recruitment',7514);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECRUITMENTCANDIDATURE_DELETE','Candidature deleted','Executed when a candidature is deleted','recruitment',7516);
|
||||
|
||||
@ -23,7 +23,7 @@ create table llx_c_action_trigger
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
elementtype varchar(64) NOT NULL,
|
||||
code varchar(32) NOT NULL,
|
||||
code varchar(64) NOT NULL,
|
||||
label varchar(128) NOT NULL,
|
||||
description varchar(255),
|
||||
rang integer DEFAULT 0
|
||||
|
||||
@ -1077,4 +1077,8 @@ AmountMustBePositive=Amount must be positive
|
||||
ByStatus=By status
|
||||
InformationMessage=Information
|
||||
ASAP=As Soon As Possible
|
||||
|
||||
CREATEInDolibarr=Record %s create
|
||||
MODIFYInDolibarr=Record %s modified
|
||||
DELETEInDolibarr=Record %s deleted
|
||||
VALIDATEInDolibarr=Record %s validated
|
||||
APPROVEDInDolibarr=Record %s approved
|
||||
|
||||
@ -32,6 +32,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
*/
|
||||
class MyObject extends CommonObject
|
||||
{
|
||||
/**
|
||||
* @var string ID of module.
|
||||
*/
|
||||
public $module = 'mymodule';
|
||||
|
||||
/**
|
||||
* @var string ID to identify managed object.
|
||||
*/
|
||||
|
||||
@ -157,7 +157,7 @@ if (empty($reshook))
|
||||
|
||||
if ($action == 'set_thirdparty' && $permissiontoadd)
|
||||
{
|
||||
$object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MYOBJECT_MODIFY');
|
||||
$object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname);
|
||||
}
|
||||
if ($action == 'classin' && $permissiontoadd)
|
||||
{
|
||||
@ -165,7 +165,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Actions to send emails
|
||||
$triggersendname = 'MYOBJECT_SENTBYMAIL';
|
||||
$triggersendname = 'MYMODULE_MYOBJECT_SENTBYMAIL';
|
||||
$autocopy = 'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
|
||||
$trackid = 'myobject'.$object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) ---Put here your own copyright and developer email---
|
||||
/* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -32,6 +31,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
*/
|
||||
class RecruitmentCandidature extends CommonObject
|
||||
{
|
||||
/**
|
||||
* @var string ID of module.
|
||||
*/
|
||||
public $module = 'recruitment';
|
||||
|
||||
/**
|
||||
* @var string ID to identify managed object.
|
||||
*/
|
||||
@ -61,6 +65,7 @@ class RecruitmentCandidature extends CommonObject
|
||||
|
||||
const STATUS_DRAFT = 0;
|
||||
const STATUS_VALIDATED = 1;
|
||||
//const STATUS_INTERVIEW_SCHEDULED = 2;
|
||||
const STATUS_CONTRACT_PROPOSED = 3;
|
||||
const STATUS_CONTRACT_SIGNED = 5;
|
||||
const STATUS_REFUSED = 8;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -31,6 +31,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
*/
|
||||
class RecruitmentJobPosition extends CommonObject
|
||||
{
|
||||
/**
|
||||
* @var string ID of module.
|
||||
*/
|
||||
public $module = 'recruitment';
|
||||
|
||||
/**
|
||||
* @var string ID to identify managed object
|
||||
*/
|
||||
|
||||
@ -138,7 +138,7 @@ if (empty($reshook))
|
||||
else $backtopage = dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
|
||||
}
|
||||
}
|
||||
$triggermodname = 'RECRUITMENT_RECRUITMENTCANDIDATURE_MODIFY'; // Name of trigger action code to execute when we modify record
|
||||
$triggermodname = 'RECRUITMENTCANDIDATURE_MODIFY'; // Name of trigger action code to execute when we modify record
|
||||
|
||||
// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
|
||||
@ -155,16 +155,12 @@ if (empty($reshook))
|
||||
// Action to build doc
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
|
||||
if ($action == 'set_thirdparty' && $permissiontoadd)
|
||||
{
|
||||
$object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'RECRUITMENTCANDIDATURE_MODIFY');
|
||||
}
|
||||
if ($action == 'classin' && $permissiontoadd)
|
||||
{
|
||||
$object->setProject(GETPOST('projectid', 'int'));
|
||||
}
|
||||
if ($action == 'confirm_decline' && $confirm == 'yes' && $permissiontoadd) {
|
||||
$result = $object->setStatut($object::STATUS_REFUSED, null, '', 'RECRUITMENTCANDIDATURE_DECLINE');
|
||||
$result = $object->setStatut($object::STATUS_REFUSED, null, '', $triggermodname);
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
@ -506,7 +502,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
}
|
||||
|
||||
// Refuse - Decline
|
||||
if ($object->status >= $object::STATUS_VALIDATED && $object->status < $object::STATUS_CANCELED)
|
||||
if ($object->status >= $object::STATUS_VALIDATED && $object->status < $object::STATUS_REFUSED)
|
||||
{
|
||||
if ($permissiontoadd)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user