alqindiirsyam преди 2 години
родител
ревизия
cc5f1431d9

+ 1 - 11
appbuilder-ios/AppBuilder/AppBuilder/FourthTabViewController.swift

@@ -151,17 +151,7 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
         Database.shared.database?.inTransaction({ fmdb, rollback in
             let idMe = UserDefaults.standard.string(forKey: "me") as String?
             if let cursorUser = Database.shared.getRecords(fmdb: fmdb, query: "SELECT user_type, image_id, official_account FROM BUDDY where f_pin='\(idMe!)'"), cursorUser.next() {
-                var groupId = ""
-                if let cursorGroup = Database.shared.getRecords(fmdb: fmdb, query: "SELECT group_id FROM GROUPZ where group_type = 1 AND official = 1"), cursorGroup.next() {
-                    groupId = cursorGroup.string(forColumnIndex: 0) ?? ""
-                    cursorGroup.close()
-                }
-                var position = ""
-                if let cursorIsAdmin = Database.shared.getRecords(fmdb: fmdb, query: "SELECT position FROM GROUPZ_MEMBER where group_id = '\(groupId)' AND f_pin = '\(idMe!)'"), cursorIsAdmin.next() {
-                    position = cursorIsAdmin.string(forColumnIndex: 0) ?? ""
-                    cursorIsAdmin.close()
-                }
-                if ( User.isInternal(userType: cursorUser.string(forColumnIndex: 0) ?? "") && position == "1") || User.isOfficial(official_account: cursorUser.string(forColumnIndex: 2) ?? "") || User.isOfficial(official_account: cursorUser.string(forColumnIndex: 2) ?? "") {
+                if (User.isInternal(userType: cursorUser.string(forColumnIndex: 0) ?? "") && User.isAdmin(fmdb: fmdb)) || User.isOfficial(official_account: cursorUser.string(forColumnIndex: 2) ?? "") || User.isOfficial(official_account: cursorUser.string(forColumnIndex: 2) ?? "") {
                     Item.menus["Personal"] = [
                         Item(icon: UIImage(systemName: "person"), title: "Personal Information".localized()),
                         Item(icon: UIImage(systemName: "textformat.abc"), title: "Change Language".localized()),

+ 3 - 0
appbuilder-ios/NexilisLite/NexilisLite/Resource/id.lproj/Localizable.strings

@@ -314,3 +314,6 @@
 "91:Invalid name or you must add Username to your contact first" = "91:Nama tidak valid atau Anda harus menambahkan Nama Pengguna ke kontak Anda terlebih dahulu";
 "108:Invalid Contact Center media parameter (0:Chat, 1:Audio Call, 2:Video Call)" = "108:Parameter media Pusat Panggilan tidak valid (0:Obrolan, 1:Panggilan Audio, 2:Panggilan Video)";
 "109:Invalid Contact Center category parameter" = "109:Parameter kategori Pusat Panggilan tidak valid";
+"111:You must Sign In as Admin to use this feature" = "111:Anda harus masuk sebagai admin agar dapat menggunakan fitur ini";
+"112:You already login or registered as Admin" = "112:Anda telah masuk atau terdaftar sebagai admin";
+"113:Password is empty" = "113:Kata sandi kosong";

+ 107 - 2
appbuilder-ios/NexilisLite/NexilisLite/Source/APIS.swift

@@ -10,6 +10,7 @@ import UIKit
 import FMDB
 import NotificationBannerSwift
 import Toast_Swift
+import nuSDKService
 
 public class APIS: NSObject {
     public static func connect(apiKey: String, delegate: ConnectDelegate, showButton: Bool = true) {
@@ -65,8 +66,8 @@ public class APIS: NSObject {
                 UIApplication.shared.visibleViewController?.present(navigationController, animated: true, completion: nil)
             }
         } else {
-            if media != nil {
-                if media! < 0 || media! > 2 {
+            if media != nil || (media == nil && category != nil) {
+                if media == nil || media! < 0 || media! > 2 {
                     UIApplication.shared.visibleViewController?.view.makeToast("108:Invalid Contact Center media parameter (0:Chat, 1:Audio Call, 2:Video Call)".localized(), duration: 2)
                     return
                 }
@@ -95,6 +96,11 @@ public class APIS: NSObject {
             }
             let controller = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "editorPersonalVC") as! EditorPersonal
             controller.isContactCenter = true
+            if media != nil {
+                controller.isDirectCC = true
+                controller.channelContactCenter = "\(media!)"
+                controller.serviceIdCC = category == nil ? "" : "\(category!)"
+            }
             let navigationController = UINavigationController(rootViewController: controller)
             navigationController.defaultStyle()
             if UIApplication.shared.visibleViewController?.navigationController != nil {
@@ -578,6 +584,105 @@ public class APIS: NSObject {
             UIApplication.shared.visibleViewController?.present(navigationController, animated: true, completion: nil)
         }
     }
+    
+    public static func signInAdmin(password: String) {
+        if password.isEmpty {
+            UIApplication.shared.visibleViewController?.view.makeToast("113:Password is empty".localized(), duration: 2)
+            return
+        }
+        let isChangeProfile = Utils.getSetProfile()
+        if !isChangeProfile {
+            APIS.showChangeProfile()
+            return
+        }
+        let isAdmin = User.isAdmin()
+        if isAdmin {
+            UIApplication.shared.visibleViewController?.view.makeToast("112:You already login or registered as Admin".localized(), duration: 2)
+            return
+        }
+        if !CheckConnection.isConnectedToNetwork()  || API.nGetCLXConnState() == 0 {
+            let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+            imageView.tintColor = .white
+            let banner = FloatingNotificationBanner(title: "Check your connection".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
+            banner.show()
+            return
+        }
+        Nexilis.showLoader()
+        self.signInAdmin(password: password, completion: { result in
+            if result {
+                DispatchQueue.main.async {
+                    Nexilis.hideLoader {
+                        let imageView = UIImageView(image: UIImage(systemName: "checkmark.circle.fill"))
+                        imageView.tintColor = .white
+                        let banner = FloatingNotificationBanner(title: "Successfully Sign-In Admin".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .success, colors: nil, iconPosition: .center)
+                        banner.show()
+                    }
+                }
+            } else {
+                DispatchQueue.main.async {
+                    Nexilis.hideLoader {}
+                }
+            }
+        })
+    }
+    
+    private static func signInAdmin(password: String, completion: @escaping (Bool) -> ()) {
+        DispatchQueue.global().async {
+            let idMe = UserDefaults.standard.string(forKey: "me") as String?
+            let p_password = password
+            let md5Hex = p_password
+            var result: Bool = false
+            if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.getSignInApiAdmin(p_name: idMe!, p_password: md5Hex)) {
+                if response.isOk() {
+                    result = true
+                }
+                DispatchQueue.main.async {
+                    if response.getBody(key: CoreMessage_TMessageKey.ERRCOD, default_value: "99") == "11" {
+                        let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+                        imageView.tintColor = .white
+                        let banner = FloatingNotificationBanner(title: "Username or password does not match".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .top)
+                        banner.show()
+                    } else if response.getBody(key: CoreMessage_TMessageKey.ERRCOD, default_value: "99") == "20" {
+                        let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+                        imageView.tintColor = .white
+                        let banner = FloatingNotificationBanner(title: "Invalid password".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .top)
+                        banner.show()
+                    }
+                }
+            } else {
+                DispatchQueue.main.async {
+                    let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+                    imageView.tintColor = .white
+                    let banner = FloatingNotificationBanner(title: "Unable to access servers".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .top)
+                    banner.show()
+                }
+            }
+            completion(result)
+        }
+    }
+    
+    public static func openSetAsOfficerForm() {
+        let isChangeProfile = Utils.getSetProfile()
+        if !isChangeProfile {
+            APIS.showChangeProfile()
+            return
+        }
+        let isAdmin = User.isAdmin()
+        if !isAdmin {
+            UIApplication.shared.visibleViewController?.view.makeToast("111:You must Sign In as Admin to use this feature".localized(), duration: 2)
+            return
+        }
+        let controller = SetInternalCSAccount()
+        controller.isSetCS = true
+        controller.fromNotification = true
+        let navigationController = UINavigationController(rootViewController: controller)
+        navigationController.defaultStyle()
+        if UIApplication.shared.visibleViewController?.navigationController != nil {
+            UIApplication.shared.visibleViewController?.navigationController?.present(navigationController, animated: true, completion: nil)
+        } else {
+            UIApplication.shared.visibleViewController?.present(navigationController, animated: true, completion: nil)
+        }
+    }
 }
 
 extension UINavigationController {

+ 28 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/Model/User.swift

@@ -83,6 +83,34 @@ public class User: Model {
         return userType == "24"
     }
     
+    public static func isAdmin(fmdb: FMDatabase? = nil) -> Bool {
+        var position = ""
+        if fmdb == nil {
+            Database.shared.database?.inTransaction({ fmdb, rollback in
+                var groupId = ""
+                if let cursorGroup = Database.shared.getRecords(fmdb: fmdb, query: "SELECT group_id FROM GROUPZ where group_type = 1 AND official = 1"), cursorGroup.next() {
+                    groupId = cursorGroup.string(forColumnIndex: 0) ?? ""
+                    cursorGroup.close()
+                }
+                if let cursorIsAdmin = Database.shared.getRecords(fmdb: fmdb, query: "SELECT position FROM GROUPZ_MEMBER where group_id = '\(groupId)' AND f_pin = '\(User.getMyPin()!)'"), cursorIsAdmin.next() {
+                    position = cursorIsAdmin.string(forColumnIndex: 0) ?? ""
+                    cursorIsAdmin.close()
+                }
+            })
+        } else {
+            var groupId = ""
+            if let cursorGroup = Database.shared.getRecords(fmdb: fmdb!, query: "SELECT group_id FROM GROUPZ where group_type = 1 AND official = 1"), cursorGroup.next() {
+                groupId = cursorGroup.string(forColumnIndex: 0) ?? ""
+                cursorGroup.close()
+            }
+            if let cursorIsAdmin = Database.shared.getRecords(fmdb: fmdb!, query: "SELECT position FROM GROUPZ_MEMBER where group_id = '\(groupId)' AND f_pin = '\(User.getMyPin()!)'"), cursorIsAdmin.next() {
+                position = cursorIsAdmin.string(forColumnIndex: 0) ?? ""
+                cursorIsAdmin.close()
+            }
+        }
+        return position == "1"
+    }
+    
     public static func getMyPin() -> String? {
         return UserDefaults.standard.string(forKey: "me")
     }

+ 5 - 6
appbuilder-ios/NexilisLite/NexilisLite/Source/Nexilis.swift

@@ -234,12 +234,11 @@ public class Nexilis: NSObject {
                                     if parent.isEmpty {
                                         parent = "-99"
                                     }
-                                    _ = try Database.shared.insertRecord(fmdb: fmdb, table: "SERVICE_BANK", cvalues: [
-                                        "service_id" : CoreMessage_TMessageUtil.getString(json: json, key: CoreMessage_TMessageKey.CATEGORY_ID),
-                                        "service_name" : CoreMessage_TMessageUtil.getString(json: json, key: CoreMessage_TMessageKey.NAME),
-                                        "description" : CoreMessage_TMessageUtil.getString(json: json, key: CoreMessage_TMessageKey.DESCRIPTION),
-                                        "parent" : parent,
-                                        "is_tablet" : CoreMessage_TMessageUtil.getString(json: json, key: CoreMessage_TMessageKey.PLATFORM)
+                                    _ = try Database.shared.insertRecord(fmdb: fmdb, table: "WORKING_AREA", cvalues: [
+                                        "area_id" : CoreMessage_TMessageUtil.getString(json: json, key: CoreMessage_TMessageKey.WORKING_AREA),
+                                        "name" : CoreMessage_TMessageUtil.getString(json: json, key: CoreMessage_TMessageKey.NAME),
+                                        "parent" : CoreMessage_TMessageUtil.getString(json: json, key: CoreMessage_TMessageKey.PARENT_ID),
+                                        "level" : CoreMessage_TMessageUtil.getString(json: json, key: CoreMessage_TMessageKey.LEVEL)
                                     ], replace: true)
                                 }
                             } catch {

+ 59 - 10
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorPersonal.swift

@@ -101,6 +101,8 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
     var touchedSubview = UIView()
     var listViewOnSection: [UIView] = []
     var fromVCAC = false
+    var serviceIdCC = ""
+    var isDirectCC = false
     
     public override func viewDidDisappear(_ animated: Bool) {
         if self.isMovingFromParent {
@@ -240,6 +242,9 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                 self.show(videoVC, sender: nil)
             }
         }
+        if isDirectCC {
+            directCC()
+        }
 //        else if isContactCenter {
 //            let buttonId = UIButton()
 //            if channelContactCenter == "0" {
@@ -988,7 +993,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
             } else {
                 query = "SELECT message_id, f_pin, l_pin, message_scope_id, server_date, status, message_text, audio_id, video_id, image_id, thumb_id, read_receipts, chat_id, file_id, attachment_flag, reff_id, lock, is_stared FROM MESSAGE where message_scope_id = '5' AND broadcast_flag = 0 AND is_call_center = 1 AND call_center_id = '\(complaintId)' order by server_date asc"
             }
-            if isRequestContactCenter {
+            if isRequestContactCenter && !isDirectCC {
                 var row: [String: Any?] = [:]
                 row["f_pin"] = nil
                 row["message_id"] = ""
@@ -996,7 +1001,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                 let listStringName: [String] = ["Chat with a Representative".localized(), "Video Call a Representative".localized(), "Call a Representative".localized()]
                 var data : [CategoryCC] = []
                 if Utils.getDefaultCC() == "No" {
-                    let category = CategoryCC.getDatafromParent(parent: "-99")
+                    let category = CategoryCC.getDatafromParent(parent: CategoryCC.default_parent)
                     for i in 0..<category.count {
                         data.append(CategoryCC(id: "level0_\(i)", service_id: category[i].service_id, service_name: category[i].service_name, parent: category[i].parent, description: category[i].description, is_tablet: "0"))
                     }
@@ -1009,6 +1014,8 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                 row["category_cc"] = data
                 dataDates.append("Today".localized())
                 dataMessages.append(row)
+            } else if isDirectCC {
+                dataDates.append("Today".localized())
             }
         }
         Database.shared.database?.inTransaction({ (fmdb, rollback) in
@@ -2492,6 +2499,47 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
         }
     }
     
+    private func directCC() {
+        if channelContactCenter == "1" || channelContactCenter == "2" {
+            if channelContactCenter == "2" {
+                let goAudioCall = Nexilis.checkMicPermission()
+                let goVideoCall = Nexilis.checkCameraPermission()
+                if goVideoCall == 0 {
+                    let alert = UIAlertController(title: "Attention!".localized(), message: !goAudioCall && goVideoCall == 0 && channelContactCenter == "2" ? "Please allow microphone & camera permission in your settings".localized() : !goAudioCall ? "Please allow microphone permission in your settings".localized() : "Please allow camera permission in your settings", preferredStyle: .alert)
+                    alert.addAction(UIAlertAction(title: "OK".localized(), style: UIAlertAction.Style.default, handler: {_ in
+                        if let url = URL(string: UIApplication.openSettingsURLString), UIApplication.shared.canOpenURL(url) {
+                            UIApplication.shared.open(url, options: [:], completionHandler: nil)
+                        }
+                    }))
+                    self.navigationController?.present(alert, animated: true, completion: nil)
+                    return
+                } else if goVideoCall == -1 {
+                    return
+                }
+            } else if channelContactCenter == "1" {
+                let goAudioCall = Nexilis.checkMicPermission()
+                if !goAudioCall{
+                    let alert = UIAlertController(title: "Attention!".localized(), message: "Please allow microphone permission in your settings".localized(), preferredStyle: .alert)
+                    alert.addAction(UIAlertAction(title: "OK".localized(), style: UIAlertAction.Style.default, handler: {_ in
+                        if let url = URL(string: UIApplication.openSettingsURLString), UIApplication.shared.canOpenURL(url) {
+                            UIApplication.shared.open(url, options: [:], completionHandler: nil)
+                        }
+                    }))
+                    self.navigationController?.present(alert, animated: true, completion: nil)
+                    return
+                }
+            }
+        }
+        var row: [String: Any?] = [:]
+        row["message_id"] = ""
+        row["chat_date"] = "Today".localized()
+        row["category_cc"] = "Please wait while we connect you\nto one of our service representatives".localized()
+        dataMessages.append(row)
+        nowSelectedCategoryCC = "CantReturn"
+        tableChatView.insertRows(at: [IndexPath(row: 0, section: 0)], with: .none)
+        requestContactCenter(channel: Int(channelContactCenter)!, service_id: serviceIdCC, row: row)
+    }
+    
     @objc func busyCCAction(sender: UIButton) {
         let id = sender.restorationIdentifier?.components(separatedBy: ",")[0]
         let service_id = sender.restorationIdentifier?.components(separatedBy: ",")[1]
@@ -2528,13 +2576,15 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
             return
         }
         DispatchQueue.global().async {
-            let message = CoreMessage_TMessageBank.getRequestCallCenter(p_channel: channel)
+            let message = CoreMessage_TMessageBank.getRequestCallCenter(p_channel: channel, category_id: service_id)
             if let response = Nexilis.writeSync(message: message) {
-                DispatchQueue.main.async {
-                    self.dataMessages.append(row)
-                    self.nowSelectedCategoryCC = "CantReturn"
-                    self.tableChatView.insertRows(at: [IndexPath(row: self.dataMessages.count - 1, section: 0)], with: .none)
-                    self.tableChatView.scrollToBottom()
+                if !self.isDirectCC {
+                    DispatchQueue.main.async {
+                        self.dataMessages.append(row)
+                        self.nowSelectedCategoryCC = "CantReturn"
+                        self.tableChatView.insertRows(at: [IndexPath(row: self.dataMessages.count - 1, section: 0)], with: .none)
+                        self.tableChatView.scrollToBottom()
+                    }
                 }
                 if (response.getBody(key: CoreMessage_TMessageKey.ERRCOD, default_value: "99") == "00") {
                     DispatchQueue.main.async {
@@ -4026,7 +4076,6 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
         cell.contentView.subviews.forEach({ $0.removeFromSuperview() })
         
         if isContactCenter && isRequestContactCenter && dataMessages[indexPath.row]["category_cc"] != nil {
-            
             cell.backgroundColor = .clear
             cell.selectionStyle = .none
             
@@ -4118,7 +4167,7 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
                     containerButton.addSubview(buttonChat)
                     buttonChat.translatesAutoresizingMaskIntoConstraints = false
                     buttonChat.widthAnchor.constraint(equalToConstant: self.view!.frame.size.width * 0.65 / 2 - 10).isActive = true
-                    buttonChat.heightAnchor.constraint(equalToConstant: 45).isActive = true
+                    buttonChat.heightAnchor.constraint(greaterThanOrEqualToConstant: 45).isActive = true
                     if i % 2 == 0 {
                         if i / 2 + 1 == 1 {
                             buttonChat.topAnchor.constraint(equalTo: containerButton.topAnchor, constant: 5).isActive = true

+ 18 - 4
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/SetInternalCSAccount.swift

@@ -12,6 +12,8 @@ public class SetInternalCSAccount: UITableViewController {
     private var searchController: UISearchController!
     public var isSetCS = false
     
+    var fromNotification = false
+    
     private var availableUser: [User] = []
     
     private var fillteredUser: [User] = []
@@ -44,6 +46,17 @@ public class SetInternalCSAccount: UITableViewController {
         navigationItem.searchController = searchController
         navigationItem.hidesSearchBarWhenScrolling = true
         
+        if fromNotification {
+            let imageButton = UIImageView(frame: CGRect(x: -16, y: 0, width: 20, height: 44))
+            imageButton.image = UIImage(systemName: "chevron.backward", withConfiguration: UIImage.SymbolConfiguration(pointSize: 20, weight: .regular, scale: .default))?.withTintColor(.white)
+            imageButton.contentMode = .left
+            let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapExit))
+            imageButton.isUserInteractionEnabled = true
+            imageButton.addGestureRecognizer(tapGestureRecognizer)
+            let leftItem = UIBarButtonItem(customView: imageButton)
+            self.navigationItem.leftBarButtonItem = leftItem
+        }
+        
         if #available(iOS 15.0, *) {
             tableView.sectionHeaderTopPadding = 0
         }
@@ -56,6 +69,10 @@ public class SetInternalCSAccount: UITableViewController {
         }
     }
     
+    @objc func didTapExit() {
+        self.dismiss(animated: true, completion: nil)
+    }
+    
     public override func viewDidAppear(_ animated: Bool) {
         self.navigationController?.navigationBar.topItem?.title = isSetCS ? "Set CS Account".localized()  :"Set Internal Account".localized()
         self.navigationController?.navigationBar.setNeedsLayout()
@@ -66,10 +83,7 @@ public class SetInternalCSAccount: UITableViewController {
         DispatchQueue.global().async {
             Database.shared.database?.inTransaction({ (fmdb, rollback) in
                 var r: [User] = []
-                var query =  "SELECT u.f_pin, u.first_name, u.last_name, u.image_id, u.user_type FROM BUDDY u where u.f_pin <> '\(User.getMyPin()!)' and u.user_type <> '24' and u.official_account <> '1' and u.official_account <> '2' and u.official_account <> '3' order by 2 collate nocase asc"
-                if self.isSetCS {
-                    query =  "SELECT u.f_pin, u.first_name, u.last_name, u.image_id, u.user_type FROM BUDDY u LEFT JOIN GROUPZ_MEMBER m ON u.f_pin = m.f_pin where u.f_pin <> '\(User.getMyPin()!)' and u.official_account <> '1' and u.official_account <> '2' and u.official_account <> '3' and (u.user_type = '23' or u.user_type = '24') and group_id = (select g.group_id from GROUPZ g where g.official = 1) and m.position <> '1' order by 2 collate nocase asc"
-                }
+                var query =  "SELECT u.f_pin, u.first_name, u.last_name, u.image_id, u.user_type FROM BUDDY u where u.f_pin <> '\(User.getMyPin()!)' and u.official_account <> '1' and u.official_account <> '2' and u.official_account <> '3' order by 2 collate nocase asc"
                 if let cursorData = Database.shared.getRecords(fmdb: fmdb, query: query) {
                     while cursorData.next() {
                         let user = User(pin: cursorData.string(forColumnIndex: 0) ?? "",