diff --git a/apps/maarch_entreprise/js/indexing.js b/apps/maarch_entreprise/js/indexing.js index 6cc9e4084810947a5e8c5b65515d94a4c1f29d18..0e70167da8dcc339d8d10bb9c2d43e1e0054c630 100755 --- a/apps/maarch_entreprise/js/indexing.js +++ b/apps/maarch_entreprise/js/indexing.js @@ -1983,10 +1983,13 @@ function initSenderRecipientAutocomplete(inputId, mode) { $j("#" + inputId + "_type").val(''); }, onLayoutBuiltBefore: function (node, query, result, resultHtmlList) { - $j.each(resultHtmlList.find('li'), function (i, target) { - $j(target).css({"background-color":"#dadadada"}); - console.log(target); - }); + if (typeof resultHtmlList != "undefined" && result.length > 0) { + $j.each(resultHtmlList.find('li'), function (i, target) { + if (result[i]['type'] == "contact" && result[i]["rateColor"] != "") { + $j(target).css({"background-color" : result[i]["rateColor"]}); + } + }); + } return resultHtmlList; } } diff --git a/src/core/controllers/AutoCompleteController.php b/src/core/controllers/AutoCompleteController.php index d3ba9fc2d598f3d7bb2a473f23d18dc380309dd6..567d080beaf4ec77e714180955f9c143f89121bc 100644 --- a/src/core/controllers/AutoCompleteController.php +++ b/src/core/controllers/AutoCompleteController.php @@ -14,6 +14,7 @@ namespace SrcCore\controllers; +use Contact\controllers\ContactController; use Contact\controllers\ContactGroupController; use Contact\models\ContactModel; use Respect\Validation\Validator; @@ -30,6 +31,7 @@ use User\models\UserModel; class AutoCompleteController { const LIMIT = 50; + const TINY_LIMIT = 5; public static function getContacts(Request $request, Response $response) { @@ -142,13 +144,10 @@ class AutoCompleteController } $contacts = ContactModel::getOnView([ - 'select' => [ - 'ca_id', 'firstname', 'lastname', 'contact_lastname', 'contact_firstname', 'society', 'address_num', - 'address_street', 'address_town', 'address_postal_code', 'is_corporate_person' - ], + 'select' => ['*'], 'where' => $where, 'data' => $requestData, - 'limit' => self::LIMIT + 'limit' => self::TINY_LIMIT ]); $autocompleteData = []; @@ -171,7 +170,7 @@ class AutoCompleteController 'where' => $requestData['where'], 'data' => $requestData['data'], 'orderBy' => ['lastname'], - 'limit' => self::LIMIT + 'limit' => self::TINY_LIMIT ]); foreach ($users as $value) { @@ -463,6 +462,9 @@ class AutoCompleteController ValidatorModel::notEmpty($aArgs, ['contact']); ValidatorModel::arrayType($aArgs, ['contact']); + $rate = ContactController::getFillingRate(['contact' => $aArgs['contact']]); + $rateColor = empty($rate['color']) ? '' : $rate['color']; + $address = ''; if ($aArgs['contact']['is_corporate_person'] == 'Y') { $address.= $aArgs['contact']['firstname']; @@ -488,7 +490,8 @@ class AutoCompleteController 'contact' => $aArgs['contact']['society'], 'address' => $address, 'idToDisplay' => "{$aArgs['contact']['society']}<br/>{$address}", - 'otherInfo' => "{$aArgs['contact']['society']} - {$address}" + 'otherInfo' => "{$aArgs['contact']['society']} - {$address}", + 'rateColor' => $rateColor ]; } else { if (!empty($aArgs['contact']['address_num'])) { @@ -514,7 +517,8 @@ class AutoCompleteController 'contact' => $contactToDisplay, 'address' => $address, 'idToDisplay' => "{$contactToDisplay}<br/>{$address}", - 'otherInfo' => "{$contactToDisplay} - {$address}" + 'otherInfo' => "{$contactToDisplay} - {$address}", + 'rateColor' => $rateColor ]; }