Permalink
Browse files

changes

  • Loading branch information...
1 parent 275cc97 commit 691b4c6e513e6fac8ec549f05b43211aaa2a1293 @jovhenni19 committed Feb 5, 2014
@@ -34,6 +34,7 @@ @interface ABridge_ActivityPagesViewController ()
@property (strong, nonatomic) LoginDetails * loginDetail;
@property (strong, nonatomic) NSString *pricePaid;
+@property (strong, nonatomic) NSString *clrf_id;
- (IBAction)buttonActionPressed:(id)sender;
@end
@@ -46,6 +47,7 @@ @implementation ABridge_ActivityPagesViewController
@synthesize urlConnectionRequestNetwork;
@synthesize loginDetail;
@synthesize pricePaid;
+@synthesize clrf_id;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
@@ -624,6 +626,8 @@ - (void)viewDidLoad
// //NSLog(@"json:%@",json);
if([[json objectForKey:@"data"] count]){
+ self.clrf_id = [[[json objectForKey:@"data"] firstObject] valueForKey:@"clrf_id"];
+
if ([[[[json objectForKey:@"data"] firstObject] valueForKey:@"r1_paid"] boolValue] == YES) {
self.labelDescription.hidden = NO;
@@ -679,11 +683,11 @@ - (void)viewDidLoad
NSString *message_block = @"";
if ([[json objectForKey:@"data"] count] == 0) {
- message_block = [NSString stringWithFormat:@"You have accepted %@'s %@ referral on %@. You have signed the Referral Agreement.", user_name, self.activityDetail.referral_fee, buyer_block];
+ message_block = [NSString stringWithFormat:/*@"You have accepted %@'s %@ referral on %@.*/ @"%@ have accepted your %@ referral on %@. You have signed the Referral Agreement.", user_name, self.activityDetail.referral_fee, buyer_block];
}
else {
- message_block = [NSString stringWithFormat:@"You have accepted %@'s %@ referral on %@. You have not signed the Referral Agreement.", user_name, self.activityDetail.referral_fee, buyer_block];
+ message_block = [NSString stringWithFormat:/*@"You have accepted %@'s %@ referral on %@.*/ @"%@ have accepted your %@ referral on %@. You have not signed the Referral Agreement.", user_name, self.activityDetail.referral_fee, buyer_block];
dispatch_async(dispatch_get_main_queue(), ^{
// self.viewForDescription.hidden = NO;
@@ -1590,10 +1594,40 @@ - (void)transactionCompletedSuccessfully {
// //NSLog(@"json:%@",json);
if([[json objectForKey:@"status"] integerValue] == 1){
- self.labelDescription.hidden = NO;
+ self.labelDescription.hidden = YES;
self.buttonDescription.hidden = YES;
- self.labelDescription.text = @"Thank you for the payment. You may now change the status of the Referral to Completed.";
+
+ NSString *updateCloseReferralString = [NSString stringWithFormat:@"http://keydiscoveryinc.com/agent_bridge/webservice/save_closed_referral_r1.php?close_referral_id=%@", self.clrf_id];
+
+
+
+ __block NSError *errorDataCLRF = nil;
+ __weak ASIHTTPRequest *requestCLRF = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:updateCloseReferralString]];
+ [requestCLRF setCompletionBlock:^{
+ // Use when fetching text data
+ // NSString *responseString = [request responseString];
+ // Use when fetching binary data
+ NSData *responseDataCLRF = [requestCLRF responseData];
+ NSDictionary *jsonCLRF = [NSJSONSerialization JSONObjectWithData:responseDataCLRF options:NSJSONReadingAllowFragments error:&errorDataCLRF];
+
+ NSLog(@"json:%@",jsonCLRF);
+ if([[json objectForKey:@"status"] integerValue] == 1){
+
+ self.labelDescription.hidden = NO;
+ self.buttonDescription.hidden = YES;
+
+ self.labelDescription.text = @"Thank you for the payment. You may now change the status of the Referral to Completed.";
+
+ }
+
+ }];
+ [requestCLRF setFailedBlock:^{
+ NSError *error = [requestCLRF error];
+ NSLog(@" error:%@",error);
+
+ }];
+ [requestCLRF startAsynchronous];
}
}];
@@ -655,7 +655,9 @@ - (IBAction)continuePressed:(id)sender {
}
else {
- UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your Gross Commission exceeds the limit." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
+ UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your Gross Commission exceeds the limit." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
+ av.tag = 12;
+ [self.grossCommission setString:@""];
[av show];
}
@@ -857,7 +859,7 @@ - (IBAction)submitTransaction:(id)sender {
// CGFloat total = [self.grossCommission doubleValue] + [self.serviceFee doubleValue];
- NSString *parameters = [[NSString stringWithFormat:@"?amount=%f&service_fee=%f&card_num=%@&card_exp=%@&user_id=%@&firstname=%@&lastname=%@&address=%@&city=%@&state=%@&zip=%@&country=%@&phone=%@&email=%@&referral_id=%@",[self.grossCommission doubleValue], [self.serviceFee doubleValue], self.textFieldCreditCard.text, [self.cardExpiry stringByReplacingOccurrencesOfString:@"/" withString:@"%2F"], self.user_id, self.textFieldFirstname.text, self.textFieldLastname.text, [NSString stringWithFormat:@"%@,%@",self.textFieldAddress1.text,self.textFieldAddress2.text], self.textFieldCity.text, self.selectedStateID, self.textFieldZipcode.text, self.selectedCountryID, [self.textFieldPhoneNumber.text stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding], self.textFieldEmail.text, self.referral_id] stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
+ NSString *parameters = [[NSString stringWithFormat:@"?amount=%f&service_fee=%f&card_num=%@&card_exp=%@&user_id=%@&firstname=%@&lastname=%@&address=%@&city=%@&state=%@&zip=%@&country=%@&phone=%@&email=%@&referral_id=%@",[self.grossCommission doubleValue], [self.serviceFee doubleValue], self.textFieldCreditCard.text, [self.cardExpiry stringByReplacingOccurrencesOfString:@"/" withString:@"-"], self.user_id, self.textFieldFirstname.text, self.textFieldLastname.text, [NSString stringWithFormat:@"%@,%@",self.textFieldAddress1.text,self.textFieldAddress2.text], self.textFieldCity.text, self.selectedStateID, self.textFieldZipcode.text, self.selectedCountryID, [self.textFieldPhoneNumber.text stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding], self.textFieldEmail.text, self.referral_id] stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSMutableString *urlString = [NSMutableString stringWithString:@"http://keydiscoveryinc.com/agent_bridge/webservice/send_transaction.php"];
[urlString appendString:parameters];
@@ -874,7 +876,7 @@ - (IBAction)submitTransaction:(id)sender {
^{
NSData *responseData = [request responseData];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingAllowFragments error:&errorData];
- NSLog(@"json:%@",json);
+// NSLog(@"json:%@",json);
if ([[json objectForKey:@"status"] integerValue] == YES) {
self.invoice_number = [[json objectForKey:@"data"] objectForKey:@"invoice_number"];
[self createInvoicePDF];
@@ -1184,18 +1186,20 @@ - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row f
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
if (pickerView == self.pickerExpiry) {
NSMutableString *expiry = [NSMutableString stringWithString:@""];
- if (component == 0) {
- if(row < 9){
- [expiry appendFormat:@"0%li",(long)row+1];
- }
- else {
- [expiry appendFormat:@"%li",(long)row+1];
- }
-
- NSInteger yearRow = [pickerView selectedRowInComponent:1];
- [expiry appendFormat:@"/%@",[[self.arrayOfYear objectAtIndex:yearRow] substringFromIndex:2]];
- }
- else {
+// if (component == 0) {
+//
+// NSInteger monthRow = [pickerView selectedRowInComponent:0];
+// if(monthRow < 9){
+// [expiry appendFormat:@"0%li",(long)monthRow+1];
+// }
+// else {
+// [expiry appendFormat:@"%li",(long)monthRow+1];
+// }
+//
+// NSInteger yearRow = [pickerView selectedRowInComponent:1];
+// [expiry appendFormat:@"/%@",[[self.arrayOfYear objectAtIndex:yearRow] substringFromIndex:2]];
+// }
+// else {
NSInteger monthRow = [pickerView selectedRowInComponent:0];
if(monthRow < 9){
[expiry appendFormat:@"0%li",(long)monthRow+1];
@@ -1204,8 +1208,8 @@ - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComp
[expiry appendFormat:@"%li",(long)monthRow+1];
}
- [expiry appendFormat:@"/%@",[[self.arrayOfYear objectAtIndex:row] substringFromIndex:2]];
- }
+ [expiry appendFormat:@"/%@",[self.arrayOfYear objectAtIndex:row]];
+// }
self.cardExpiry = expiry;
[self.buttonExpiry setTitle:[NSString stringWithFormat:@"Expiry date: %@",expiry] forState:UIControlStateNormal];
}
@@ -1344,6 +1348,14 @@ - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)butto
case 1:
[self.textFieldGrossComission becomeFirstResponder];
break;
+ case 12:{
+ [UIView animateWithDuration:0.2 animations:^{
+ [self.scrollView setContentOffset:CGPointMake(self.scrollView.contentOffset.x - 320.0f, 0.0f)];
+ } completion:^(BOOL finished) {
+
+ [self.textFieldGrossComission becomeFirstResponder];
+ }];}
+ break;
case 21:
[self.textFieldFirstname becomeFirstResponder];
break;
@@ -1369,21 +1381,61 @@ - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)butto
[self statePressed:nil];
break;
case 99:{
+// NSString *parameters = [NSString stringWithFormat:@"?referral_id=%@&price_paid=%@", self.referral_id, self.grossCommission];
+//
+// NSString *urlString = @"";
+// if (self.grossCommissionValue != nil && [self.grossCommissionValue isEqualToString:@""] == NO) {
+// //r1
+// urlString = [NSString stringWithFormat:@"http://keydiscoveryinc.com/agent_bridge/webservice/save_closed_referral_r1.php%@", parameters];
+// }
+// else {
+// //r2
+// urlString = [NSString stringWithFormat:@"http://keydiscoveryinc.com/agent_bridge/webservice/save_closed_referral_r2.php%@", parameters];
+// }
+//
+//// NSString *parameters = [NSString stringWithFormat:@"?referral_id=%@&price_paid=%@", self.referral_id, self.grossCommission];
+////
+//// NSString *urlString = [NSString stringWithFormat:@"http://keydiscoveryinc.com/agent_bridge/webservice/save_closed_referral.php%@", parameters];
+//
+//
+// __block NSError *errorData = nil;
+// __weak ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:urlString]];
+// [request setCompletionBlock:^{
+// // Use when fetching text data
+// // NSString *responseString = [request responseString];
+// // Use when fetching binary data
+// NSData *responseData = [request responseData];
+// NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingAllowFragments error:&errorData];
+//
+// NSLog(@"json:%@",json);
+// if([[json objectForKey:@"status"] integerValue] == 1){
+//
+// [self dismissViewControllerAnimated:YES completion:^{
+// [self.delegate transactionCompletedSuccessfully];
+// }];
+// }
+//
+// }];
+// [request setFailedBlock:^{
+// NSError *error = [request error];
+// NSLog(@" error:%@",error);
+//
+// }];
+// [request startAsynchronous];
+//
+
NSString *parameters = [NSString stringWithFormat:@"?referral_id=%@&price_paid=%@", self.referral_id, self.grossCommission];
NSString *urlString = @"";
- if (self.grossCommissionValue != nil && [self.grossCommissionValue isEqualToString:@""] == NO) {
- //r1
- urlString = [NSString stringWithFormat:@"http://keydiscoveryinc.com/agent_bridge/webservice/save_closed_referral_r1.php%@", parameters];
- }
- else {
+ if (self.grossCommissionValue == nil || [self.grossCommissionValue isEqualToString:@""] == YES) {
+
//r2
urlString = [NSString stringWithFormat:@"http://keydiscoveryinc.com/agent_bridge/webservice/save_closed_referral_r2.php%@", parameters];
- }
-// NSString *parameters = [NSString stringWithFormat:@"?referral_id=%@&price_paid=%@", self.referral_id, self.grossCommission];
-//
-// NSString *urlString = [NSString stringWithFormat:@"http://keydiscoveryinc.com/agent_bridge/webservice/save_closed_referral.php%@", parameters];
+
+ // NSString *parameters = [NSString stringWithFormat:@"?referral_id=%@&price_paid=%@", self.referral_id, self.grossCommission];
+ //
+ // NSString *urlString = [NSString stringWithFormat:@"http://keydiscoveryinc.com/agent_bridge/webservice/save_closed_referral.php%@", parameters];
__block NSError *errorData = nil;
@@ -1395,7 +1447,7 @@ - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)butto
NSData *responseData = [request responseData];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingAllowFragments error:&errorData];
- //NSLog(@"json:%@",json);
+// NSLog(@"json:%@",json);
if([[json objectForKey:@"status"] integerValue] == 1){
[self dismissViewControllerAnimated:YES completion:^{
@@ -1410,10 +1462,17 @@ - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)butto
}];
[request startAsynchronous];
-
+
+ }
+ else {
+
+ [self dismissViewControllerAnimated:YES completion:^{
+ [self.delegate transactionCompletedSuccessfully];
+ }];
+ }
break;
- }
+ }
default:
break;
}
Oops, something went wrong.

0 comments on commit 691b4c6

Please sign in to comment.