Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Maarch
MaarchCourrier
Commits
cfa40410
Commit
cfa40410
authored
May 25, 2022
by
mathieu.pionier
Browse files
FIX #18863 TIME 0:05 add entity contact replacement on mail when deleting one
parent
2782e876
Changes
3
Show whitespace changes
Inline
Side-by-side
src/app/entity/controllers/EntityController.php
View file @
cfa40410
...
...
@@ -180,6 +180,7 @@ class EntityController
$entity
[
'users'
]
=
EntityModel
::
getUsersById
([
'id'
=>
$entity
[
'entity_id'
],
'select'
=>
[
'users.id'
,
'users.user_id'
,
'users.firstname'
,
'users.lastname'
,
'users.status'
]]);
$children
=
EntityModel
::
get
([
'select'
=>
[
1
],
'where'
=>
[
'parent_entity_id = ?'
],
'data'
=>
[
$args
[
'id'
]]]);
$entity
[
'contact'
]
=
$this
->
getContactLinkCount
(
$entity
[
'id'
]);
$entity
[
'hasChildren'
]
=
count
(
$children
)
>
0
;
$documents
=
ResModel
::
get
([
'select'
=>
[
1
],
'where'
=>
[
'destination = ?'
],
'data'
=>
[
$args
[
'id'
]]]);
$entity
[
'documents'
]
=
count
(
$documents
);
...
...
@@ -195,6 +196,13 @@ class EntityController
return
$response
->
withJson
([
'entity'
=>
$entity
]);
}
public
function
getContactLinkCount
(
int
$id
)
{
$linkCount
=
count
(
ResourceContactModel
::
get
([
'select'
=>
[
'distinct res_id'
],
'where'
=>
[
'item_id = ?'
,
'type = ?'
],
'data'
=>
[
$id
,
'entity'
]]));
return
$linkCount
;
}
public
function
create
(
Request
$request
,
Response
$response
)
{
if
(
!
PrivilegeController
::
hasPrivilege
([
'privilegeId'
=>
'manage_entities'
,
'userId'
=>
$GLOBALS
[
'id'
]]))
{
...
...
@@ -532,10 +540,20 @@ class EntityController
'data'
=>
[
'"'
.
$dyingEntity
[
'id'
]
.
'"'
]
]);
//ResourceContact
ResourceContactModel
::
update
([
'set'
=>
[
'item_id'
=>
$successorEntity
[
'id'
]],
'where'
=>
[
'item_id = ?'
,
'type = ?'
],
'data'
=>
[
$dyingEntity
[
'id'
],
'entity'
]]);
$dyingOcc
=
ResourceContactModel
::
get
([
'select'
=>
[
'id'
,
'res_id'
,
'item_id'
,
'mode'
],
'where'
=>
[
'type = ?'
,
'item_id = ?'
],
'data'
=>
[
'entity'
,
$dyingEntity
[
'id'
]]]);
$succOcc
=
ResourceContactModel
::
get
([
'select'
=>
[
'id'
,
'res_id'
,
'item_id'
,
'mode'
],
'where'
=>
[
'type = ?'
,
'item_id = ?'
,
'res_id in (?)'
],
'data'
=>
[
'entity'
,
$successorEntity
[
'id'
],
array_uniq
(
array_column
(
$dyingOcc
,
'res_id'
))]]);
$dyingIds
=
array_column
(
$dyingOcc
,
'id'
);
$idsToDelete
=
[];
foreach
(
$dyingOcc
as
$d
)
{
foreach
(
$succOcc
as
$s
)
{
if
(
$d
[
'mode'
]
==
$s
[
'mode'
]
&&
$d
[
'res_id'
]
==
$s
[
'res_id'
])
{
$idsToDelete
[]
=
$d
[
'id'
];
}
}
}
ResourceContactModel
::
delete
([
'where'
=>
[
'id in (?)'
],
'data'
=>
[
$idsToDelete
]]);
ResourceContactModel
::
update
([
'set'
=>
[
'item_id'
=>
$successorEntity
[
'id'
]],
'where'
=>
[
'id in (?)'
],
'data'
=>
[
$dyingIds
]]);
EntityModel
::
delete
([
'where'
=>
[
'entity_id = ?'
],
'data'
=>
[
$aArgs
[
'id'
]]]);
HistoryController
::
add
([
'tableName'
=>
'entities'
,
'recordId'
=>
$aArgs
[
'id'
],
...
...
src/frontend/app/administration/entity/entities-administration-redirect-modal.component.html
View file @
cfa40410
...
...
@@ -15,6 +15,12 @@
<b>
{{data.entity.entity_label}}
</b>
{{'lang.isCopyTo' | translate}}
<b>
{{data.entity.instances}}
</b>
{{'lang.documents' | translate}}
</p>
</mat-list-item>
<mat-list-item
*ngIf=
"data.entity.contact > 0"
>
<mat-icon
color=
"primary"
mat-list-icon
class=
"fa fa-address-book fa-2x"
></mat-icon>
<p
mat-line
>
<b>
{{data.entity.entity_label}}
</b>
{{'lang.isLinkedTo' | translate | lowercase}}
<b>
{{data.entity.contact}}
</b>
{{'lang.contactsEntity' | translate | lowercase}}
</p>
</mat-list-item>
<mat-list-item
*ngIf=
"data.entity.users.length > 0"
>
<mat-icon
color=
"primary"
mat-list-icon
class=
"fa fa-user fa-2x"
></mat-icon>
<p
mat-line
>
...
...
src/lang/lang-fr.json
View file @
cfa40410
...
...
@@ -378,6 +378,7 @@
"contacts"
:
"Contacts"
,
"contactsAdmin"
:
"Administration des contacts"
,
"contactsAlt"
:
"Contact(s)"
,
"contactsEntity"
:
"courrier(s) en tant que contact"
,
"contactsFillingAdministration"
:
"Complétude des informations contacts"
,
"contactsFillingCriteria"
:
"Critères de complétude"
,
"contactsFillingRate"
:
"Taux de complétude"
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment