|
|
@@ -186,10 +186,10 @@
|
|
|
}
|
|
|
return template;
|
|
|
}
|
|
|
--(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
|
|
|
-{
|
|
|
-
|
|
|
-}
|
|
|
+//-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
|
|
|
+//{
|
|
|
+//
|
|
|
+//}
|
|
|
|
|
|
-(void) setupTemplete
|
|
|
{
|
|
|
@@ -521,7 +521,7 @@
|
|
|
{
|
|
|
|
|
|
|
|
|
- NSArray* arr =self.pageViewController.viewControllers;
|
|
|
+// NSArray* arr =self.pageViewController.viewControllers;
|
|
|
|
|
|
PageViewController *currentViewController = (PageViewController*)self.pageViewController.viewControllers[0];
|
|
|
// PageViewController *currentViewController = (PageViewController*)self.pageViewController.viewControllers[self.current_page];
|
|
|
@@ -544,7 +544,7 @@
|
|
|
|
|
|
NSString* pdffile = nil;
|
|
|
NSString* zipfile = nil;
|
|
|
- NSString* jsonfile = nil;
|
|
|
+// NSString* jsonfile = nil;
|
|
|
// for(int l=0;l<1;l++)
|
|
|
{
|
|
|
|
|
|
@@ -608,128 +608,223 @@
|
|
|
// __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Saving" completion:^{
|
|
|
|
|
|
PopWaitAlert* pop =[RAUtils waiting_pop:@"Saving..." completion:nil];
|
|
|
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
-
|
|
|
- NSDictionary* json = nil;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- json = [RANetwork save_document:zipfile isnew:self.action==PDFEditActionNew];
|
|
|
-
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
-
|
|
|
-
|
|
|
-// [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
-// [waitalert dismissViewControllerAnimated:YES completion:^{
|
|
|
- [pop hide];
|
|
|
- if([[json valueForKey:@"result"] intValue]==2)
|
|
|
+
|
|
|
+ [RANetwork request_save_document:zipfile isnew:self.action==PDFEditActionNew completionHandler:^(NSMutableDictionary *result) {
|
|
|
+ NSDictionary* json = result;
|
|
|
+
|
|
|
+ [pop hide];
|
|
|
+ if([[json valueForKey:@"result"] intValue]==2)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ [weakSelf.navigationController popViewControllerAnimated:false];
|
|
|
+ if(weakSelf.OnSave)
|
|
|
+ weakSelf.OnSave(pdffile,json[@"subject"]);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Save document" controller:self] ;
|
|
|
+
|
|
|
+ if(self.hide_control)
|
|
|
{
|
|
|
+ //提交离线合同
|
|
|
+// [RAUtils message_alert:@"Can not upload pending documents please try again later." title:@"Save document" controller:self] ;
|
|
|
|
|
|
-
|
|
|
- [weakSelf.navigationController popViewControllerAnimated:false];
|
|
|
- if(weakSelf.OnSave)
|
|
|
- weakSelf.OnSave(pdffile,json[@"subject"]);
|
|
|
-
|
|
|
-
|
|
|
+ [RAUtils message_box:@"Save document" message:@"Can not upload pending documents please try again later." completion:nil];
|
|
|
+ return;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- // [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Save document" controller:self] ;
|
|
|
-
|
|
|
- if(self.hide_control)
|
|
|
+
|
|
|
+ UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Create Customer" message:@"Can not create new customer on server, do you want to create an offline document?" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+
|
|
|
+
|
|
|
+ UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
|
|
|
+ __block NSString* offline_docnumber =[RANetwork offline_docnumber];
|
|
|
+ if(offline_docnumber==nil)
|
|
|
{
|
|
|
- //提交离线合同
|
|
|
-// [RAUtils message_alert:@"Can not upload pending documents please try again later." title:@"Save document" controller:self] ;
|
|
|
+// [RAUtils message_alert:@"Offline document number prefix not found, Please check your user name and make sure you had signed in at least once." title:@"Create Customer" controller:self] ;
|
|
|
|
|
|
- [RAUtils message_box:@"Save document" message:@"Can not upload pending documents please try again later." completion:nil];
|
|
|
+ [RAUtils message_box:@"Create Customer" message:@"Offline document number prefix not found, Please check your user name and make sure you had signed in at least once." completion:nil];
|
|
|
return;
|
|
|
}
|
|
|
+ [appDelegate SwitchToOffline:RASingleton.sharedInstance.user];
|
|
|
|
|
|
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Create Customer" message:@"Can not create new customer on server, do you want to create an offline document?" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
|
+ NSMutableDictionary * json = [[NSMutableDictionary alloc]init];
|
|
|
|
|
|
- UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
|
|
|
- __block NSString* offline_docnumber =[RANetwork offline_docnumber];
|
|
|
- if(offline_docnumber==nil)
|
|
|
- {
|
|
|
-// [RAUtils message_alert:@"Offline document number prefix not found, Please check your user name and make sure you had signed in at least once." title:@"Create Customer" controller:self] ;
|
|
|
-
|
|
|
- [RAUtils message_box:@"Create Customer" message:@"Offline document number prefix not found, Please check your user name and make sure you had signed in at least once." completion:nil];
|
|
|
- return;
|
|
|
- }
|
|
|
- [appDelegate SwitchToOffline:RASingleton.sharedInstance.user];
|
|
|
-
|
|
|
-
|
|
|
- NSMutableDictionary * json = [[NSMutableDictionary alloc]init];
|
|
|
-
|
|
|
- json[@"json"]=@"json.json";
|
|
|
- json[@"pdf"]=pdffile.lastPathComponent;
|
|
|
- json[@"zip"]=zipfile.lastPathComponent;
|
|
|
- json[@"serial"]=[json[@"zip"] stringByDeletingPathExtension];
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- json[@"create_by"]=RASingleton.sharedInstance.user;
|
|
|
-
|
|
|
-
|
|
|
- json[@"agent_name"]=[self extract_data:@"sales_person"];
|
|
|
- json[@"doc_number"]=[self extract_data:@"doc_number"];
|
|
|
- json[@"job_date"]=[self extract_data:@"job_date"];
|
|
|
- json[@"customer_name"]=[self extract_data:@"customer_name"];
|
|
|
- json[@"signed_date"]=[self extract_data:@"signed_date"];
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
|
|
|
- NSMutableArray * arr_pending = [[defaults arrayForKey:@"pending_doc"] mutableCopy];
|
|
|
- if(arr_pending==nil)
|
|
|
- arr_pending = [[NSMutableArray alloc]init];
|
|
|
- [arr_pending addObject:json];
|
|
|
- [defaults setObject:arr_pending forKey:@"pending_doc"];
|
|
|
- [defaults synchronize];
|
|
|
-
|
|
|
-
|
|
|
- [weakSelf.navigationController popViewControllerAnimated:false];
|
|
|
- if(weakSelf.OnSave)
|
|
|
- weakSelf.OnSave(pdffile,@"");
|
|
|
-
|
|
|
-
|
|
|
- }];
|
|
|
+ json[@"json"]=@"json.json";
|
|
|
+ json[@"pdf"]=pdffile.lastPathComponent;
|
|
|
+ json[@"zip"]=zipfile.lastPathComponent;
|
|
|
+ json[@"serial"]=[json[@"zip"] stringByDeletingPathExtension];
|
|
|
|
|
|
- UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
|
|
|
- DebugLog(@"Cancel");
|
|
|
- }];
|
|
|
- [alertControl addAction:actionOne];
|
|
|
|
|
|
- [alertControl addAction:alertthree];
|
|
|
|
|
|
- //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
|
|
|
+ json[@"create_by"]=RASingleton.sharedInstance.user;
|
|
|
|
|
|
|
|
|
- [self presentViewController:alertControl animated:YES completion:nil];
|
|
|
+ json[@"agent_name"]=[self extract_data:@"sales_person"];
|
|
|
+ json[@"doc_number"]=[self extract_data:@"doc_number"];
|
|
|
+ json[@"job_date"]=[self extract_data:@"job_date"];
|
|
|
+ json[@"customer_name"]=[self extract_data:@"customer_name"];
|
|
|
+ json[@"signed_date"]=[self extract_data:@"signed_date"];
|
|
|
|
|
|
- }
|
|
|
-// }];
|
|
|
- // if([[logout_json valueForKey:@"result"] intValue]==2)
|
|
|
- // {
|
|
|
- // self.welcomeLabel.text=@"Not sign in";
|
|
|
- // // [sender setTitle:@"Sign in" forState:UIControlStateNormal];
|
|
|
- // [bbitem setTitle:@"Sign in"];
|
|
|
- //
|
|
|
- // self.buttonHIC.enabled = false;
|
|
|
- // self.buttonSRL.enabled = false;
|
|
|
- // self.coverView.hidden = false;
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // [RAUtils message_alert:[logout_json valueForKey:@"err_msg"] title:@"Sign out" controller:self] ;
|
|
|
- // }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- });
|
|
|
- });
|
|
|
+
|
|
|
+
|
|
|
+ NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
|
|
|
+ NSMutableArray * arr_pending = [[defaults arrayForKey:@"pending_doc"] mutableCopy];
|
|
|
+ if(arr_pending==nil)
|
|
|
+ arr_pending = [[NSMutableArray alloc]init];
|
|
|
+ [arr_pending addObject:json];
|
|
|
+ [defaults setObject:arr_pending forKey:@"pending_doc"];
|
|
|
+ [defaults synchronize];
|
|
|
+
|
|
|
+
|
|
|
+ [weakSelf.navigationController popViewControllerAnimated:false];
|
|
|
+ if(weakSelf.OnSave)
|
|
|
+ weakSelf.OnSave(pdffile,@"");
|
|
|
+
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
|
|
|
+ DebugLog(@"Cancel");
|
|
|
+ }];
|
|
|
+ [alertControl addAction:actionOne];
|
|
|
+
|
|
|
+ [alertControl addAction:alertthree];
|
|
|
+
|
|
|
+ //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
|
|
|
+
|
|
|
+
|
|
|
+ [self presentViewController:alertControl animated:YES completion:nil];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }];
|
|
|
+// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+//
|
|
|
+// NSDictionary* json = nil;
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// json = [RANetwork save_document:zipfile isnew:self.action==PDFEditActionNew];
|
|
|
+//
|
|
|
+// dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+//
|
|
|
+//
|
|
|
+//// [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
+//// [waitalert dismissViewControllerAnimated:YES completion:^{
|
|
|
+// [pop hide];
|
|
|
+// if([[json valueForKey:@"result"] intValue]==2)
|
|
|
+// {
|
|
|
+//
|
|
|
+//
|
|
|
+// [weakSelf.navigationController popViewControllerAnimated:false];
|
|
|
+// if(weakSelf.OnSave)
|
|
|
+// weakSelf.OnSave(pdffile,json[@"subject"]);
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// // [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Save document" controller:self] ;
|
|
|
+//
|
|
|
+// if(self.hide_control)
|
|
|
+// {
|
|
|
+// //提交离线合同
|
|
|
+//// [RAUtils message_alert:@"Can not upload pending documents please try again later." title:@"Save document" controller:self] ;
|
|
|
+//
|
|
|
+// [RAUtils message_box:@"Save document" message:@"Can not upload pending documents please try again later." completion:nil];
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Create Customer" message:@"Can not create new customer on server, do you want to create an offline document?" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+//
|
|
|
+//
|
|
|
+// UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
|
|
|
+// __block NSString* offline_docnumber =[RANetwork offline_docnumber];
|
|
|
+// if(offline_docnumber==nil)
|
|
|
+// {
|
|
|
+//// [RAUtils message_alert:@"Offline document number prefix not found, Please check your user name and make sure you had signed in at least once." title:@"Create Customer" controller:self] ;
|
|
|
+//
|
|
|
+// [RAUtils message_box:@"Create Customer" message:@"Offline document number prefix not found, Please check your user name and make sure you had signed in at least once." completion:nil];
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// [appDelegate SwitchToOffline:RASingleton.sharedInstance.user];
|
|
|
+//
|
|
|
+//
|
|
|
+// NSMutableDictionary * json = [[NSMutableDictionary alloc]init];
|
|
|
+//
|
|
|
+// json[@"json"]=@"json.json";
|
|
|
+// json[@"pdf"]=pdffile.lastPathComponent;
|
|
|
+// json[@"zip"]=zipfile.lastPathComponent;
|
|
|
+// json[@"serial"]=[json[@"zip"] stringByDeletingPathExtension];
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// json[@"create_by"]=RASingleton.sharedInstance.user;
|
|
|
+//
|
|
|
+//
|
|
|
+// json[@"agent_name"]=[self extract_data:@"sales_person"];
|
|
|
+// json[@"doc_number"]=[self extract_data:@"doc_number"];
|
|
|
+// json[@"job_date"]=[self extract_data:@"job_date"];
|
|
|
+// json[@"customer_name"]=[self extract_data:@"customer_name"];
|
|
|
+// json[@"signed_date"]=[self extract_data:@"signed_date"];
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
|
|
|
+// NSMutableArray * arr_pending = [[defaults arrayForKey:@"pending_doc"] mutableCopy];
|
|
|
+// if(arr_pending==nil)
|
|
|
+// arr_pending = [[NSMutableArray alloc]init];
|
|
|
+// [arr_pending addObject:json];
|
|
|
+// [defaults setObject:arr_pending forKey:@"pending_doc"];
|
|
|
+// [defaults synchronize];
|
|
|
+//
|
|
|
+//
|
|
|
+// [weakSelf.navigationController popViewControllerAnimated:false];
|
|
|
+// if(weakSelf.OnSave)
|
|
|
+// weakSelf.OnSave(pdffile,@"");
|
|
|
+//
|
|
|
+//
|
|
|
+// }];
|
|
|
+//
|
|
|
+// UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
|
|
|
+// DebugLog(@"Cancel");
|
|
|
+// }];
|
|
|
+// [alertControl addAction:actionOne];
|
|
|
+//
|
|
|
+// [alertControl addAction:alertthree];
|
|
|
+//
|
|
|
+// //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
|
|
|
+//
|
|
|
+//
|
|
|
+// [self presentViewController:alertControl animated:YES completion:nil];
|
|
|
+//
|
|
|
+// }
|
|
|
+//// }];
|
|
|
+// // if([[logout_json valueForKey:@"result"] intValue]==2)
|
|
|
+// // {
|
|
|
+// // self.welcomeLabel.text=@"Not sign in";
|
|
|
+// // // [sender setTitle:@"Sign in" forState:UIControlStateNormal];
|
|
|
+// // [bbitem setTitle:@"Sign in"];
|
|
|
+// //
|
|
|
+// // self.buttonHIC.enabled = false;
|
|
|
+// // self.buttonSRL.enabled = false;
|
|
|
+// // self.coverView.hidden = false;
|
|
|
+// // }
|
|
|
+// // else
|
|
|
+// // {
|
|
|
+// // [RAUtils message_alert:[logout_json valueForKey:@"err_msg"] title:@"Sign out" controller:self] ;
|
|
|
+// // }
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// });
|
|
|
+// });
|
|
|
// }];
|
|
|
|
|
|
|
|
|
@@ -882,7 +977,7 @@
|
|
|
/*
|
|
|
PageViewController.pdfview = [[PDFView alloc]initWithFrame:self.view.frame atPage:index];
|
|
|
[PageViewController.view addSubview:PageViewController.pdfview];
|
|
|
- NSLog(@"index = %d",index);
|
|
|
+ DebugLog(@"index = %d",index);
|
|
|
|
|
|
|
|
|
*/
|
|
|
@@ -927,7 +1022,9 @@
|
|
|
// titleLabel.textAlignment = NSTextAlignmentRight;
|
|
|
titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
CGSize constraintkey = CGSizeMake(270, 20000.0f);//key label width is 40% cell width;
|
|
|
- CGSize sizetitle = [@"Missing fields:" sizeWithFont:[UIFont systemFontOfSize:20.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
|
|
|
+
|
|
|
+ CGSize sizetitle =[RAUtils sizeWithFont:@"Missing fields:" font:[UIFont systemFontOfSize:20.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
|
|
|
+// CGSize sizetitle = [@"Missing fields:" sizeWithFont:[UIFont systemFontOfSize:20.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
|
|
|
|
|
|
//[titleLabel sizeToFit];
|
|
|
// titleLabel.center.x = demoView.center.x;
|
|
|
@@ -942,7 +1039,8 @@
|
|
|
|
|
|
|
|
|
constraintkey = CGSizeMake(260, 20000.0f);
|
|
|
- CGSize sizemsg = [msg sizeWithFont:[UIFont boldSystemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
|
|
|
+ CGSize sizemsg = [RAUtils sizeWithFont:msg font:[UIFont boldSystemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
|
|
|
+// CGSize sizemsg = [msg sizeWithFont:[UIFont boldSystemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
|
|
|
|
|
|
lineLabel.frame = CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 260, sizemsg.height);
|
|
|
//[lineLabel sizeToFit];
|
|
|
@@ -984,7 +1082,7 @@
|
|
|
{
|
|
|
ret=false;
|
|
|
|
|
|
- NSString* msg=[NSString stringWithFormat:@"%u. Page %d: %@",fields.count+1,i+1,name];
|
|
|
+ NSString* msg=[NSString stringWithFormat:@"%ld. Page %d: %@",fields.count+1,i+1,name];
|
|
|
if(fields.count<15)
|
|
|
[fields addObject:msg];
|
|
|
else
|
|
|
@@ -1092,7 +1190,7 @@
|
|
|
#pragma mark - UIPageViewController delegate methods
|
|
|
- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray<UIViewController *> *)previousViewControllers transitionCompleted:(BOOL)completed
|
|
|
{
|
|
|
- NSLog(@"didFinishAnimating");
|
|
|
+ DebugLog(@"didFinishAnimating");
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1109,7 +1207,8 @@
|
|
|
// self.title = [NSString stringWithFormat:@"%@ [%ld/%ld]", self.docment_id,((PageViewController*)self.pageViewController.viewControllers[0]).pageIndex+1, self.total_page ];
|
|
|
}
|
|
|
- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation {
|
|
|
- if (true||UIInterfaceOrientationIsPortrait(orientation) || ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)) {
|
|
|
+ if (true/*||UIInterfaceOrientationIsPortrait(orientation) || ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)*/)
|
|
|
+ {
|
|
|
// In portrait orientation or on iPhone: Set the spine position to "min" and the page view controller's view controllers array to contain just one view controller. Setting the spine position to 'UIPageViewControllerSpineLocationMid' in landscape orientation sets the doubleSided property to YES, so set it to NO here.
|
|
|
|
|
|
UIViewController *currentViewController = self.pageViewController.viewControllers[0];
|