Commit 0aca0747 by Anand.suthar

Worked on order status changes

parent 2eadac7e
......@@ -33,6 +33,7 @@
B032225E20F1D6B9005116F4 /* TermsAndRules.swift in Sources */ = {isa = PBXBuildFile; fileRef = B032225D20F1D6B9005116F4 /* TermsAndRules.swift */; };
B038371E20F37F5200B68870 /* Appointment.swift in Sources */ = {isa = PBXBuildFile; fileRef = B038371D20F37F5200B68870 /* Appointment.swift */; };
B038372020F37F6300B68870 /* AppointmentExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = B038371F20F37F6300B68870 /* AppointmentExt.swift */; };
B04824612128342100B088C0 /* UpdateOrder.swift in Sources */ = {isa = PBXBuildFile; fileRef = B04824602128342100B088C0 /* UpdateOrder.swift */; };
B04F589720B8073600A0F6B8 /* TPKeyboardAvoidingScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = B04F589620B8073600A0F6B8 /* TPKeyboardAvoidingScrollView.m */; };
B04F589A20B8076800A0F6B8 /* UIScrollView+TPKeyboardAvoidingAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B04F589920B8076800A0F6B8 /* UIScrollView+TPKeyboardAvoidingAdditions.m */; };
B055210320F21CE9001E9B38 /* Income.swift in Sources */ = {isa = PBXBuildFile; fileRef = B055210220F21CE9001E9B38 /* Income.swift */; };
......@@ -543,6 +544,7 @@
B032225D20F1D6B9005116F4 /* TermsAndRules.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermsAndRules.swift; sourceTree = "<group>"; };
B038371D20F37F5200B68870 /* Appointment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Appointment.swift; sourceTree = "<group>"; };
B038371F20F37F6300B68870 /* AppointmentExt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppointmentExt.swift; sourceTree = "<group>"; };
B04824602128342100B088C0 /* UpdateOrder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateOrder.swift; sourceTree = "<group>"; };
B04F589520B8073600A0F6B8 /* TPKeyboardAvoidingScrollView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TPKeyboardAvoidingScrollView.h; sourceTree = "<group>"; };
B04F589620B8073600A0F6B8 /* TPKeyboardAvoidingScrollView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TPKeyboardAvoidingScrollView.m; sourceTree = "<group>"; };
B04F589820B8076800A0F6B8 /* UIScrollView+TPKeyboardAvoidingAdditions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIScrollView+TPKeyboardAvoidingAdditions.h"; sourceTree = "<group>"; };
......@@ -950,6 +952,7 @@
B01B216D20EF877A002AC8D5 /* Model */ = {
isa = PBXGroup;
children = (
B04824602128342100B088C0 /* UpdateOrder.swift */,
B091CD672119A43F00E270BF /* FireBaseChat */,
B038371420F37F2F00B68870 /* Appointment */,
B0F371E320EFB08D000F92D2 /* Home */,
......@@ -2291,6 +2294,7 @@
EC04CF2E2052CEEC00B425BB /* Productcategory.swift in Sources */,
B055210520F21D01001E9B38 /* IncomeExt.swift in Sources */,
EC04CDC52052CD4500B425BB /* SellerReviewsCollectionModel.swift in Sources */,
B04824612128342100B088C0 /* UpdateOrder.swift in Sources */,
EC04CEC22052CE4A00B425BB /* MyCartModel.swift in Sources */,
EC04CF182052CEBD00B425BB /* ProfileTableViewCell.swift in Sources */,
EC04CF9D2052CF2A00B425BB /* CHIPageControlJalapeno.swift in Sources */,
......
......@@ -26,7 +26,7 @@
moduleName = "Bhagyashree"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/sunarcmac/Documents/Futurecommerce/Fengshui-Seller-iOS/Bhagyashree/Sunarc/Controller/Me/CorporateCultureViewController.swift"
timestampString = "556273458.770355"
timestampString = "556459275.434637"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "22"
......@@ -41,7 +41,7 @@
moduleName = "Bhagyashree"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/sunarcmac/Documents/Futurecommerce/Fengshui-Seller-iOS/Bhagyashree/Sunarc/Controller/Me/CorporateCultureViewController.swift"
timestampString = "556273458.774583"
timestampString = "556459275.438275"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "22"
......@@ -56,7 +56,7 @@
moduleName = "Bhagyashree"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/sunarcmac/Documents/Futurecommerce/Fengshui-Seller-iOS/Bhagyashree/Sunarc/Controller/Me/CorporateCultureViewController.swift"
timestampString = "556273458.780182"
timestampString = "556459275.44317"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "22"
......@@ -71,7 +71,7 @@
moduleName = "Bhagyashree"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/sunarcmac/Documents/Futurecommerce/Fengshui-Seller-iOS/Bhagyashree/Sunarc/Controller/Me/CorporateCultureViewController.swift"
timestampString = "556273458.785668"
timestampString = "556459275.448035"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "22"
......@@ -81,5 +81,53 @@
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Bhagyashree/Sunarc/Controller/Appointment/ServicesListViewController.swift"
timestampString = "556442966.305923"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "110"
endingLineNumber = "110"
landmarkName = "tableView(_:didSelectRowAt:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Bhagyashree/Sunarc/Model/UpdateOrder.swift"
timestampString = "556463024.5798759"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "40"
endingLineNumber = "40"
landmarkName = "updateOrder(to:orderId:success:failuer:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Bhagyashree/Sunarc/Controller/Home/HomePageViewController.swift"
timestampString = "556463024.5799609"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "146"
endingLineNumber = "146"
landmarkName = "unknown"
landmarkType = "0">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
......@@ -80,10 +80,18 @@ extension EditResultViewController {
let result = UIAlertController(title: "Submit Result", message: "Result successfully submitted.", preferredStyle: .alert)
let actionOk = UIAlertAction(title: "Ok", style: .default, handler: { (_) in
self.back()
UpdateOrder.toComplete(orderId: self.orderId, success: {
self.navigationController?.popToRootViewController(animated: true)
}, failuer: { (errorMessage) in
self.view.showToast(errorMessage, position: .bottom, popTime: 2.0, dismissOnTap: false)
self.back()
})
})
result.addAction(actionOk)
self.present(result, animated: true, completion: nil)
SVProgressHUD.dismiss()
}, failure: { (errorMessage) in
......
......@@ -77,6 +77,9 @@ extension ServiceDetailViewController {
@IBAction func startMeeting() {
let videoCallViewController = Utils.viewController(storyboardName: "Appointment", ofType: VideoCallingViewController.self)
if let orderId = orderId {
videoCallViewController.orderId = orderId
}
self.navigationController?.pushViewController(videoCallViewController, animated: true)
}
......
......@@ -107,6 +107,7 @@ extension ServicesListViewController: UITableViewDelegate, UITableViewDataSource
let servicedetailViewController = Utils.viewController(storyboardName: "Appointment", ofType: ServiceDetailViewController.self)
servicedetailViewController.serviceStatus = .ongoing
servicedetailViewController.incrementId = service.services[indexPath.row].incrementId
print(service.services[indexPath.row].orderId)
servicedetailViewController.orderId = service.services[indexPath.row].orderId
self.navigationController?.pushViewController(servicedetailViewController, animated: true)
}
......
......@@ -18,6 +18,8 @@ class VideoCallingViewController: UIViewController {
@IBOutlet weak var remoteVideo: UIView! // 5.
var agoraKit: AgoraRtcEngineKit!
var orderId: String = "0"
override func viewDidLoad() {
super.viewDidLoad()
......@@ -47,7 +49,22 @@ extension VideoCallingViewController {
}
@IBAction func endCall() {
leaveChannel()
let alert = UIAlertController(title: nil, message: "Is the service finished?", preferredStyle: .alert)
let yesAction = UIAlertAction(title: "Yes", style: .default) { (_) in
self.leaveChannel()
UpdateOrder.toOngoing(orderId: self.orderId, success: {
self.navigationController?.popToRootViewController(animated: true)
}) { (errorMessage) in
self.navigationController?.popToRootViewController(animated: true)
self.view.showToast(errorMessage, position: .bottom, popTime: 2.0, dismissOnTap: false)
}
}
let noAction = UIAlertAction(title: "No", style: .default, handler: nil)
alert.addAction(yesAction)
alert.addAction(noAction)
self.present(alert, animated: true, completion: nil)
}
}
......@@ -71,7 +88,7 @@ extension VideoCallingViewController {
agoraKit.setupLocalVideo(videoCanvas)
}
func joinChannel() {
agoraKit.joinChannel(byToken: nil, channelId: "demoChannel1", info:nil, uid:0) {[weak self] (sid, uid, elapsed) -> Void in
agoraKit.joinChannel(byToken: nil, channelId: orderId, info:nil, uid:0) {[weak self] (sid, uid, elapsed) -> Void in
// Join channel "demoChannel1"
if let weakSelf = self {
weakSelf.agoraKit.setEnableSpeakerphone(true)
......
......@@ -99,6 +99,8 @@ extension CompleteEnquiryViewController: UITableViewDataSource, UITableViewDeleg
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
let enquiryDetailsViewController = Utils.viewController(storyboardName: "Home", ofType: EnquiryDetailsViewController.self)
enquiryDetailsViewController.incrementId = enquiry.enquiries[indexPath.row].incrementId!
enquiryDetailsViewController.orderId = enquiry.enquiries[indexPath.row].orderId!
self.navigationController?.pushViewController(enquiryDetailsViewController, animated: true)
}
}
......
......@@ -7,19 +7,38 @@
//
import UIKit
import Kingfisher
class EnquiryDetailsViewController: UIViewController {
class EnquiryDetailsViewController: BaseViewController {
@IBOutlet var tblDetails: UITableView!
var incrementId = "0"
var orderId = "0"
var appointmentDetails = Appointment()
override func viewDidLoad() {
super.viewDidLoad()
appointmentDetails.getAppointmentDetails(incrementId: incrementId, success: {
self.tblDetails.reloadData()
}) { (errorMessage) in
self.view.showToast(errorMessage, position: .bottom, popTime: 2.0, dismissOnTap: false)
}
}
}
extension EnquiryDetailsViewController {
@IBAction func chatHistory() {
let chatViewController = Utils.viewController(storyboardName: "Home", ofType: OnlineEnquiryViewController.self)
chatViewController.orderId = orderId
self.navigationController?.pushViewController(chatViewController, animated: true)
}
......@@ -28,6 +47,9 @@ extension EnquiryDetailsViewController {
}
}
extension EnquiryDetailsViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
......@@ -38,10 +60,11 @@ extension EnquiryDetailsViewController: UITableViewDelegate, UITableViewDataSour
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "enquiryDetails") as! EnquiryDetailsCell
cell.updateUI()
cell.appointmentDetails = appointmentDetails
return cell
}else{
let cell = tableView.dequeueReusableCell(withIdentifier: "review") as! EnquiryReviewCell
cell.appointmentDetails = appointmentDetails
return cell
}
......@@ -52,6 +75,19 @@ extension EnquiryDetailsViewController: UITableViewDelegate, UITableViewDataSour
}
}
class EnquiryDetailsCell: UITableViewCell {
@IBOutlet var imgCustomer: UIImageView!
@IBOutlet var lblName: UILabel!
......@@ -59,21 +95,51 @@ class EnquiryDetailsCell: UITableViewCell {
@IBOutlet var lblPriceOld: UILabel!
@IBOutlet var lblDateTime: UILabel!
func updateUI() {
// imgCustomer.layer.cornerRadius = imgCustomer.frame.size.width/2
let attributedString = NSMutableAttributedString(string:"$99.50")
attributedString.addAttribute(NSAttributedStringKey.baselineOffset, value: 0, range: NSMakeRange(0, attributedString.length))
attributedString.addAttribute(NSAttributedStringKey.strikethroughStyle, value: NSNumber(value: NSUnderlineStyle.styleThick.rawValue), range: NSMakeRange(0, attributedString.length))
attributedString.addAttribute(NSAttributedStringKey.strikethroughColor, value: UIColor.gray, range: NSMakeRange(0, attributedString.length))
lblPriceOld.attributedText = attributedString
var appointmentDetails: Appointment? {
didSet {
if let appointmentDetails = appointmentDetails {
if let profileImage = appointmentDetails.customerProfileImage {
let url = URL(string: profileImage)
imgCustomer.kf.setImage(with: url, placeholder: UIImage(named: "placeholder"), options: [.transition(ImageTransition.fade(1)), .scaleFactor(1.0)], progressBlock: nil, completionHandler: nil)
}
lblName.text = appointmentDetails.customerName
lblPriceNew.text = appointmentDetails.orderTotal
if let orderTotal = appointmentDetails.orderTotal {
let attributedString = NSMutableAttributedString(string:orderTotal)
attributedString.addAttribute(NSAttributedStringKey.baselineOffset, value: 0, range: NSMakeRange(0, attributedString.length))
attributedString.addAttribute(NSAttributedStringKey.strikethroughStyle, value: NSNumber(value: NSUnderlineStyle.styleThick.rawValue), range: NSMakeRange(0, attributedString.length))
attributedString.addAttribute(NSAttributedStringKey.strikethroughColor, value: UIColor.gray, range: NSMakeRange(0, attributedString.length))
lblPriceOld.attributedText = attributedString
}
}
}
}
@IBAction func chatHistory() {
}
}
class EnquiryReviewCell: UITableViewCell {
@IBOutlet var btnStar1: UIButton!
@IBOutlet var btnStar2: UIButton!
......@@ -84,45 +150,42 @@ class EnquiryReviewCell: UITableViewCell {
@IBOutlet var txtReview: UITextView!
@IBOutlet var lblDateTime: UILabel!
@IBAction func starReview(_ star: UIButton) {
switch star.tag {
case 1:
btnStar1.setImage(#imageLiteral(resourceName: "star"), for: .normal)
btnStar2.setImage(#imageLiteral(resourceName: "star_clr"), for: .normal)
btnStar3.setImage(#imageLiteral(resourceName: "star_clr"), for: .normal)
btnStar4.setImage(#imageLiteral(resourceName: "star_clr"), for: .normal)
btnStar5.setImage(#imageLiteral(resourceName: "star_clr"), for: .normal)
case 2:
btnStar1.setImage(#imageLiteral(resourceName: "star"), for: .normal)
btnStar2.setImage(#imageLiteral(resourceName: "star"), for: .normal)
btnStar3.setImage(#imageLiteral(resourceName: "star_clr"), for: .normal)
btnStar4.setImage(#imageLiteral(resourceName: "star_clr"), for: .normal)
btnStar5.setImage(#imageLiteral(resourceName: "star_clr"), for: .normal)
case 3:
btnStar1.setImage(#imageLiteral(resourceName: "star"), for: .normal)
btnStar2.setImage(#imageLiteral(resourceName: "star"), for: .normal)
btnStar3.setImage(#imageLiteral(resourceName: "star"), for: .normal)
btnStar4.setImage(#imageLiteral(resourceName: "star_clr"), for: .normal)
btnStar5.setImage(#imageLiteral(resourceName: "star_clr"), for: .normal)
case 4:
btnStar1.setImage(#imageLiteral(resourceName: "star"), for: .normal)
btnStar2.setImage(#imageLiteral(resourceName: "star"), for: .normal)
btnStar3.setImage(#imageLiteral(resourceName: "star"), for: .normal)
btnStar4.setImage(#imageLiteral(resourceName: "star"), for: .normal)
btnStar5.setImage(#imageLiteral(resourceName: "star_clr"), for: .normal)
case 5:
btnStar1.setImage(#imageLiteral(resourceName: "star"), for: .normal)
btnStar2.setImage(#imageLiteral(resourceName: "star"), for: .normal)
btnStar3.setImage(#imageLiteral(resourceName: "star"), for: .normal)
btnStar4.setImage(#imageLiteral(resourceName: "star"), for: .normal)
btnStar5.setImage(#imageLiteral(resourceName: "star"), for: .normal)
default:
print("defaults")
var appointmentDetails: Appointment? {
didSet {
if let appointmentDetails = appointmentDetails {
self.txtReview.text = appointmentDetails.reviewMessage
self.lblDateTime.text = appointmentDetails.reviewDateTime
if let rating = appointmentDetails.rating {
let ratingAsInt = Int(rating)!
if ratingAsInt > 0 {
btnStar1.setImage(UIImage(named: "filledStar"), for: .normal)
}
if ratingAsInt > 1 {
btnStar2.setImage(UIImage(named: "filledStar"), for: .normal)
}
if ratingAsInt > 2 {
btnStar3.setImage(UIImage(named: "filledStar"), for: .normal)
}
if ratingAsInt > 3 {
btnStar4.setImage(UIImage(named: "filledStar"), for: .normal)
}
if ratingAsInt > 4 {
btnStar5.setImage(UIImage(named: "filledStar"), for: .normal)
}
}
}
}
}
}
......@@ -106,13 +106,8 @@ extension HomePageViewController: UITableViewDelegate, UITableViewDataSource {
cell.switchMode.setOn(User.isOnline, animated: true)
return cell
}else{
let recentOrder = dashboard.orders[indexPath.row-1]
let cell = tableView.dequeueReusableCell(withIdentifier: "services") as! RecentServicesCell
cell.lblService.text = recentOrder.products.first?.name
cell.lblCustomerName.text = recentOrder.customerDetail.name
cell.lblDate.text = recentOrder.customerDetail.date
cell.lblPrice.text = recentOrder.customerDetail.purchaseTotal
cell.recentOrder = dashboard.orders[indexPath.row-1]
return cell
}
......@@ -123,11 +118,35 @@ extension HomePageViewController: UITableViewDelegate, UITableViewDataSource {
if indexPath.row == 0 {
return
}
let appointmentdetails = Utils.viewController(storyboardName: "Appointment", ofType: ServiceDetailViewController.self)
appointmentdetails.serviceStatus = .tbc
appointmentdetails.incrementId = dashboard.orders[indexPath.row-1].incrementId
appointmentdetails.orderId = dashboard.orders[indexPath.row-1].orderId
self.navigationController?.pushViewController(appointmentdetails, animated: true)
let order = dashboard.orders[indexPath.row-1]
if order.products.first?.serviceType == .BOOKING {
let appointmentdetails = Utils.viewController(storyboardName: "Appointment", ofType: ServiceDetailViewController.self)
appointmentdetails.serviceStatus = .tbc
appointmentdetails.incrementId = order.incrementId
appointmentdetails.orderId = order.orderId
self.navigationController?.pushViewController(appointmentdetails, animated: true)
} else if order.products.first?.serviceType == .FAQ {
if order.status == .PROCESSING {
let chatViewController = Utils.viewController(storyboardName: "Home", ofType: OnlineEnquiryViewController.self)
if let orderId = order.orderId {
chatViewController.orderId = orderId
self.navigationController?.pushViewController(chatViewController, animated: true)
}
} else {
let enquiryDetailsViewController = Utils.viewController(storyboardName: "Home", ofType: EnquiryDetailsViewController.self)
enquiryDetailsViewController.incrementId = order.incrementId!
enquiryDetailsViewController.orderId = order.orderId!
self.navigationController?.pushViewController(enquiryDetailsViewController, animated: true)
}
} else {
// TO DO forms
}
}
}
......@@ -209,6 +228,25 @@ class RecentServicesCell: UITableViewCell {
@IBOutlet var lblCustomerName: UILabel!
@IBOutlet var lblDate: UILabel!
@IBOutlet var lblPrice: UILabel!
var recentOrder: Order? {
didSet {
if let recentOrder = recentOrder {
self.lblService.text = recentOrder.products.first?.name
self.lblCustomerName.text = recentOrder.customerDetail.name
self.lblDate.text = recentOrder.customerDetail.date
self.lblPrice.text = recentOrder.customerDetail.purchaseTotal
}
}
}
}
......@@ -21,14 +21,12 @@ class OngoingEnquiryViewController: BaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.setupRefreshHeaderFooter()
enquiry.enquiryFor = EnquiryStatus.SERVICE_ONGOING
enquiry.enquiryFor = EnquiryStatus.PROCESSING
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if enquiry.enquiries.count == 0 {
tblEnquires.mj_header.beginRefreshing()
}
tblEnquires.mj_header.beginRefreshing()
}
func setupRefreshHeaderFooter() {
......@@ -105,7 +103,10 @@ extension OngoingEnquiryViewController: UITableViewDataSource, UITableViewDelega
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
let chatViewController = Utils.viewController(storyboardName: "Home", ofType: OnlineEnquiryViewController.self)
self.navigationController?.pushViewController(chatViewController, animated: true)
if let orderId = enquiry.enquiries[indexPath.row].orderId {
chatViewController.orderId = orderId
self.navigationController?.pushViewController(chatViewController, animated: true)
}
}
}
......@@ -123,7 +124,6 @@ class OngoingEnquiryCell: UITableViewCell {
}
func getTimeFromFirebaseTimeStamp(time: TimeInterval) {
let timeInHoursAgo = Date.pcTimeAgoFrom(Date(timeIntervalSince1970: time/1000))
self.lblTime.text = "\(timeInHoursAgo)"
}
......
......@@ -19,11 +19,13 @@ class OnlineEnquiryViewController: UIViewController {
var ref = Database.database().reference()
var chats = [Chat]()
var orderId: String = "0"
override func viewDidLoad() {
super.viewDidLoad()
ref = Database.database().reference().child("20") // replace 20 with orderid
ref = Database.database().reference().child(orderId)
ref.queryOrdered(byChild: "timestamp") .observe(DataEventType.value, with: { (snapshot) in
self.chats = [Chat]()
if let chatsJSON = snapshot.value as? [String: AnyObject] {
......@@ -89,7 +91,13 @@ extension OnlineEnquiryViewController {
}
let actionYes = UIAlertAction(title: "Yes", style: .default) { (_) in
self.navigationController?.popToRootViewController(animated: true)
UpdateOrder.toComplete(orderId: self.orderId, success: {
self.navigationController?.popToRootViewController(animated: true)
}, failuer: { (errorMessage) in
self.view.showToast(errorMessage, position: .bottom, popTime: 2.0, dismissOnTap: false)
})
}
alerController.addAction(actionNo)
......
......@@ -101,6 +101,7 @@ extension MyAllServiceOrderViewController: UITableViewDelegate, UITableViewDataS
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let serviceDetail = Utils.viewController(storyboardName: "Appointment", ofType: ServiceDetailViewController.self)
serviceDetail.serviceStatus = .tbc
serviceDetail.orderId = service.services[indexPath.row].orderId
self.navigationController?.pushViewController(serviceDetail, animated: true)
}
......
......@@ -100,6 +100,7 @@ extension MyCompletedOrdersViewController: UITableViewDelegate, UITableViewDataS
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let serviceDetail = Utils.viewController(storyboardName: "Appointment", ofType: ServiceDetailViewController.self)
serviceDetail.serviceStatus = .completed
serviceDetail.orderId = service.services[indexPath.row].orderId
self.navigationController?.pushViewController(serviceDetail, animated: true)
}
......
......@@ -100,6 +100,7 @@ extension MyOngoingServiceOrderViewController: UITableViewDelegate, UITableViewD
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let serviceDetail = Utils.viewController(storyboardName: "Appointment", ofType: ServiceDetailViewController.self)
serviceDetail.serviceStatus = .ongoing
serviceDetail.orderId = service.services[indexPath.row].orderId
self.navigationController?.pushViewController(serviceDetail, animated: true)
}
......
......@@ -100,6 +100,7 @@ extension MyUploadResultViewController: UITableViewDelegate, UITableViewDataSour
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let serviceDetail = Utils.viewController(storyboardName: "Appointment", ofType: ServiceDetailViewController.self)
serviceDetail.serviceStatus = .ongoing
serviceDetail.orderId = service.services[indexPath.row].orderId
self.navigationController?.pushViewController(serviceDetail, animated: true)
}
......
......@@ -10,8 +10,9 @@ import Foundation
enum EnquiryStatus: String {
case SERVICE_ONGOING
case SERVICE_COMPLETE
case PROCESSING
case COMPLETE
}
......@@ -19,13 +20,13 @@ class Enquiry {
var bookingTill: String?
var status: EnquiryStatus = EnquiryStatus.SERVICE_ONGOING
var status: EnquiryStatus = EnquiryStatus.PROCESSING
var orderId: String?
var incrementId: String?
var customerName: String?
var customerProfileImage: String?
var enquiryFor = EnquiryStatus.SERVICE_ONGOING
var enquiryFor = EnquiryStatus.PROCESSING
var enquiries = [Enquiry]()
var currentPage: Int = 1
var maxPage: Int = 0
......
......@@ -30,10 +30,10 @@ extension Enquiry {
private func enquiriesForPage(success: @escaping () -> Void, failuer: @escaping (_ errorMessage: String) -> Void) {
var statusFilter = ""
if enquiryFor == .SERVICE_ONGOING {
statusFilter = "service_complete"
if enquiryFor == .PROCESSING {
statusFilter = "processing"
} else {
statusFilter = "service_ongoing"
statusFilter = "complete"
}
let paramenters: [String: Any] = ["storeId": UserDefaults.standard.value(forKey: "storeId") as! String, "status": statusFilter]
......
......@@ -20,6 +20,7 @@ enum SellerOrderStatus: String {
case PROCESSING
}
class Order {
var orderId: String?
......@@ -29,6 +30,7 @@ class Order {
var customerDetail = Customer()
func initWithJSON(json: Any) {
if let response = json as? [String: Any] {
self.orderId = response["orderId"] as? String
self.incrementId = response["incrementId"] as? String
......
......@@ -8,15 +8,33 @@
import Foundation
enum ServiceType: String {
case FAQ
case BOOKING
case FORM
}
class Product {
var productId: String?
var name: String?
var qty: Int = 0
var serviceType = ServiceType.BOOKING
func initWithJSON(json: Any) {
if let response = json as? [String: Any] {
self.productId = response["productId"] as? String
self.name = response["name"] as? String
if let productName = response["name"] as? String {
self.name = productName
if productName == "Online FAQ Service" {
self.serviceType = .FAQ
} else if productName == "dff" {
self.serviceType = .BOOKING
} else {
self.serviceType = .FORM
}
}
self.qty = response["qty"] as! Int
}
}
......
//
// UpdateOrder.swift
// Bhagyashree
//
// Created by SunarcMAC on 18/08/18.
// Copyright © 2018 Sunarc. All rights reserved.
//
import Foundation
import SVProgressHUD
class UpdateOrder {
class private func updateOrder(to status: String, orderId: String, success: @escaping () -> Void, failuer: @escaping (_ message: String) -> Void) {
SVProgressHUD.show()
let headers = [
"authkey": UserDefaults.standard.value(forKey: "authKey") as! String,
"content-type": "application/json"
]
let parameters = [
"storeId": UserDefaults.standard.value(forKey: "storeId") as! String,
"orderId": orderId,
"status": status
] as [String : Any]
let postData = try! JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "http://54.251.144.17/rest/V1/service/updateorder")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
DispatchQueue.main.async {
SVProgressHUD.dismiss()
if (error != nil) {
failuer(error!.localizedDescription)
} else {
do {
let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers)
if let jsonData = json as? [[String: Any]] {
if jsonData.count > 0 {
guard let status = jsonData[0]["api_status"] as? [String: Any] else {
failuer("try again")
return
}
if let responseStatus = status["status"] as? Bool {
if responseStatus == true {
success()
} else {
let message = status["message"] as! String
failuer(message)
}
} else {
failuer("try again")
}
}
}
} catch let myJSONError {
failuer(myJSONError.localizedDescription)
}
}
}
})
dataTask.resume()
}
class func toComplete(orderId: String, success: @escaping () -> Void, failuer: @escaping (_ message: String) -> Void) {
UpdateOrder.updateOrder(to: "complete", orderId: orderId, success: success, failuer: failuer)
}
class func toUploadResult(orderId: String, success: @escaping () -> Void, failuer: @escaping (_ message: String) -> Void) {
UpdateOrder.updateOrder(to: "service_upload_result", orderId: orderId, success: success, failuer: failuer)
}
class func toOngoing(orderId: String, success: @escaping () -> Void, failuer: @escaping (_ message: String) -> Void) {
UpdateOrder.updateOrder(to: "service_ongoing", orderId: orderId, success: success, failuer: failuer)
}
}
......@@ -39,6 +39,8 @@ class API {
static let VIEW_ORDER = "mobikulmphttp/marketplace/viewOrder"
static let RECOMEND_PRODUCTS = "/rest/V1/seller/recommendedproducts?page="
static let UPDATE_RESULT = "/rest/V1/service/saveResult"
static let UPDATE_ORDER = "rest/V1/service/updateorder"
}
......
......@@ -18,7 +18,6 @@ class HTTP: NSObject {
SVProgressHUD.show()
}
// Build request object
var request = URLRequest(url: URL(string: HOST_NAME + api)!)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment