Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Maarch
MaarchCourrier
Commits
9e9e3166
Commit
9e9e3166
authored
May 26, 2021
by
Guillaume Heurtier
Browse files
FEAT #14753 TIME 6:10 added contact address sector field
parent
43c6c39a
Changes
10
Hide whitespace changes
Inline
Side-by-side
sql/data_fr.sql
View file @
9e9e3166
...
...
@@ -248,6 +248,7 @@ INSERT INTO contacts_parameters (id, identifier, mandatory, filling, searchable,
INSERT
INTO
contacts_parameters
(
id
,
identifier
,
mandatory
,
filling
,
searchable
,
displayable
)
VALUES
(
14
,
'email'
,
false
,
true
,
false
,
false
);
INSERT
INTO
contacts_parameters
(
id
,
identifier
,
mandatory
,
filling
,
searchable
,
displayable
)
VALUES
(
15
,
'phone'
,
false
,
true
,
false
,
false
);
INSERT
INTO
contacts_parameters
(
id
,
identifier
,
mandatory
,
filling
,
searchable
,
displayable
)
VALUES
(
16
,
'notes'
,
false
,
false
,
false
,
false
);
INSERT
INTO
contacts_parameters
(
id
,
identifier
,
mandatory
,
filling
,
searchable
,
displayable
)
VALUES
(
17
,
'sector'
,
false
,
false
,
false
,
false
);
INSERT
INTO
custom_fields
(
id
,
label
,
type
,
mode
,
"values"
)
VALUES
(
1
,
'Date de fin de contrat'
,
'date'
,
'form'
,
'[]'
);
INSERT
INTO
custom_fields
(
id
,
label
,
type
,
mode
,
"values"
)
VALUES
(
2
,
'Adresse d
''
intervention'
,
'banAutocomplete'
,
'form'
,
'[]'
);
...
...
sql/structure.sql
View file @
9e9e3166
...
...
@@ -767,6 +767,7 @@ CREATE TABLE contacts
enabled
boolean
NOT
NULL
DEFAULT
TRUE
,
custom_fields
jsonb
DEFAULT
'{}'
,
external_id
jsonb
DEFAULT
'{}'
,
sector
CHARACTER
VARYING
(
256
),
CONSTRAINT
contacts_pkey
PRIMARY
KEY
(
id
)
)
WITH
(
OIDS
=
FALSE
);
...
...
@@ -1538,3 +1539,17 @@ CREATE TABLE tiles
CONSTRAINT
tiles_pkey
PRIMARY
KEY
(
id
)
)
WITH
(
OIDS
=
FALSE
);
CREATE
TABLE
address_sectors
(
id
SERIAL
NOT
NULL
,
address_number
CHARACTER
VARYING
(
256
),
address_street
CHARACTER
VARYING
(
256
),
address_postcode
CHARACTER
VARYING
(
256
),
address_town
CHARACTER
VARYING
(
256
),
label
CHARACTER
VARYING
(
256
),
ban_id
CHARACTER
VARYING
(
256
),
CONSTRAINT
address_sectors_key
UNIQUE
(
address_number
,
address_street
,
address_postcode
,
address_town
),
CONSTRAINT
address_sectors_pkey
PRIMARY
KEY
(
id
)
)
WITH
(
OIDS
=
FALSE
);
src/app/contact/controllers/ContactController.php
View file @
9e9e3166
...
...
@@ -15,6 +15,7 @@ namespace Contact\controllers;
use
AcknowledgementReceipt\models\AcknowledgementReceiptModel
;
use
Attachment\models\AttachmentModel
;
use
Contact\models\ContactAddressSectorModel
;
use
Contact\models\ContactCivilityModel
;
use
Contact\models\ContactCustomFieldListModel
;
use
Contact\models\ContactFillingModel
;
...
...
@@ -57,7 +58,8 @@ class ContactController
'addressCountry'
=>
'address_country'
,
'email'
=>
'email'
,
'phone'
=>
'phone'
,
'notes'
=>
'notes'
'notes'
=>
'notes'
,
'sector'
=>
'sector'
];
public
function
get
(
Request
$request
,
Response
$response
)
...
...
@@ -91,7 +93,7 @@ class ContactController
'select'
=>
[
'id'
,
'firstname'
,
'lastname'
,
'company'
,
'address_number as "addressNumber"'
,
'address_street as "addressStreet"'
,
'address_additional1 as "addressAdditional1"'
,
'address_additional2 as "addressAdditional2"'
,
'address_postcode as "addressPostcode"'
,
'address_town as "addressTown"'
,
'address_country as "addressCountry"'
,
'enabled'
,
'count(1) OVER()'
'address_town as "addressTown"'
,
'address_country as "addressCountry"'
,
'enabled'
,
'sector'
,
'count(1) OVER()'
],
'where'
=>
$requestData
[
'where'
]
??
null
,
'data'
=>
$requestData
[
'data'
]
??
null
,
...
...
@@ -168,6 +170,8 @@ class ContactController
$externalId
=
'{}'
;
}
$sector
=
ContactController
::
getAddressSector
(
$body
);
$id
=
ContactModel
::
create
([
'civility'
=>
$body
[
'civility'
]
??
null
,
'firstname'
=>
$body
[
'firstname'
]
??
null
,
...
...
@@ -189,7 +193,8 @@ class ContactController
'creator'
=>
$GLOBALS
[
'id'
],
'enabled'
=>
'true'
,
'custom_fields'
=>
!
empty
(
$body
[
'customFields'
])
?
json_encode
(
$body
[
'customFields'
])
:
'{}'
,
'external_id'
=>
$externalId
'external_id'
=>
$externalId
,
'sector'
=>
$sector
[
'label'
]
??
null
]);
$historyInfoContact
=
''
;
...
...
@@ -252,7 +257,8 @@ class ContactController
'creationDate'
=>
$rawContact
[
'creation_date'
],
'modificationDate'
=>
$rawContact
[
'modification_date'
],
'customFields'
=>
!
empty
(
$rawContact
[
'custom_fields'
])
?
json_decode
(
$rawContact
[
'custom_fields'
],
true
)
:
null
,
'externalId'
=>
json_decode
(
$rawContact
[
'external_id'
],
true
)
'externalId'
=>
json_decode
(
$rawContact
[
'external_id'
],
true
),
'sector'
=>
$rawContact
[
'sector'
]
];
if
(
!
empty
(
$rawContact
[
'civility'
]))
{
...
...
@@ -340,6 +346,8 @@ class ContactController
$externalId
=
'{}'
;
}
$sector
=
ContactController
::
getAddressSector
(
$body
);
ContactModel
::
update
([
'set'
=>
[
'civility'
=>
$body
[
'civility'
]
??
null
,
...
...
@@ -361,7 +369,8 @@ class ContactController
'notes'
=>
$body
[
'notes'
]
??
null
,
'modification_date'
=>
'CURRENT_TIMESTAMP'
,
'custom_fields'
=>
!
empty
(
$body
[
'customFields'
])
?
json_encode
(
$body
[
'customFields'
])
:
null
,
'external_id'
=>
$externalId
'external_id'
=>
$externalId
,
'sector'
=>
$sector
[
'label'
]
??
null
],
'where'
=>
[
'id = ?'
],
'data'
=>
[
$args
[
'id'
]]
...
...
@@ -1134,6 +1143,7 @@ class ContactController
'enabled'
=>
'enabled'
,
'customFields'
=>
'custom_fields'
,
'externalId'
=>
'external_id'
,
'sector'
=>
'sector'
];
$contactCustoms
=
ContactCustomFieldListModel
::
get
([
'select'
=>
[
'id'
]]);
...
...
@@ -1745,7 +1755,10 @@ class ContactController
$address
.
=
$args
[
'contact'
][
'address_town'
]
.
' '
;
}
if
(
!
empty
(
$args
[
'contact'
][
'address_country'
]))
{
$address
.
=
$args
[
'contact'
][
'address_country'
];
$address
.
=
$args
[
'contact'
][
'address_country'
]
.
' '
;
}
if
(
!
empty
(
$args
[
'contact'
][
'sector'
]))
{
$address
.
=
$args
[
'contact'
][
'sector'
];
}
$contactName
=
''
;
...
...
@@ -1860,6 +1873,9 @@ class ContactController
if
(
in_array
(
'notes'
,
$displayableStdParameters
))
{
$contact
[
'notes'
]
=
$rawContact
[
'notes'
];
}
if
(
in_array
(
'sector'
,
$displayableStdParameters
))
{
$contact
[
'sector'
]
=
$rawContact
[
'sector'
];
}
if
(
!
empty
(
$displayableCstParameters
))
{
$contact
[
'customFields'
]
=
[];
...
...
@@ -1909,4 +1925,52 @@ class ContactController
return
$contactsUsed
;
}
private
static
function
getAddressSector
(
array
$args
)
{
ValidatorModel
::
stringType
(
$args
,
[
'addressNumber'
,
'addressStreet'
,
'addressPostcode'
,
'addressTown'
]);
$where
=
[];
$data
=
[];
if
(
!
empty
(
$args
[
'addressNumber'
]))
{
$where
[]
=
'address_number = ?'
;
$data
[]
=
strtoupper
(
$args
[
'addressNumber'
]);
}
else
{
$where
[]
=
'address_number is null'
;
}
if
(
!
empty
(
$args
[
'addressStreet'
]))
{
$where
[]
=
'address_street = ?'
;
$data
[]
=
strtoupper
(
$args
[
'addressStreet'
]);
}
else
{
$where
[]
=
'address_street is null'
;
}
if
(
!
empty
(
$args
[
'addressPostcode'
]))
{
$where
[]
=
'address_postcode = ?'
;
$data
[]
=
strtoupper
(
$args
[
'addressPostcode'
]);
}
else
{
$where
[]
=
'address_postcode is null'
;
}
if
(
!
empty
(
$args
[
'addressTown'
]))
{
$where
[]
=
'address_town = ?'
;
$data
[]
=
strtoupper
(
$args
[
'addressTown'
]);
}
else
{
$where
[]
=
'address_town is null'
;
}
$sector
=
ContactAddressSectorModel
::
get
([
'select'
=>
[
'*'
],
'where'
=>
$where
,
'data'
=>
$data
]);
if
(
empty
(
$sector
[
0
]))
{
return
null
;
}
return
$sector
[
0
];
}
}
src/app/contact/models/ContactAddressSectorModel.php
0 → 100644
View file @
9e9e3166
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
/**
* @brief Contact Address Sector Model
* @author dev@maarch.org
*/
namespace
Contact\models
;
use
SrcCore\models\DatabaseModel
;
use
SrcCore\models\ValidatorModel
;
class
ContactAddressSectorModel
{
public
static
function
get
(
array
$args
)
{
ValidatorModel
::
notEmpty
(
$args
,
[
'select'
]);
ValidatorModel
::
arrayType
(
$args
,
[
'select'
,
'where'
,
'data'
,
'orderBy'
]);
ValidatorModel
::
intType
(
$args
,
[
'limit'
]);
$sectors
=
DatabaseModel
::
select
([
'select'
=>
$args
[
'select'
],
'table'
=>
[
'address_sectors'
],
'where'
=>
empty
(
$args
[
'where'
])
?
[]
:
$args
[
'where'
],
'data'
=>
empty
(
$args
[
'data'
])
?
[]
:
$args
[
'data'
],
'order_by'
=>
empty
(
$args
[
'orderBy'
])
?
[]
:
$args
[
'orderBy'
],
'offset'
=>
empty
(
$args
[
'offset'
])
?
0
:
$args
[
'offset'
],
'limit'
=>
empty
(
$args
[
'limit'
])
?
0
:
$args
[
'limit'
]
]);
return
$sectors
;
}
public
static
function
getById
(
array
$args
)
{
ValidatorModel
::
notEmpty
(
$args
,
[
'id'
,
'select'
]);
ValidatorModel
::
intVal
(
$args
,
[
'id'
]);
ValidatorModel
::
arrayType
(
$args
,
[
'select'
]);
$sector
=
DatabaseModel
::
select
([
'select'
=>
$args
[
'select'
],
'table'
=>
[
'address_sectors'
],
'where'
=>
[
'id = ?'
],
'data'
=>
[
$args
[
'id'
]]
]);
if
(
empty
(
$sector
[
0
]))
{
return
[];
}
return
$sector
[
0
];
}
public
static
function
create
(
array
$args
)
{
ValidatorModel
::
notEmpty
(
$args
,
[
'label'
,
'abbreviation'
]);
ValidatorModel
::
stringType
(
$args
,
[
'label'
,
'abbreviation'
]);
$nextSequenceId
=
DatabaseModel
::
getNextSequenceValue
([
'sequenceId'
=>
'address_sectors_id_seq'
]);
DatabaseModel
::
insert
([
'table'
=>
'address_sectors'
,
'columnsValues'
=>
[
'id'
=>
$nextSequenceId
,
'label'
=>
$args
[
'label'
],
'abbreviation'
=>
$args
[
'abbreviation'
]
]
]);
return
$nextSequenceId
;
}
public
static
function
update
(
array
$args
)
{
ValidatorModel
::
notEmpty
(
$args
,
[
'set'
,
'where'
,
'data'
]);
ValidatorModel
::
arrayType
(
$args
,
[
'set'
,
'where'
,
'data'
]);
DatabaseModel
::
update
([
'table'
=>
'address_sectors'
,
'set'
=>
$args
[
'set'
],
'where'
=>
$args
[
'where'
],
'data'
=>
$args
[
'data'
]
]);
return
true
;
}
public
static
function
delete
(
array
$args
)
{
ValidatorModel
::
notEmpty
(
$args
,
[
'where'
,
'data'
]);
ValidatorModel
::
arrayType
(
$args
,
[
'where'
,
'data'
]);
DatabaseModel
::
delete
([
'table'
=>
'address_sectors'
,
'where'
=>
$args
[
'where'
],
'data'
=>
$args
[
'data'
]
]);
return
true
;
}
}
src/frontend/app/administration/contact/page/form/contacts-form.component.html
View file @
9e9e3166
...
...
@@ -275,7 +275,7 @@
</button>
</mat-list-item>
<ng-container
*ngIf=
"unit.id === 'address' && addressBANMode && ['addressAdditional1', 'addressAdditional2'].indexOf(field.id) > -1"
>
*ngIf=
"unit.id === 'address' && addressBANMode && ['addressAdditional1', 'addressAdditional2'
, 'sector'
].indexOf(field.id) > -1"
>
<mat-list-item
class=
"contact-item"
>
<p
mat-line
class=
"contact-content"
*ngIf=
"field.display"
>
<mat-form-field>
...
...
src/frontend/app/administration/contact/page/form/contacts-form.component.ts
View file @
9e9e3166
...
...
@@ -255,6 +255,17 @@ export class ContactsFormComponent implements OnInit {
filling
:
false
,
values
:
[]
},
{
id
:
'
sector
'
,
unit
:
'
address
'
,
label
:
this
.
translate
.
instant
(
'
lang.contactsParameters_sector
'
),
type
:
'
string
'
,
control
:
new
FormControl
({
value
:
''
,
disabled
:
true
}),
required
:
false
,
display
:
true
,
filling
:
false
,
values
:
[]
},
{
id
:
'
communicationMeans
'
,
unit
:
'
maarch2maarch
'
,
...
...
src/frontend/app/contact/autocomplete/contact-autocomplete.component.html
View file @
9e9e3166
...
...
@@ -73,6 +73,8 @@
{{option.addressTown}}
</p>
<p
mat-line
class=
"contact-content"
*ngIf=
"!empty(option.addressCountry)"
[title]=
"option.addressCountry"
>
{{option.addressCountry}}
</p>
<p
mat-line
class=
"contact-content"
*ngIf=
"!empty(option.sector)"
[title]=
"option.sector"
>
{{option.sector}}
</p>
</mat-list-item>
<mat-list-item
class=
"contact-item"
*ngIf=
"!empty(option.notes)"
>
<mat-icon
mat-list-icon
class=
"contact-group far fa-sticky-note"
[title]=
"'lang.note' | translate"
>
...
...
src/frontend/app/contact/contact-detail/contact-detail.component.html
View file @
9e9e3166
...
...
@@ -76,6 +76,11 @@
<p
mat-line
class=
"contact-content"
*ngIf=
"!functionsService.empty(contact.addressCountry)"
[class.newData]=
"isNewValue('addressCountry')"
>
{{contact.addressCountry}}
</p>
</mat-list-item>
<mat-list-item
class=
"contact-item"
*ngIf=
"!functionsService.empty(contact.sector)"
>
<mat-icon
mat-list-icon
class=
"contact-group fas fa-map-marked-alt"
[title]=
"'lang.contactsParameters_sector' | translate"
>
</mat-icon>
<p
mat-line
class=
"contact-content"
>
{{contact.sector}}
</p>
</mat-list-item>
</mat-list>
<mat-expansion-panel
*ngIf=
"!emptyOtherInfo(contact)"
[expanded]=
"selectable"
>
<mat-expansion-panel-header>
...
...
src/lang/lang-en.json
View file @
9e9e3166
...
...
@@ -2514,5 +2514,6 @@
"youSign"
:
"Yousign"
,
"source"
:
"Source"
,
"isRequired"
:
"is required"
,
"updateOtp"
:
"Edit external user"
}
\ No newline at end of file
"updateOtp"
:
"Edit external user"
,
"contactsParameters_sector"
:
"Sector"
}
src/lang/lang-fr.json
View file @
9e9e3166
...
...
@@ -2510,5 +2510,6 @@
"suggestedCorrespondents"
:
"Correspondant(s) suggéré(s)"
,
"searchCorrespondent"
:
"Rechercher un correspondant"
,
"viewSuggestions"
:
"Voir les suggestions"
,
"noSuggestion"
:
"Aucune suggestion"
"noSuggestion"
:
"Aucune suggestion"
,
"contactsParameters_sector"
:
"Secteur"
}
Write
Preview
Markdown
is supported
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