From 00b6d6a5353c10398c80a5fa4dc05b1a86264493 Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Mon, 23 Dec 2019 17:01:05 +0100 Subject: [PATCH] FEAT #12635 TIME 0:15 Fix autocomplete lastname nulls first + get civilities --- rest/index.php | 1 + src/app/contact/controllers/ContactController.php | 7 +++++++ src/app/contact/models/ContactModel.php | 10 ++++++---- src/core/controllers/AutoCompleteController.php | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/rest/index.php b/rest/index.php index 97e45fbee63..ab3d2f7ee72 100755 --- a/rest/index.php +++ b/rest/index.php @@ -137,6 +137,7 @@ $app->post('/contactsGroups/{id}/contacts', \Contact\controllers\ContactGroupCon $app->delete('/contactsGroups/{id}/contacts/{contactId}', \Contact\controllers\ContactGroupController::class . ':deleteContact'); $app->get('/contactsParameters', \Contact\controllers\ContactController::class . ':getContactsParameters'); $app->put('/contactsParameters', \Contact\controllers\ContactController::class . ':updateContactsParameters'); +$app->get('/civilities', \Contact\controllers\ContactController::class . ':getCivilities'); //Convert $app->post('/convertedFile', \Convert\controllers\ConvertPdfController::class . ':convertedFile'); diff --git a/src/app/contact/controllers/ContactController.php b/src/app/contact/controllers/ContactController.php index e633252cce6..87df30f994f 100755 --- a/src/app/contact/controllers/ContactController.php +++ b/src/app/contact/controllers/ContactController.php @@ -503,6 +503,13 @@ class ContactController return $response->withJson(['contact' => $contact]); } + public static function getCivilities(Request $request, Response $response) + { + $civilities = ContactModel::getCivilities(); + + return $response->withJson(['civilities' => $civilities]); + } + public static function getFillingRate(array $aArgs) { ValidatorModel::notEmpty($aArgs, ['contactId']); diff --git a/src/app/contact/models/ContactModel.php b/src/app/contact/models/ContactModel.php index b0ee39ea56b..5625f13b21d 100755 --- a/src/app/contact/models/ContactModel.php +++ b/src/app/contact/models/ContactModel.php @@ -190,10 +190,12 @@ class ContactModel $result = $loadedXml->xpath('/ROOT/titles'); foreach ($result as $title) { foreach ($title as $value) { - $civilities[(string) $value->id] = [ - 'label' => (string)$value->label, - 'abbreviation' => (string)$value->abbreviation, - ]; + if (!empty((string) $value->id)) { + $civilities[(string) $value->id] = [ + 'label' => (string)$value->label, + 'abbreviation' => (string)$value->abbreviation, + ]; + } } } } diff --git a/src/core/controllers/AutoCompleteController.php b/src/core/controllers/AutoCompleteController.php index 6ff31de499d..b2c822f67d8 100755 --- a/src/core/controllers/AutoCompleteController.php +++ b/src/core/controllers/AutoCompleteController.php @@ -183,7 +183,7 @@ class AutoCompleteController 'select' => ['id'], 'where' => $requestData['where'], 'data' => $requestData['data'], - 'orderBy' => ['company', 'lastname'], + 'orderBy' => ['company', 'lastname NULLS FIRST'], 'limit' => self::TINY_LIMIT ]); -- GitLab