ItemNotesViewController.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. }
  18. - (void)didReceiveMemoryWarning {
  19. [super didReceiveMemoryWarning];
  20. // Dispose of any resources that can be recreated.
  21. }
  22. - (IBAction)onCloseClicked:(id)sender {
  23. [self dismissViewControllerAnimated:NO
  24. completion:^{
  25. }];
  26. }
  27. - (IBAction)onSaveClicked:(id)sender {
  28. [self.tv_notes endEditing:true];
  29. self.notes = self.tv_notes.text;
  30. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Update Item Notes"];
  31. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  32. NSDictionary* cart_json = nil;
  33. cart_json = [RANetwork cart_setItemNote:self.cart_id notes:self.tv_notes.text];
  34. dispatch_async(dispatch_get_main_queue(), ^{
  35. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  36. if([[cart_json valueForKey:@"result"] intValue]==2)
  37. {
  38. [self dismissViewControllerAnimated:NO
  39. completion:^{
  40. if(self.onSaveNote)
  41. self.onSaveNote(self.notes);
  42. }];
  43. }
  44. else
  45. {
  46. [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Update Item Notes" controller:self] ;
  47. }
  48. });
  49. });
  50. }
  51. /*
  52. #pragma mark - Navigation
  53. // In a storyboard-based application, you will often want to do a little preparation before navigation
  54. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  55. // Get the new view controller using [segue destinationViewController].
  56. // Pass the selected object to the new view controller.
  57. }
  58. */
  59. @end