From 20c993236f92d8e4edf1965fc468e668aa3c32ad Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared.hancock@cleco.com>
Date: Fri, 15 Feb 2019 16:35:53 -0600
Subject: [PATCH] users: Fix seaching of users

The CDATA table may be dropped on upgrade and is not created on new installs.
So it should be created on demand when searching for users.
---
 include/ajax.users.php | 4 +++-
 scp/js/scp.js          | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/ajax.users.php b/include/ajax.users.php
index 328b93cf0..4e090889a 100644
--- a/include/ajax.users.php
+++ b/include/ajax.users.php
@@ -79,8 +79,10 @@ class UsersAjaxAPI extends AjaxController {
                     'org__name__contains' => $q,
                     'account__username__contains' => $q,
                 ));
-                if (UserForm::getInstance()->getField('phone'))
+                if (UserForm::getInstance()->getField('phone')) {
+                    UserForm::ensureDynamicDataView();
                     $filter->add(array('cdata__phone__contains' => $q));
+                }
 
                 $users->filter($filter);
             }
diff --git a/scp/js/scp.js b/scp/js/scp.js
index c83673cd3..c567f2af1 100644
--- a/scp/js/scp.js
+++ b/scp/js/scp.js
@@ -475,7 +475,7 @@ var scp_prep = function() {
 
   $('div.tab_content[id] div.error:not(:empty)').each(function() {
     var div = $(this).closest('.tab_content');
-    $('a[href^=#'+div.attr('id')+']').parent().addClass('error');
+    $('a[href^="#'+div.attr('id')+'"]').parent().addClass('error');
   });
 
   $('[data-toggle="tooltip"]').tooltip()
-- 
GitLab