Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (IBAction)saveCustomer:(id)sender {
- @try {
- [self.view endEditing:YES];
- // Cannot save if customer is pending
- if ([self.service isWaitingForApproval]) {
- APAlert(WARNING_TITLE, NSLocalizedString(@"message.waiting-approval", nil));
- return;
- }
- // Check required field
- NSString *incompleteRequiredField = [self.service checkRequiredFields];
- if (incompleteRequiredField) {
- NSString *message = [NSString localizedStringWithFormat:NSLocalizedString(@"message.required field %@", nil), NSLocalizedString(incompleteRequiredField, nil)];
- APAlert(WARNING_TITLE, message);
- return;
- }
- if(![self.service isDistributorOrWholesalerInTW]) {
- incompleteRequiredField = [self checkRequireCellOTM];
- if(incompleteRequiredField) {
- NSString *message = [NSString localizedStringWithFormat:NSLocalizedString(@"message.required otm %@", nil), NSLocalizedString(incompleteRequiredField, nil)];
- APAlert(WARNING_TITLE, message);
- return;
- }
- }
- Country_Identifier countryID = (Country_Identifier)[self.service.customer.country_id integerValue];
- if (countryID == Country_Taiwan || countryID == Country_Thailand) {
- if (![self.service isHasContact]) {
- APAlert(WARNING_TITLE, ALERT_CONFRIM_HAVE_CONTACT);
- return;
- }
- }
- [[SomeManager alertViewManager] showAlertWithTitle:SAVING_TITLE
- message:SAVE_CUSTOMER_CONFIRM
- target:self
- actionView:nil
- cancelButtonTitle:YES_BUTTON_TITLE
- otherButtonTitles:NO_BUTTON_TITLE
- andTag:AlertViewTag_Save];
- }
- @catch(NSException *exception) {
- [self sendException:exception];
- }
- }
- - (NSString*)validateServiceReadiness:(NSString*)requiredCellOTM {
- // Cannot save if customer is pending
- if ([self isWaitingForApproval]) {
- return NSLocalizedString(@"message.waiting-approval", nil);
- }
- // Check required field
- NSString *incompleteRequiredField = [self checkRequiredFields];
- if (incompleteRequiredField) {
- NSString *message = [NSString localizedStringWithFormat:NSLocalizedString(@"message.required field %@", nil), NSLocalizedString(incompleteRequiredField, nil)];
- return message;
- }
- if(![self isDistributorOrWholesalerInTW]) {
- incompleteRequiredField = requiredCellOTM;
- if(incompleteRequiredField) {
- NSString *message = [NSString localizedStringWithFormat:NSLocalizedString(@"message.required otm %@", nil), NSLocalizedString(incompleteRequiredField, nil)];
- return message;
- }
- }
- Country_Identifier countryID = (Country_Identifier)[self.customer.country_id integerValue];
- if (countryID == Country_Taiwan || countryID == Country_Thailand) {
- if (![self isHasContact]) {
- return ALERT_CONFRIM_HAVE_CONTACT;
- }
- }
- }
- - (IBAction)saveCustomer:(id)sender {
- @try {
- [self.view endEditing:YES];
- NSString *serviceReadinessMessage = [self.service validateServiceReadiness:[self checkRequireCellOTM]];
- if (serviceReadynessMessage != nil) {
- APAlert(WARNING_TITLE, serviceReadinessMessage);
- return;
- }
- [[SomeManager alertViewManager] showAlertWithTitle:SAVING_TITLE
- message:SAVE_CUSTOMER_CONFIRM
- target:self
- actionView:nil
- cancelButtonTitle:YES_BUTTON_TITLE
- otherButtonTitles:NO_BUTTON_TITLE
- andTag:AlertViewTag_Save];
- }
- @catch(NSException *exception) {
- [self sendException:exception];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement