CartGeneralNotesViewController.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. //
  2. // CartGeneralNotesViewController.m
  3. // iSales-NPD
  4. //
  5. // Created by Ray on 2/16/16.
  6. // Copyright © 2016 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "CartGeneralNotesViewController.h"
  9. #import "RANetwork.h"
  10. @interface CartGeneralNotesViewController ()
  11. @end
  12. @implementation CartGeneralNotesViewController
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. #ifdef SCANNER_ORDER
  16. self.title = @"Special Instructions";
  17. #endif
  18. self.tv_notes.text = self.notes;
  19. // Do any additional setup after loading the view.
  20. if (@available(iOS 11, *)) {
  21. self.tv_notes.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  22. }
  23. // else {
  24. //
  25. //// self.tv_notes.scrollView.contentInsetAdjustmentBehavior =UIScrollViewContentInsetAdjustmentNever;
  26. //
  27. // self.automaticallyAdjustsScrollViewInsets = NO;
  28. // }
  29. // self.automaticallyAdjustsScrollViewInsets = NO;
  30. // self.navigationController.navigationBar.translucent = NO;
  31. self.tv_notes.layer.borderColor = [UIColor lightGrayColor].CGColor;
  32. self.tv_notes.layer.borderWidth = 1.0f;
  33. }
  34. - (void)didReceiveMemoryWarning {
  35. [super didReceiveMemoryWarning];
  36. // Dispose of any resources that can be recreated.
  37. }
  38. - (IBAction)onCloseClicked:(id)sender {
  39. [self dismissViewControllerAnimated:NO
  40. completion:^{
  41. }];
  42. }
  43. - (IBAction)onSaveClicked:(id)sender {
  44. // [self.tv_notes endEditing:true];
  45. self.notes = self.tv_notes.text;
  46. NSString* notes=self.tv_notes.text;
  47. UIApplication * app = [UIApplication sharedApplication];
  48. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  49. __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Update General Notes" completion:^{
  50. [RANetwork request_update_cartgeneralnote:appDelegate.order_code notes:notes completionHandler:^(NSMutableDictionary *result) {
  51. NSDictionary* cart_json = result;
  52. [waitalert dismissViewControllerAnimated:YES completion:^{
  53. // [waitalert dismissViewControllerAnimated:YES completion:nil];
  54. if([[cart_json valueForKey:@"result"] intValue]==2)
  55. {
  56. [self dismissViewControllerAnimated:NO
  57. completion:^{
  58. if(self.onSetValue)
  59. self.onSetValue(self.notes);
  60. }];
  61. }
  62. else
  63. {
  64. [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Update General Notes" controller:self] ;
  65. }
  66. }];
  67. }];
  68. }];
  69. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  70. //
  71. // NSDictionary* cart_json = nil;
  72. //
  73. //
  74. //
  75. //
  76. // cart_json = [RANetwork cart_setGeneralNote:appDelegate.order_code notes:notes];
  77. //
  78. // dispatch_async(dispatch_get_main_queue(), ^{
  79. //
  80. //
  81. // [waitalert dismissViewControllerAnimated:YES completion:nil];
  82. //// [waitalert dismissViewControllerAnimated:YES completion:nil];
  83. // if([[cart_json valueForKey:@"result"] intValue]==2)
  84. // {
  85. // [self dismissViewControllerAnimated:NO
  86. // completion:^{
  87. //
  88. // if(self.onSetValue)
  89. // self.onSetValue(self.notes);
  90. //
  91. // }];
  92. // }
  93. // else
  94. // {
  95. // [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Update General Notes" controller:self] ;
  96. // }
  97. //
  98. //
  99. //
  100. //
  101. // });
  102. // });
  103. }
  104. /*
  105. #pragma mark - Navigation
  106. // In a storyboard-based application, you will often want to do a little preparation before navigation
  107. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  108. // Get the new view controller using [segue destinationViewController].
  109. // Pass the selected object to the new view controller.
  110. }
  111. */
  112. @end