|
@@ -140,116 +140,127 @@ public class FourthTabViewController: UIViewController, UITableViewDelegate, UIT
|
|
|
|
|
|
func makeMenu(imageSignIn: String = ""){
|
|
|
let isChangeProfile = Utils.getSetProfile()
|
|
|
- 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() {
|
|
|
- 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()),
|
|
|
- Item(icon: UIImage(systemName: "person.crop.rectangle"), title: "Change Admin / Internal Password".localized()),
|
|
|
- Item(icon: UIImage(systemName: "laptopcomputer.and.iphone"), title: "Sign-In to Web".localized()),
|
|
|
- Item(icon: UIImage(named: "ic_internal", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, title: "Set Internal Account".localized()),
|
|
|
- Item(icon: UIImage(named: "pb_call_center", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, title: "Set CS Account".localized()),
|
|
|
- ]
|
|
|
- } else if User.isInternal(userType: cursorUser.string(forColumnIndex: 0) ?? "") || User.isCallCenter(userType: cursorUser.string(forColumnIndex: 0) ?? "") || User.isVerified(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()),
|
|
|
- Item(icon: UIImage(systemName: "laptopcomputer.and.iphone"), title: "Sign-In to Web".localized()),
|
|
|
- ]
|
|
|
+ if Database.shared.database == nil {
|
|
|
+ Item.menus["Personal"] = [
|
|
|
+ Item(icon: UIImage(systemName: "person"), title: "Personal Information".localized()),
|
|
|
+ Item(icon: UIImage(systemName: "textformat.abc"), title: "Change Language".localized()),
|
|
|
+ Item(icon: UIImage(systemName: "arrow.up.and.person.rectangle.portrait"), title: "Sign-Up/Sign-In".localized()),
|
|
|
+ ]
|
|
|
+ if Nexilis.showButtonFB {
|
|
|
+ Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "gearshape.circle"), title: "Configure Floating Button".localized()))
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ 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() {
|
|
|
+ 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()),
|
|
|
+ Item(icon: UIImage(systemName: "person.crop.rectangle"), title: "Change Admin / Internal Password".localized()),
|
|
|
+ Item(icon: UIImage(systemName: "laptopcomputer.and.iphone"), title: "Sign-In to Web".localized()),
|
|
|
+ Item(icon: UIImage(named: "ic_internal", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, title: "Set Internal Account".localized()),
|
|
|
+ Item(icon: UIImage(named: "pb_call_center", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, title: "Set CS Account".localized()),
|
|
|
+ ]
|
|
|
+ } else if User.isInternal(userType: cursorUser.string(forColumnIndex: 0) ?? "") || User.isCallCenter(userType: cursorUser.string(forColumnIndex: 0) ?? "") || User.isVerified(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()),
|
|
|
+ Item(icon: UIImage(systemName: "laptopcomputer.and.iphone"), title: "Sign-In to Web".localized()),
|
|
|
+ ]
|
|
|
+ } else {
|
|
|
+ Item.menus["Personal"] = [
|
|
|
+ Item(icon: UIImage(systemName: "person"), title: "Personal Information".localized()),
|
|
|
+ Item(icon: UIImage(systemName: "textformat.abc"), title: "Change Language".localized()),
|
|
|
+ Item(icon: UIImage(systemName: "person.badge.key"), title: "Access Admin / Internal Features".localized()),
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ if !isChangeProfile {
|
|
|
+ Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "arrow.up.and.person.rectangle.portrait"), title: "Sign-Up/Sign-In".localized()))
|
|
|
+ } else if isChangeProfile {
|
|
|
+ if Nexilis.checkingAccess(key: "backup_restore") {
|
|
|
+ Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "arrow.clockwise.icloud"), title: "Backup & Restore".localized()))
|
|
|
+ }
|
|
|
+ if Utils.getLimitValidTrans() == "1" {
|
|
|
+ Item.menus["Personal"]?.insert(Item(icon: UIImage(systemName: "lessthan.circle"), title: "Validation Transaction Limit".localized()), at: 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let image = cursorUser.string(forColumnIndex: 1)
|
|
|
+ if image != nil {
|
|
|
+ if !image!.isEmpty {
|
|
|
+ do {
|
|
|
+ let documentDir = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
|
|
|
+ let file = documentDir.appendingPathComponent(image!)
|
|
|
+ if FileManager().fileExists(atPath: file.path) {
|
|
|
+ let image = UIImage(contentsOfFile: file.path)
|
|
|
+ Item.menus["Personal"]?[0].icon = image?.circleMasked
|
|
|
+ if !imageSignIn.isEmpty {
|
|
|
+ var dataImage: [AnyHashable : Any] = [:]
|
|
|
+ dataImage["name"] = imageSignIn
|
|
|
+ NotificationCenter.default.post(name: NSNotification.Name(rawValue: "imageFBUpdate"), object: nil, userInfo: dataImage)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Download().start(forKey: image!) { (name, progress) in
|
|
|
+ guard progress == 100 else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ let image = UIImage(contentsOfFile: file.path)
|
|
|
+ Item.menus["Personal"]?[0].icon = image?.circleMasked
|
|
|
+ self.tableView.reloadData()
|
|
|
+ if !imageSignIn.isEmpty {
|
|
|
+ var dataImage: [AnyHashable : Any] = [:]
|
|
|
+ dataImage["name"] = imageSignIn
|
|
|
+ NotificationCenter.default.post(name: NSNotification.Name(rawValue: "imageFBUpdate"), object: nil, userInfo: dataImage)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch {}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cursorUser.close()
|
|
|
} else {
|
|
|
Item.menus["Personal"] = [
|
|
|
Item(icon: UIImage(systemName: "person"), title: "Personal Information".localized()),
|
|
|
- Item(icon: UIImage(systemName: "textformat.abc"), title: "Change Language".localized()),
|
|
|
+ Item(icon: UIImage(systemName: "textformat.abc"), title: "Change Language".localized()),
|
|
|
Item(icon: UIImage(systemName: "person.badge.key"), title: "Access Admin / Internal Features".localized()),
|
|
|
]
|
|
|
- }
|
|
|
- if !isChangeProfile {
|
|
|
- Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "arrow.up.and.person.rectangle.portrait"), title: "Sign-Up/Sign-In".localized()))
|
|
|
- } else if isChangeProfile {
|
|
|
- if Nexilis.checkingAccess(key: "backup_restore") {
|
|
|
- Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "arrow.clockwise.icloud"), title: "Backup & Restore".localized()))
|
|
|
- }
|
|
|
- if Utils.getLimitValidTrans() == "1" {
|
|
|
- Item.menus["Personal"]?.insert(Item(icon: UIImage(systemName: "lessthan.circle"), title: "Validation Transaction Limit".localized()), at: 1)
|
|
|
+ if Nexilis.showButtonFB {
|
|
|
+ Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "gearshape.circle"), title: "Configure Floating Button".localized()))
|
|
|
}
|
|
|
- }
|
|
|
- let image = cursorUser.string(forColumnIndex: 1)
|
|
|
- if image != nil {
|
|
|
- if !image!.isEmpty {
|
|
|
+ Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "arrow.up.and.person.rectangle.portrait"), title: "Sign-Up/Sign-In".localized()))
|
|
|
+ if !imageSignIn.isEmpty {
|
|
|
do {
|
|
|
let documentDir = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
|
|
|
- let file = documentDir.appendingPathComponent(image!)
|
|
|
+ let file = documentDir.appendingPathComponent(imageSignIn)
|
|
|
if FileManager().fileExists(atPath: file.path) {
|
|
|
let image = UIImage(contentsOfFile: file.path)
|
|
|
Item.menus["Personal"]?[0].icon = image?.circleMasked
|
|
|
- if !imageSignIn.isEmpty {
|
|
|
- var dataImage: [AnyHashable : Any] = [:]
|
|
|
- dataImage["name"] = imageSignIn
|
|
|
- NotificationCenter.default.post(name: NSNotification.Name(rawValue: "imageFBUpdate"), object: nil, userInfo: dataImage)
|
|
|
- }
|
|
|
+ var dataImage: [AnyHashable : Any] = [:]
|
|
|
+ dataImage["name"] = imageSignIn
|
|
|
+ NotificationCenter.default.post(name: NSNotification.Name(rawValue: "imageFBUpdate"), object: nil, userInfo: dataImage)
|
|
|
} else {
|
|
|
- Download().start(forKey: image!) { (name, progress) in
|
|
|
+ Download().start(forKey: imageSignIn) { (name, progress) in
|
|
|
guard progress == 100 else {
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
DispatchQueue.main.async {
|
|
|
let image = UIImage(contentsOfFile: file.path)
|
|
|
Item.menus["Personal"]?[0].icon = image?.circleMasked
|
|
|
self.tableView.reloadData()
|
|
|
- if !imageSignIn.isEmpty {
|
|
|
- var dataImage: [AnyHashable : Any] = [:]
|
|
|
- dataImage["name"] = imageSignIn
|
|
|
- NotificationCenter.default.post(name: NSNotification.Name(rawValue: "imageFBUpdate"), object: nil, userInfo: dataImage)
|
|
|
- }
|
|
|
+ var dataImage: [AnyHashable : Any] = [:]
|
|
|
+ dataImage["name"] = imageSignIn
|
|
|
+ NotificationCenter.default.post(name: NSNotification.Name(rawValue: "imageFBUpdate"), object: nil, userInfo: dataImage)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} catch {}
|
|
|
}
|
|
|
}
|
|
|
- cursorUser.close()
|
|
|
- } else {
|
|
|
- Item.menus["Personal"] = [
|
|
|
- Item(icon: UIImage(systemName: "person"), title: "Personal Information".localized()),
|
|
|
- Item(icon: UIImage(systemName: "textformat.abc"), title: "Change Language".localized()),
|
|
|
- Item(icon: UIImage(systemName: "person.badge.key"), title: "Access Admin / Internal Features".localized()),
|
|
|
- ]
|
|
|
- if Nexilis.showButtonFB {
|
|
|
- Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "gearshape.circle"), title: "Configure Floating Button".localized()))
|
|
|
- }
|
|
|
- Item.menus["Personal"]?.append(Item(icon: UIImage(systemName: "arrow.up.and.person.rectangle.portrait"), title: "Sign-Up/Sign-In".localized()))
|
|
|
- if !imageSignIn.isEmpty {
|
|
|
- do {
|
|
|
- let documentDir = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
|
|
|
- let file = documentDir.appendingPathComponent(imageSignIn)
|
|
|
- if FileManager().fileExists(atPath: file.path) {
|
|
|
- let image = UIImage(contentsOfFile: file.path)
|
|
|
- Item.menus["Personal"]?[0].icon = image?.circleMasked
|
|
|
- var dataImage: [AnyHashable : Any] = [:]
|
|
|
- dataImage["name"] = imageSignIn
|
|
|
- NotificationCenter.default.post(name: NSNotification.Name(rawValue: "imageFBUpdate"), object: nil, userInfo: dataImage)
|
|
|
- } else {
|
|
|
- Download().start(forKey: imageSignIn) { (name, progress) in
|
|
|
- guard progress == 100 else {
|
|
|
- return
|
|
|
- }
|
|
|
- DispatchQueue.main.async {
|
|
|
- let image = UIImage(contentsOfFile: file.path)
|
|
|
- Item.menus["Personal"]?[0].icon = image?.circleMasked
|
|
|
- self.tableView.reloadData()
|
|
|
- var dataImage: [AnyHashable : Any] = [:]
|
|
|
- dataImage["name"] = imageSignIn
|
|
|
- NotificationCenter.default.post(name: NSNotification.Name(rawValue: "imageFBUpdate"), object: nil, userInfo: dataImage)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } catch {}
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
Item.menus["Config"] = [
|
|
|
Item(icon: UIImage(systemName: "iphone"), title: "Create Your Own App".localized()),
|