ItemNotesViewController.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // ItemNotesViewController.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 "ItemNotesViewController.h"
  9. #import "RANetwork.h"
  10. @interface ItemNotesViewController ()
  11. @end
  12. @implementation ItemNotesViewController
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. self.tv_notes.text = self.notes;
  16. // Do any additional setup after loading the view.
  17. if (@available(iOS 11, *)) {
  18. self.tv_notes.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  19. }
  20. else {
  21. self.automaticallyAdjustsScrollViewInsets = NO;
  22. }
  23. // self.automaticallyAdjustsScrollViewInsets = NO;
  24. self.navigationController.navigationBar.translucent = NO;
  25. self.tv_notes.layer.borderColor = [UIColor lightGrayColor].CGColor;
  26. self.tv_notes.layer.borderWidth = 1.0f;
  27. }
  28. - (void)didReceiveMemoryWarning {
  29. [super didReceiveMemoryWarning];
  30. // Dispose of any resources that can be recreated.
  31. }
  32. - (IBAction)onCloseClicked:(id)sender {
  33. [self dismissViewControllerAnimated:NO
  34. completion:^{
  35. }];
  36. }
  37. - (IBAction)onSaveClicked:(id)sender {
  38. [self.tv_notes endEditing:true];
  39. self.notes = self.tv_notes.text;
  40. UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Update Item Notes"];
  41. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  42. NSDictionary* cart_json = nil;
  43. cart_json = [RANetwork cart_setItemNote:self.cart_id notes:self.tv_notes.text];
  44. dispatch_async(dispatch_get_main_queue(), ^{
  45. [waitalert dismissViewControllerAnimated:YES completion:nil];
  46. if([[cart_json valueForKey:@"result"] intValue]==2)
  47. {
  48. [self dismissViewControllerAnimated:NO
  49. completion:^{
  50. if(self.onSaveNote)
  51. self.onSaveNote(self.notes);
  52. }];
  53. }
  54. else
  55. {
  56. [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Update Item Notes" controller:self] ;
  57. }
  58. });
  59. });
  60. }
  61. /*
  62. #pragma mark - Navigation
  63. // In a storyboard-based application, you will often want to do a little preparation before navigation
  64. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  65. // Get the new view controller using [segue destinationViewController].
  66. // Pass the selected object to the new view controller.
  67. }
  68. */
  69. @end