CartGeneralNotesViewController.m 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. self.tv_notes.text = self.notes;
  16. // Do any additional setup after loading the view.
  17. self.automaticallyAdjustsScrollViewInsets = NO;
  18. self.navigationController.navigationBar.translucent = NO;
  19. self.tv_notes.layer.borderColor = [UIColor lightGrayColor].CGColor;
  20. self.tv_notes.layer.borderWidth = 1.0f;
  21. }
  22. - (void)didReceiveMemoryWarning {
  23. [super didReceiveMemoryWarning];
  24. // Dispose of any resources that can be recreated.
  25. }
  26. - (IBAction)onCloseClicked:(id)sender {
  27. [self dismissViewControllerAnimated:NO
  28. completion:^{
  29. }];
  30. }
  31. - (IBAction)onSaveClicked:(id)sender {
  32. // [self.tv_notes endEditing:true];
  33. self.notes = self.tv_notes.text;
  34. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Update General Notes"];
  35. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  36. NSDictionary* cart_json = nil;
  37. UIApplication * app = [UIApplication sharedApplication];
  38. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  39. cart_json = [RANetwork cart_setGeneralNote:appDelegate.order_code notes:self.tv_notes.text];
  40. dispatch_async(dispatch_get_main_queue(), ^{
  41. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  42. if([[cart_json valueForKey:@"result"] intValue]==2)
  43. {
  44. [self dismissViewControllerAnimated:NO
  45. completion:^{
  46. if(self.onSetValue)
  47. self.onSetValue(self.notes);
  48. }];
  49. }
  50. else
  51. {
  52. [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Update General Notes" controller:self] ;
  53. }
  54. });
  55. });
  56. }
  57. /*
  58. #pragma mark - Navigation
  59. // In a storyboard-based application, you will often want to do a little preparation before navigation
  60. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  61. // Get the new view controller using [segue destinationViewController].
  62. // Pass the selected object to the new view controller.
  63. }
  64. */
  65. @end