move automatic intervention creation from ticket/card.php to triggers/workflow.php
This commit is contained in:
parent
8db171ae41
commit
ea68ed9c07
@ -435,7 +435,6 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
|||||||
$number_contracts_found = 0;
|
$number_contracts_found = 0;
|
||||||
foreach ($company_ids as $company_id) {
|
foreach ($company_ids as $company_id) {
|
||||||
$contrat->socid = $company_id;
|
$contrat->socid = $company_id;
|
||||||
|
|
||||||
$list = $contrat->getListOfContracts($option = 'all', $status = [Contrat::STATUS_DRAFT, Contrat::STATUS_VALIDATED], $product_categories = [$conf->global->TICKET_PRODUCT_CATEGORY], $line_status = [ContratLigne::STATUS_INITIAL, ContratLigne::STATUS_OPEN]);
|
$list = $contrat->getListOfContracts($option = 'all', $status = [Contrat::STATUS_DRAFT, Contrat::STATUS_VALIDATED], $product_categories = [$conf->global->TICKET_PRODUCT_CATEGORY], $line_status = [ContratLigne::STATUS_INITIAL, ContratLigne::STATUS_OPEN]);
|
||||||
if (is_array($list) && !empty($list)) {
|
if (is_array($list) && !empty($list)) {
|
||||||
$number_contracts_found = count($list);
|
$number_contracts_found = count($list);
|
||||||
@ -457,6 +456,28 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
|||||||
if (empty(NOLOGIN)) setEventMessage($langs->trans('TicketNoContractFoundToLink'), 'mesgs');
|
if (empty(NOLOGIN)) setEventMessage($langs->trans('TicketNoContractFoundToLink'), 'mesgs');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Automatically create intervention
|
||||||
|
if (!empty($conf->ficheinter->enabled) && !empty($conf->ticket->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_TICKET_CREATE_INTERVENTION) && !empty($object->fk_soc)) {
|
||||||
|
$fichinter = new Fichinter($this->db);
|
||||||
|
$fichinter->socid = $object->fk_soc;
|
||||||
|
$fichinter->fk_project = $projectid;
|
||||||
|
$fichinter->fk_contrat = (int) $object->fk_contract;
|
||||||
|
$fichinter->author = $user->id;
|
||||||
|
$fichinter->model_pdf = 'soleil';
|
||||||
|
$fichinter->origin = $object->element;
|
||||||
|
$fichinter->origin_id = $object->id;
|
||||||
|
|
||||||
|
// Extrafields
|
||||||
|
$extrafields = new ExtraFields($this->db);
|
||||||
|
$extrafields->fetch_name_optionals_label($fichinter->table_element);
|
||||||
|
$array_options = $extrafields->getOptionalsFromPost($fichinter->table_element);
|
||||||
|
$fichinter->array_options = $array_options;
|
||||||
|
|
||||||
|
$id = $fichinter->create($user);
|
||||||
|
if ($id <= 0) {
|
||||||
|
setEventMessages($fichinter->error, null, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -254,28 +254,6 @@ if (empty($reshook)) {
|
|||||||
$result = $object->assignUser($user, $user->id, 1);
|
$result = $object->assignUser($user, $user->id, 1);
|
||||||
$object->add_contact($user->id, "SUPPORTTEC", 'internal');
|
$object->add_contact($user->id, "SUPPORTTEC", 'internal');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto create fiche intervention
|
|
||||||
if (!empty($conf->global->TICKET_AUTO_CREATE_FICHINTER_CREATE)) {
|
|
||||||
$fichinter = new Fichinter($db);
|
|
||||||
$fichinter->socid = $object->fk_soc;
|
|
||||||
$fichinter->fk_project = $projectid;
|
|
||||||
$fichinter->fk_contrat = $object->fk_contract;
|
|
||||||
$fichinter->author = $user->id;
|
|
||||||
$fichinter->model_pdf = 'soleil';
|
|
||||||
$fichinter->origin = $object->element;
|
|
||||||
$fichinter->origin_id = $object->id;
|
|
||||||
|
|
||||||
// Extrafields
|
|
||||||
$extrafields->fetch_name_optionals_label($fichinter->table_element);
|
|
||||||
$array_options = $extrafields->getOptionalsFromPost($fichinter->table_element);
|
|
||||||
$fichinter->array_options = $array_options;
|
|
||||||
|
|
||||||
$id = $fichinter->create($user);
|
|
||||||
if ($id <= 0) {
|
|
||||||
setEventMessages($fichinter->error, null, 'errors');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user