|
|
@@ -548,196 +548,196 @@
|
|
|
// [self.controlTemplate writeToFile:path atomically:NO];
|
|
|
|
|
|
return;
|
|
|
-
|
|
|
- [self EndEditing];
|
|
|
- if(self.no_save)
|
|
|
- {
|
|
|
- [RAUtils message_alert:@"Can not save pending document under offline mode." title:@"Save document" controller:self] ;
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if([self verifyData]==false)
|
|
|
- return;
|
|
|
-
|
|
|
- NSString* pdffile = nil;
|
|
|
- NSString* zipfile = nil;
|
|
|
- NSString* jsonfile = nil;
|
|
|
- // for(int l=0;l<1;l++)
|
|
|
- {
|
|
|
-
|
|
|
- if(self.hide_control)
|
|
|
- {
|
|
|
- pdffile = self.pdfPath;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- pdffile = [PDFUtils SavePDF:self.controlTemplate source:self.document window_rect:CGRectMake(0, 0, 768, 960) name:self.docment_id isnew:self.action==PDFEditActionNew];
|
|
|
- }
|
|
|
-
|
|
|
- zipfile=[ACNetwork prepareUploadFile:pdffile json:self.controlTemplate];
|
|
|
-
|
|
|
- //jsonfile = [ACNetwork getjsonPath:zip];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- __weak typeof(self) weakSelf = self;
|
|
|
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
- if(appDelegate.accessMode == AppAccessModeOffline)
|
|
|
- {
|
|
|
-
|
|
|
- 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"]=appDelegate.user;
|
|
|
-
|
|
|
-
|
|
|
- json[@"agent_name"]=[self extract_data:@"agent_name"];
|
|
|
- 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,@"");
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Saving"];
|
|
|
-
|
|
|
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
-
|
|
|
- NSDictionary* json = nil;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- json = [ACNetwork save_document:zipfile isnew:self.action==PDFEditActionNew];
|
|
|
-
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
-
|
|
|
-
|
|
|
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
- // 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] ;
|
|
|
- // }
|
|
|
-
|
|
|
- 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] ;
|
|
|
- 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 =[ACNetwork 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] ;
|
|
|
- return;
|
|
|
- }
|
|
|
- [appDelegate SwitchToOffline:appDelegate.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"]=appDelegate.user;
|
|
|
-
|
|
|
-
|
|
|
- json[@"agent_name"]=[self extract_data:@"agent_name"];
|
|
|
- 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];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
+//
|
|
|
+// [self EndEditing];
|
|
|
+// if(self.no_save)
|
|
|
+// {
|
|
|
+// [RAUtils message_alert:@"Can not save pending document under offline mode." title:@"Save document" controller:self] ;
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// if([self verifyData]==false)
|
|
|
+// return;
|
|
|
+//
|
|
|
+// NSString* pdffile = nil;
|
|
|
+// NSString* zipfile = nil;
|
|
|
+// NSString* jsonfile = nil;
|
|
|
+// // for(int l=0;l<1;l++)
|
|
|
+// {
|
|
|
+//
|
|
|
+// if(self.hide_control)
|
|
|
+// {
|
|
|
+// pdffile = self.pdfPath;
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// pdffile = [PDFUtils SavePDF:self.controlTemplate source:self.document window_rect:CGRectMake(0, 0, 768, 960) name:self.docment_id isnew:self.action==PDFEditActionNew];
|
|
|
+// }
|
|
|
+//
|
|
|
+// zipfile=[ACNetwork prepareUploadFile:pdffile json:self.controlTemplate];
|
|
|
+//
|
|
|
+// //jsonfile = [ACNetwork getjsonPath:zip];
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// __weak typeof(self) weakSelf = self;
|
|
|
+// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+// if(appDelegate.accessMode == AppAccessModeOffline)
|
|
|
+// {
|
|
|
+//
|
|
|
+// 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"]=appDelegate.user;
|
|
|
+//
|
|
|
+//
|
|
|
+// json[@"agent_name"]=[self extract_data:@"agent_name"];
|
|
|
+// 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,@"");
|
|
|
+//
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Saving"];
|
|
|
+//
|
|
|
+// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+//
|
|
|
+// NSDictionary* json = nil;
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// json = [ACNetwork save_document:zipfile isnew:self.action==PDFEditActionNew md5:md5];
|
|
|
+//
|
|
|
+// dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+//
|
|
|
+//
|
|
|
+// [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
+// // 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] ;
|
|
|
+// // }
|
|
|
+//
|
|
|
+// 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] ;
|
|
|
+// 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 =[ACNetwork 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] ;
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// [appDelegate SwitchToOffline:appDelegate.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"]=appDelegate.user;
|
|
|
+//
|
|
|
+//
|
|
|
+// json[@"agent_name"]=[self extract_data:@"agent_name"];
|
|
|
+// 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];
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// });
|
|
|
+// });
|
|
|
+// }
|
|
|
|
|
|
|
|
|
|