OrderDetailViewController.m 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859
  1. //
  2. // OrderDetailViewController.m
  3. // RedAnt ERP Mobile
  4. //
  5. // Created by Ray on 8/28/15.
  6. // Copyright (c) 2015 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "OrderDetailViewController.h"
  9. #import "OrderDetailInfoCell.h"
  10. #import "OrderDetailHtmlCell.h"
  11. #import "OrderDetailModelCell.h"
  12. #import "OrderDetailPriceCell.h"
  13. #import "OrderDetailSignatureCell.h"
  14. #import "iSalesNetwork.h"
  15. #import "RTLabel.h"
  16. #import "DetailViewController.h"
  17. #import "PDFViewController.h"
  18. #import "SignatureViewController.h"
  19. #import "MainViewController.h"
  20. #import "AFHTTPSessionManager.h"
  21. #import "DefaultAppearance.h"
  22. #import "DefaultTableHeaderView.h"
  23. #import "OLDataProvider.h"
  24. #define DEF_CELL_HEIGHT 44
  25. #define DEF_TABLE_HEIGHT 44
  26. #define LINE_WIDTH 0
  27. #define CELL_MARGIN 0
  28. #define LABEL_MARGIN 15
  29. @interface OrderDetailViewController ()
  30. @property (nonatomic,assign) BOOL showModels;
  31. @end
  32. @implementation OrderDetailViewController
  33. -(void) reload_container_getdata:(bool) update_data
  34. {
  35. [super reload_container_getdata:update_data];
  36. if(update_data)
  37. [self reload_data];
  38. else
  39. {
  40. [self.detailTable reloadData];
  41. }
  42. }
  43. - (void)onBackClick:(UIButton *)sender {
  44. [self.navigationController popViewControllerAnimated:FALSE];
  45. }
  46. -(void)manually_refresh
  47. {
  48. UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
  49. if(self.isrefreshing)
  50. {
  51. [reF endRefreshing];
  52. return;
  53. }
  54. reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Refreshing"];
  55. if ([self respondsToSelector:@selector(reload_data)])
  56. [self performSelector:@selector(reload_data) withObject:nil afterDelay:1];
  57. // DebugLog(@"refresh!!!!!!!!");
  58. }
  59. -(void) reload_data
  60. {
  61. UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
  62. [reF endRefreshing];
  63. reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
  64. [self loaddata];
  65. }
  66. - (void)viewDidLoad {
  67. [super viewDidLoad];
  68. self.label_net_err.layer.borderColor = [UIColor darkGrayColor].CGColor;
  69. self.label_net_err.layer.borderWidth = 2.0;
  70. self.label_net_err.layer.cornerRadius=15;
  71. self.label_net_err.layer.masksToBounds=true;
  72. self.showModels = YES;
  73. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(refresh_btn_click:)];
  74. // tap.minimumPressDuration = 0.8; //定义按的时间
  75. [self.label_net_err addGestureRecognizer:tap];
  76. UIRefreshControl *ref = [[UIRefreshControl alloc]init];
  77. ref.tag = 200 ;
  78. ref.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
  79. ref.tintColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
  80. // ref.hidden = true;
  81. [ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged];
  82. [self.detailTable addSubview:ref];
  83. NSMutableArray * items = [[NSMutableArray alloc]init];
  84. self.navigationItem.title=@"View Order Detail";
  85. UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  86. style:UIBarButtonItemStylePlain
  87. target:self
  88. action:@selector( onBackClick:)];
  89. // closeButton.tintColor = UIColorFromRGB(0x996633);
  90. self.navigationItem.leftBarButtonItem = closeButton;
  91. self.btnOpen = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  92. style:UIBarButtonItemStylePlain
  93. target:self
  94. action:@selector(onOpenOrderClick:)];//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onOpenOrderClick:)];
  95. // self.btnOpen.tintColor = UIColorFromRGB(0x996633);
  96. self.btnSign = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"signature"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  97. style:UIBarButtonItemStylePlain
  98. target:self
  99. action:@selector(onSignOrderClick:)];//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onOpenOrderClick:)];
  100. // self.btnSign.tintColor = UIColorFromRGB(0x996633);
  101. self.btnCopy =[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"copy"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  102. style:UIBarButtonItemStylePlain
  103. target:self
  104. action:@selector(onCopyOrderClick:)];// [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Commit", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCommitOrderClick:)];
  105. // self.btnCopy.tintColor = UIColorFromRGB(0x996633);
  106. // self.btnSend = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Email", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onSendMailClick:)];
  107. self.btnRelease = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"unlock"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  108. style:UIBarButtonItemStylePlain
  109. target:self
  110. action:@selector(onReleaseOrderClick:)];
  111. // self.btnRelease.tintColor = UIColorFromRGB(0x996633);
  112. self.btnPDF = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"sales_order"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  113. style:UIBarButtonItemStylePlain
  114. target:self
  115. action:@selector(onDownloadOrderClick:)];//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Download", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onDownloadOrderClick:)];
  116. // self.btnPDF.tintColor = UIColorFromRGB(0x996633);
  117. // UIBarButtonItem *item1 = [[UIBarButtonItem alloc] init];
  118. // item1.title = @"item1";
  119. //// item1.image = [UIImage imageNamed:@"rect_setting"];
  120. // UIBarButtonItem *item2 = [[UIBarButtonItem alloc] init];
  121. //// item2.image = [UIImage imageNamed:@"rect_about"];
  122. // item2.title = @"item2";
  123. // UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
  124. // fixedItem.width = 0.0f;
  125. [items addObject:self.btnOpen];
  126. // [items addObject:fixedItem];
  127. // [items addObject:self.btnCommit];
  128. // [items addObject:fixedItem];
  129. [items addObject:self.btnRelease];
  130. // [items addObject:fixedItem];
  131. [items addObject:self.btnPDF];
  132. // [items addObject:fixedItem];
  133. [items addObject:self.btnSign];
  134. // [items addObject:fixedItem];
  135. [items addObject:self.btnCopy];
  136. // [items addObject:item2];
  137. self.navigationItem.rightBarButtonItems=items;
  138. self.btnOpen.enabled =false;
  139. self.btnSign.enabled = false;
  140. self.btnCopy.enabled =false;
  141. self.btnPDF.enabled =false;
  142. self.btnRelease.enabled =false;
  143. // if(self.isTempOrder)
  144. // {
  145. //
  146. //
  147. // self.btnOpen.enabled =true;
  148. //
  149. //
  150. // self.btnCommit.enabled =true;
  151. // }
  152. // else
  153. // {
  154. //
  155. // [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
  156. //
  157. // [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
  158. // self.btnOpen.enabled =false;
  159. // self.btnCommit.enabled =false;
  160. // }
  161. // Do any additional setup after loading the view.
  162. [self loaddata];
  163. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  164. }
  165. - (IBAction)onReleaseOrderClick:(id)sender {
  166. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Are you sure to release order?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  167. //block代码块取代了delegate
  168. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  169. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Release Order"];
  170. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  171. NSDictionary* order_json = [iSalesNetwork release_Order:self.order_code];
  172. dispatch_async(dispatch_get_main_queue(), ^{
  173. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  174. if([[order_json valueForKey:@"result"] intValue]==2)
  175. {
  176. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  177. // appDelegate.order_code = nil;
  178. [appDelegate closeOrder];
  179. // appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
  180. //
  181. // appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
  182. // if(self.selectOrder)
  183. // self.selectOrder();
  184. [self.navigationController popToRootViewControllerAnimated:false];
  185. }
  186. else
  187. {
  188. [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
  189. }
  190. });
  191. });
  192. }];
  193. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  194. NSLog(@"Cancel");
  195. }];
  196. [alertControl addAction:actionOne];
  197. [alertControl addAction:alertthree];
  198. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  199. [self presentViewController:alertControl animated:YES completion:nil];
  200. // get customer info
  201. }
  202. - (void)onDownloadOrderClick:(id)sender {
  203. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  204. PDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
  205. ViewController.mail_content = [self.content_data valueForKey:@"email_content"];
  206. NSString* so = [self.content_data valueForKey:@"so#"];
  207. if(so==nil)
  208. so =@"";
  209. NSString* company = [self.content_data[@"customerInfo"] valueForKey:@"customer_name"];
  210. if(company==nil)
  211. company =@"";
  212. ViewController.save_name =so;
  213. ViewController.hidenavi = false;
  214. if(company==nil)
  215. company=@"";
  216. NSString* customer_email= [self.content_data[@"customerInfo"] valueForKey:@"customer_email"];
  217. // NSMutableArray* arr_subject = [[NSMutableArray alloc]init];
  218. // if(company.length>0)
  219. // [arr_subject addObject:company];
  220. // if(so.length>0)
  221. // [arr_subject addObject:so];
  222. if(company.length==0)
  223. company=@"";
  224. if(so.length==0)
  225. so=@"";
  226. NSMutableArray* send_to = [[NSMutableArray alloc]init];
  227. if(customer_email.length>0)
  228. {
  229. send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
  230. // customer_email compo
  231. // [send_to addObject:customer_email];
  232. }
  233. ViewController.mail_to = send_to;
  234. NSString* subject=[NSString stringWithFormat:@"%@ -- SO# %@ from NEW PACIFIC DIRECT,INC.",company,so];//[arr_subject componentsJoinedByString:@" : "];
  235. ViewController.mail_subject = subject;
  236. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"View Sales Order:" message:nil preferredStyle:UIAlertControllerStyleAlert];
  237. //block代码块取代了delegate
  238. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"With Thumbnails" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  239. if(appDelegate.offline_mode)
  240. {
  241. NSMutableDictionary* params = [@{
  242. @"type" : @"1",
  243. @"order_code" : self.order_code,
  244. } mutableCopy];
  245. [OLDataProvider offline_request_salesorder:params];
  246. }
  247. else
  248. {
  249. NSString* url=[self.content_data valueForKey:@"pdfUrl"];
  250. url= [url stringByAppendingString:@"&has_item_pic=true"];
  251. NSLog(@"pdf url:%@",url);
  252. ViewController.url = url;
  253. [self.navigationController pushViewController:ViewController animated:YES];
  254. }
  255. }];
  256. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Without Thumbnails" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  257. if(appDelegate.offline_mode)
  258. {
  259. NSMutableDictionary* params = [@{
  260. @"type" : @"0",
  261. @"order_code" : self.order_code,
  262. } mutableCopy];
  263. [OLDataProvider offline_request_salesorder:params];
  264. }
  265. else
  266. {
  267. NSString* url=[self.content_data valueForKey:@"pdfUrl"];
  268. NSLog(@"pdf url:%@",url);
  269. ViewController.url = url;
  270. [self.navigationController pushViewController:ViewController animated:YES];
  271. }
  272. }];
  273. UIAlertAction *alertCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {}];
  274. [alertControl addAction:actionOne];
  275. [alertControl addAction:alertthree];
  276. [alertControl addAction:alertCancel];
  277. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  278. [self presentViewController:alertControl animated:YES completion:nil];
  279. // get customer info
  280. //
  281. }
  282. - (void)onCopyOrderClick:(id)sender {
  283. UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Copy confirm", nil) message:NSLocalizedString(@"Are you sure to copy order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
  284. [alert show];
  285. }
  286. //- (void)onCommitOrderClick:(id)sender {
  287. // // get customer info
  288. //
  289. // int model_count = [[self.content_data valueForKey:@"model_count"] intValue];
  290. // if(model_count==0)
  291. // {
  292. //// UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Error." message:@"Can not submit an order without models." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  293. ////
  294. //// [alert show];
  295. //
  296. //
  297. // [RAUtils alert_view:@"Cannot submit an order without models" title:@""];
  298. // }
  299. //
  300. // else
  301. // {
  302. //
  303. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Submit confirm", nil) message:NSLocalizedString(@"Are you sure to submit order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
  304. // [alert show];
  305. //
  306. // }
  307. //
  308. //
  309. //}
  310. -(void) upload_img :(UIImage*) img
  311. {
  312. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  313. if(appDelegate.offline_mode)
  314. {
  315. NSData *data = [OLDataProvider offline_saveBusinesscard:UIImagePNGRepresentation(img)];;
  316. // 再将NSData转为字符串
  317. NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  318. // NSMutableString *str = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
  319. NSLog(@"data string: %@",jsonStr);
  320. NSError *error=nil;
  321. NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error];
  322. if([[json valueForKey:@"result"] intValue]==2)
  323. {
  324. NSString* img_url_down = json[@"img_url_aname"];
  325. NSString* img_url_up = json[@"img_url"];
  326. {
  327. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Signature"];
  328. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  329. NSDictionary* order_json = [iSalesNetwork sign_Order:self.order_code path:img_url_up];
  330. dispatch_async(dispatch_get_main_queue(), ^{
  331. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  332. if([[order_json valueForKey:@"result"] intValue]==2)
  333. {
  334. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  335. // appDelegate.order_code = self.order_code;
  336. // [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
  337. //
  338. //
  339. // appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
  340. //
  341. // appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
  342. // [self.navigationController popViewControllerAnimated:false];
  343. //
  344. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  345. // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  346. // if(self.selectOrder)
  347. // self.selectOrder(self.content_data);
  348. [self.content_data setValue:img_url_down forKey:@"sign_url"];
  349. //self.btnSign.enabled = false;
  350. [self.detailTable reloadData];
  351. [RAUtils message_alert:@"Successful." title:@"Signature" controller:self];
  352. }
  353. else
  354. {
  355. [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Signature" controller:self] ;
  356. }
  357. });
  358. });
  359. }
  360. }
  361. else
  362. {
  363. [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Upload Image" controller:self] ;
  364. }
  365. }
  366. else
  367. {
  368. // UIAlertView * waitalert = [[UIAlertView alloc] initWithTitle:@"wait" message:@"uploading" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
  369. // [waitalert show];
  370. NSData *imageData = UIImagePNGRepresentation(img);
  371. AFHTTPRequestSerializer* serializer=[AFHTTPRequestSerializer serializer] ;
  372. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  373. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  374. if(appDelegate.user!=nil)
  375. [params setValue:appDelegate.user forKey:@"user"];
  376. // if(appDelegate.contact_id!=nil)
  377. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  378. if(appDelegate.password!=nil)
  379. [params setValue:appDelegate.password forKey:@"password"];
  380. NSMutableURLRequest *request = [serializer multipartFormRequestWithMethod:@"POST" URLString:URL_UPLOAD_IMG parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
  381. [formData appendPartWithFileData:imageData name:@"upfile" fileName:@"test.jpg" mimeType:@"image/png"];
  382. } error:nil];
  383. // NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:WEBSERVICE_URL parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
  384. // [formData appendPartWithFileData:imageData name:@"upfile" fileName:@"test" mimeType:@"image/png"];
  385. // } error:nil];
  386. //
  387. AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
  388. //manager.responseSerializer.acceptableContentTypes = [self.operationManager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
  389. //
  390. NSProgress *progress = nil;
  391. NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
  392. // [progress removeObserver:self forKeyPath:@"fractionCompleted"];
  393. if (error) {
  394. NSString* err_msg = [error localizedDescription];
  395. NSLog(@"%@",err_msg);// [self.view updateWithMessage:[NSString stringWithFormat:@"Error : %@!", error.debugDescription]];
  396. NSMutableString *str = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
  397. NSLog(@"data string: %@",str);
  398. [RAUtils message_alert:@"Can not connect to server please try again." title:@"Upload Image" controller:self] ;
  399. } else {
  400. NSLog(@"response ");
  401. NSData *data = [NSJSONSerialization dataWithJSONObject:(NSDictionary*)responseObject options:kNilOptions error:nil];
  402. // 再将NSData转为字符串
  403. NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  404. // NSMutableString *str = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
  405. NSLog(@"data string: %@",jsonStr);
  406. NSDictionary* json = responseObject;
  407. if([[json valueForKey:@"result"] intValue]==2)
  408. {
  409. NSString* img_url_down = json[@"img_url_aname"];
  410. NSString* img_url_up = json[@"img_url"];
  411. {
  412. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Signature"];
  413. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  414. NSDictionary* order_json = [iSalesNetwork sign_Order:self.order_code path:img_url_up];
  415. dispatch_async(dispatch_get_main_queue(), ^{
  416. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  417. if([[order_json valueForKey:@"result"] intValue]==2)
  418. {
  419. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  420. // appDelegate.order_code = self.order_code;
  421. // [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
  422. //
  423. //
  424. // appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
  425. //
  426. // appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
  427. // [self.navigationController popViewControllerAnimated:false];
  428. //
  429. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  430. // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  431. // if(self.selectOrder)
  432. // self.selectOrder(self.content_data);
  433. [self.content_data setValue:img_url_down forKey:@"sign_url"];
  434. //self.btnSign.enabled = false;
  435. [self.detailTable reloadData];
  436. [RAUtils message_alert:@"Successful." title:@"Signature" controller:self];
  437. }
  438. else
  439. {
  440. [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Signature" controller:self] ;
  441. }
  442. });
  443. });
  444. }
  445. }
  446. else
  447. {
  448. [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Upload Image" controller:self] ;
  449. }
  450. }
  451. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  452. }];
  453. [uploadTask resume];
  454. }
  455. }
  456. - (IBAction)onSignOrderClick:(id)sender {
  457. // SignatureViewController * vc;
  458. __block UIImage* signimg=nil;
  459. SignatureViewController * vc =[ self.storyboard instantiateViewControllerWithIdentifier:@"SignatureViewController"];
  460. vc.onReturnImg = ^(UIImage* img)
  461. {
  462. signimg = img;
  463. if(signimg!=nil)
  464. [self upload_img:signimg];
  465. };
  466. // orderinfoVC.url_type = URL_REMOTE;
  467. // orderinfoVC.request_url=URL_CARTDELIVERY;
  468. //
  469. // orderinfoVC.params = params;
  470. //
  471. // orderinfoVC.delegate=self;
  472. //
  473. // if(checked.count==count)
  474. // {
  475. // orderinfoVC.have_tail = true
  476. // }
  477. [self.navigationController pushViewController:vc animated:true];
  478. }
  479. - (IBAction)onOpenOrderClick:(id)sender {
  480. // get customer info
  481. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Are you sure to open order?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  482. //block代码块取代了delegate
  483. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  484. {
  485. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Open Order"];
  486. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  487. NSDictionary* order_json = [iSalesNetwork open_Order:self.order_code];
  488. dispatch_async(dispatch_get_main_queue(), ^{
  489. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  490. if([[order_json valueForKey:@"result"] intValue]==2)
  491. {
  492. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  493. appDelegate.order_code = self.order_code;
  494. appDelegate.order_status = self.order_status;
  495. [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
  496. appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
  497. appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
  498. [self.navigationController popViewControllerAnimated:false];
  499. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  500. [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  501. [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
  502. if(self.selectOrder)
  503. self.selectOrder(self.content_data);
  504. }
  505. else
  506. {
  507. [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
  508. }
  509. });
  510. });
  511. }
  512. }];
  513. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  514. NSLog(@"Cancel");
  515. }];
  516. [alertControl addAction:actionOne];
  517. [alertControl addAction:alertthree];
  518. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  519. [self presentViewController:alertControl animated:YES completion:nil];
  520. }
  521. - (void)didReceiveMemoryWarning {
  522. [super didReceiveMemoryWarning];
  523. // Dispose of any resources that can be recreated.
  524. }
  525. -(void) loaddata
  526. {
  527. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Loading"];
  528. dispatch_async(dispatch_get_main_queue(), ^{
  529. if(self.isrefreshing)
  530. return;
  531. self.detailTable.hidden = true;
  532. self.label_net_err.hidden=true;
  533. self.isrefreshing=true;
  534. self.mum.center = self.view.center;
  535. self.mum.hidden = false;
  536. [self.mum startAnimating];
  537. NSLog(@"reloading...");
  538. self.web_info_height=0;
  539. self.web_moreinfo_height=0;
  540. self.content_data = nil;
  541. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  542. NSDictionary* order_json = [iSalesNetwork request_OrderDetail:self.orderid];
  543. dispatch_async(dispatch_get_main_queue(), ^{
  544. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  545. [self.mum stopAnimating];
  546. if([[order_json valueForKey:@"result"] intValue]==2)
  547. {
  548. self.detailTable.hidden = false;
  549. self.content_data = [order_json mutableCopy];
  550. }
  551. else
  552. if([[order_json valueForKey:@"result"] intValue]==RESULT_NET_ERROR)
  553. {
  554. self.label_net_err.hidden=false;
  555. self.detailTable.hidden=true;
  556. }
  557. else
  558. {
  559. [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Loading Order Detail" controller:self] ;
  560. }
  561. bool web_order =[[self.content_data valueForKey:@"from_online"] boolValue];
  562. if(web_order)
  563. self.btnCopy.enabled = false;
  564. else
  565. self.btnCopy.enabled = true;
  566. int model_count =[[self.content_data valueForKey:@"model_count"] intValue];
  567. if(model_count>0)
  568. self.btnPDF.enabled =true;
  569. // [self.btnPDF setImage:[[UIImage imageNamed:@"download"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  570. NSString* status = [self.content_data valueForKey:@"order_status"];
  571. int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
  572. NSString* lock_user = [self.content_data valueForKey:@"opened_customer"];
  573. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  574. bool offline_edit =[[self.content_data valueForKey:@"offline_edit"] boolValue];
  575. if(status_code==1)//[status isEqualToString:@"Saved Order"])
  576. {
  577. // [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  578. //
  579. // [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  580. if(appDelegate.offline_mode==false||offline_edit)
  581. {
  582. self.btnOpen.enabled =true;
  583. self.btnSign.enabled = true;
  584. }
  585. // if([lock_user isEqualToString:appDelegate.user])
  586. // {
  587. // self.btnCommit.enabled =true;
  588. // }
  589. // else
  590. // self.btnCommit.enabled =false;
  591. }
  592. else
  593. if(status_code==0)//[status isEqualToString:@"Quote Saved"])
  594. {
  595. // [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  596. //
  597. // [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
  598. if(appDelegate.offline_mode==false||offline_edit)
  599. {
  600. self.btnOpen.enabled =true;
  601. self.btnSign.enabled = true;
  602. }
  603. // self.btnCommit.enabled =false;
  604. }
  605. if([lock_user isEqualToString:appDelegate.user])
  606. {
  607. // [self.btnRelease setImage:[[UIImage imageNamed:@"order"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  608. self.btnRelease.enabled =true;
  609. }
  610. else
  611. {
  612. // [self.btnRelease setImage:[[UIImage imageNamed:@"order"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
  613. self.btnRelease.enabled =false;
  614. }
  615. [self.detailTable reloadData];
  616. self.isrefreshing=false;
  617. });
  618. });
  619. });
  620. }
  621. - (void)viewWillAppear:(BOOL)animated
  622. {
  623. // if(appDelegate.can_submit_order)
  624. // {
  625. //
  626. //
  627. // [self.btnCommit setImage:[UIImage imageNamed:@"commit"]];
  628. // self.btnCommit.enabled = true;
  629. // }
  630. // else
  631. // {
  632. // [self.btnCommit setImage:nil];
  633. // self.btnCommit.enabled = false;
  634. // }
  635. //
  636. [[self navigationController] setNavigationBarHidden:NO animated:NO];
  637. }
  638. - (IBAction)imgbtnClicked:(UIButton*)sender {
  639. UITableViewCell* cell =(UITableViewCell*) sender.superview.superview;
  640. NSIndexPath * indexPath = [self.detailTable indexPathForCell:cell];
  641. if(indexPath.section!=1)
  642. return ;
  643. // NSLog(@"shouldchangeedit %d_%d",indexPath.section,indexPath.row);
  644. NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  645. NSString* product_id = [item_json valueForKey:@"product_id"];
  646. DetailViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController" ];
  647. // dvc
  648. dvc.product_id=product_id;
  649. dvc.category_id=nil;
  650. dvc.ispush=true;
  651. [dvc reload];
  652. [self.navigationController pushViewController:dvc animated:true];
  653. }
  654. /*
  655. #pragma mark - Navigation
  656. // In a storyboard-based application, you will often want to do a little preparation before navigation
  657. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  658. // Get the new view controller using [segue destinationViewController].
  659. // Pass the selected object to the new view controller.
  660. }
  661. */
  662. #pragma mark - Table view data source
  663. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
  664. {
  665. // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  666. // if([item_json objectForKey:@"combine"] == nil)
  667. // {
  668. // return 120;
  669. // }
  670. // else
  671. // return 150;
  672. switch (indexPath.section) {
  673. case 0:
  674. {
  675. if(indexPath.row==0)
  676. {
  677. float height= self.web_info_height;
  678. if(height==0)
  679. height=DEF_TABLE_HEIGHT;
  680. return height;
  681. }
  682. else
  683. return 148;
  684. }
  685. break;
  686. case 1:
  687. {
  688. float height= self.web_moreinfo_height;
  689. if(height==0)
  690. height=DEF_TABLE_HEIGHT;
  691. // DebugLog(@"heightForRowAtIndexPath...............webview,hight = %f section=%ld",height,indexPath.section);
  692. //wait(1000);
  693. return height;
  694. }
  695. break;
  696. case 2:
  697. {
  698. NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  699. NSString* notes =[item_json valueForKey:@"note"];
  700. if(notes.length>0)
  701. {
  702. return 190;
  703. }
  704. else
  705. return 162;
  706. }
  707. case 3:
  708. return 44;
  709. default:
  710. break;
  711. }
  712. return 44;
  713. }
  714. //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  715. //{
  716. // return 0;
  717. //}
  718. //- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  719. //{
  720. // return 0;
  721. //}
  722. //- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  723. //{
  724. // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  725. // return myView;
  726. //
  727. //}
  728. //- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  729. //{
  730. // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  731. //// myView.backgroundColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
  732. //// UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 90, 22)];
  733. //// titleLabel.textColor=[UIColor whiteColor];
  734. //// titleLabel.backgroundColor = [UIColor clearColor];
  735. //// if(section==0)
  736. //// titleLabel.text=NSLocalizedString(@"display_items", nil);
  737. //// else
  738. //// titleLabel.text=NSLocalizedString(@"hide_items", nil);
  739. //// [titleLabel sizeToFit];
  740. //// [myView addSubview:titleLabel];
  741. ////
  742. // return myView;
  743. //}
  744. //
  745. - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  746. {
  747. NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  748. if(value==nil)
  749. value=@"";
  750. unsigned long color = strtoul([value UTF8String],0,16);
  751. DefaultTableHeaderView* myView = [[DefaultTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  752. // myView.backgroundColor = UIColorFromRGB(0x996633);;
  753. myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath;
  754. // myView.layer.masksToBounds = false;
  755. //添加四个边阴影
  756. myView.layer.shadowColor = [UIColor blackColor].CGColor;
  757. myView.layer.shadowOffset = CGSizeMake(0, 0);
  758. myView.layer.shadowOpacity = 0.5;
  759. myView.layer.shadowRadius = 2.0;
  760. NSString*labeltitle = nil;
  761. switch (section) {
  762. case 0:
  763. labeltitle= @"Order Info";
  764. break;
  765. case 1:
  766. {
  767. labeltitle= @"More Info";
  768. NSString* btntitle=nil ;
  769. if(self.showMore)
  770. {
  771. btntitle=@"Hide";
  772. // [section setValue:@"false" forKey:@"hide"];
  773. // [sender setTitle:@"Show" forState:UIControlStateNormal];
  774. }
  775. else{
  776. btntitle=@"Show";
  777. }
  778. UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
  779. btn.tag=section;
  780. [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
  781. [btn setTitle:btntitle forState:UIControlStateNormal];
  782. [myView addSubview:btn];
  783. }
  784. break;
  785. case 2:{
  786. labeltitle= @"Models";
  787. NSString* btntitle=nil ;
  788. if(self.showModels)
  789. {
  790. btntitle=@"Hide";
  791. }
  792. else{
  793. btntitle=@"Show";
  794. }
  795. UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
  796. btn.tag=section;
  797. [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
  798. [btn setTitle:btntitle forState:UIControlStateNormal];
  799. [myView addSubview:btn];
  800. }
  801. break;
  802. case 3:
  803. labeltitle= @"Price Info";
  804. default:
  805. break;
  806. }
  807. UILabel *titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 5.5, 200, 20)];
  808. titlelabel.textColor=UIColorFromRGB(color);;
  809. titlelabel.backgroundColor = [UIColor clearColor];
  810. titlelabel.text=NSLocalizedString(labeltitle, nil);
  811. [titlelabel sizeToFit];
  812. [myView addSubview:titlelabel];
  813. //
  814. return myView;
  815. }
  816. #pragma mark - hide section button clicked
  817. - (void)HideSction:(UIButton *)sender {
  818. /*
  819. NSMutableDictionary* section= [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",sender.tag]] mutableCopy];
  820. bool hide = [[section valueForKey:@"hide"]boolValue];
  821. if(hide)
  822. {
  823. [section setValue:@"false" forKey:@"hide"];
  824. [sender setTitle:@"Show" forState:UIControlStateNormal];
  825. }
  826. else{
  827. [section setValue:@"true" forKey:@"hide"];
  828. [sender setTitle:@"Hide" forState:UIControlStateNormal];
  829. }
  830. [self.content_data_download setObject:section forKey:[NSString stringWithFormat:@"section_%d",sender.tag]];
  831. self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
  832. */
  833. switch (sender.tag) {
  834. case 0:{
  835. }
  836. break;
  837. case 1:{
  838. self.showMore=!self.showMore;
  839. NSRange range = NSMakeRange(1, 1);
  840. NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
  841. [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
  842. }
  843. break;
  844. case 2:{
  845. self.showModels = !self.showModels;
  846. NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndex:2];
  847. [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
  848. }
  849. break;
  850. default:
  851. break;
  852. }
  853. }
  854. - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  855. switch (section) {
  856. case 0:
  857. return @"Order Info";
  858. break;
  859. case 1:
  860. return @"More Info";
  861. break;
  862. case 2:
  863. return @"Models";
  864. case 3:
  865. return @"Price Info";
  866. default:
  867. break;
  868. }
  869. return nil;
  870. }
  871. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  872. {
  873. if(self.content_data==nil)
  874. return 0;
  875. return 4;
  876. }
  877. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  878. {
  879. return 33;
  880. }
  881. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  882. {
  883. // NSDictionary * item_json = [self.content_data objectForKey:@"items"];
  884. if(section==0)
  885. return 2;
  886. if(section==1)
  887. {
  888. if(self.showMore)
  889. return 1;
  890. else
  891. return 0;
  892. }
  893. if(section==2)
  894. {
  895. if (self.showModels) {
  896. int count =[[self.content_data valueForKey:@"model_count"] intValue];
  897. return count;
  898. } else {
  899. return 0;
  900. }
  901. }
  902. if(section==3)
  903. return 5;
  904. return 0;
  905. }
  906. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  907. {
  908. UIApplication * app = [UIApplication sharedApplication];
  909. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  910. switch(indexPath.section)
  911. {
  912. case 0:
  913. {
  914. if(indexPath.row==0)
  915. {
  916. NSString *CellIdentifier = @"OrderDetailHtmlCell";
  917. OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  918. cell.webview.tag = indexPath.section;
  919. cell.webview.delegate = self;
  920. // cell.webView.scrollView.contentSize.height = 0;
  921. cell.webview.scrollView.bounces=NO;
  922. cell.webview.scrollView.directionalLockEnabled = true;
  923. CGSize size= cell.webview.scrollView.contentSize;
  924. size.height=10;
  925. cell.webview.scrollView.contentSize=size;
  926. [cell.webview loadHTMLString:[self.content_data valueForKey:@"order_info"] baseURL:nil];
  927. cell.backgroundColor = [UIColor whiteColor];
  928. return cell;
  929. }
  930. else
  931. {
  932. NSString *CellIdentifier = @"OrderDetailSignatureCell";
  933. OrderDetailSignatureCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  934. NSString* img_url = [self.content_data valueForKey:@"sign_url"];
  935. NSString* file_name=[img_url lastPathComponent];
  936. NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
  937. if(img_data!=nil)
  938. {
  939. UIImage * img =[UIImage imageWithData:img_data];
  940. cell.sign_img.image=img ;
  941. }
  942. else
  943. {
  944. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  945. NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  946. dispatch_async(dispatch_get_main_queue(), ^{
  947. if(downloadimg_data!=nil)
  948. {
  949. [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
  950. UIImage * img =[UIImage imageWithData:downloadimg_data];
  951. cell.sign_img.image=img ;
  952. }
  953. else
  954. cell.sign_img.image=[UIImage imageNamed:@"taptosign_s"];
  955. });
  956. });
  957. }
  958. cell.backgroundColor = [UIColor whiteColor];
  959. return cell;
  960. }
  961. }
  962. break;
  963. case 1:
  964. {
  965. NSString *CellIdentifier = @"OrderDetailHtmlCell";
  966. OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  967. cell.webview.tag = indexPath.section;
  968. cell.webview.delegate = self;
  969. // cell.webView.scrollView.contentSize.height = 0;
  970. cell.webview.scrollView.bounces=NO;
  971. cell.webview.scrollView.directionalLockEnabled = true;
  972. CGSize size= cell.webview.scrollView.contentSize;
  973. size.height=10;
  974. cell.webview.scrollView.contentSize=size;
  975. [cell.webview loadHTMLString:[self.content_data valueForKey:@"more_order_info"] baseURL:nil];
  976. cell.backgroundColor = [UIColor whiteColor];
  977. return cell;
  978. // NSString *CellIdentifier = @"OrderDetailInfoCell";
  979. // OrderDetailInfoCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  980. //
  981. // cell.infoLabel.text =[self.content_data valueForKey:@"more_order_info"];
  982. //
  983. //
  984. //
  985. //// float width = tableView.frame.size.width;
  986. //// width-=CELL_MARGIN*2;
  987. //// CGSize constraintkey = CGSizeMake(width-2*LABEL_MARGIN, 10.0f);//key label width is 40% cell width;
  988. ////
  989. //// NSString* key =[self.content_data valueForKey:@"order_info"];
  990. ////
  991. ////
  992. ////
  993. //// CGRect frame;
  994. //// frame.size = constraintkey;
  995. //// frame.origin.x=0;
  996. //// frame.origin.y=0;
  997. ////
  998. //// RTLabel* rtlabel = [[RTLabel alloc] initWithFrame:frame];
  999. ////
  1000. //// [rtlabel setText: key];
  1001. //// CGSize optimumSize = [rtlabel optimumSize];
  1002. ////
  1003. //// float height = optimumSize.height;
  1004. //// height = MAX(height+LINE_WIDTH+2*LABEL_MARGIN, DEF_CELL_HEIGHT);
  1005. ////
  1006. ////
  1007. //// frame.origin.x=LABEL_MARGIN;
  1008. //// frame.size=CGSizeMake(width, height);
  1009. ////
  1010. //// cell.infoLabel.frame = frame;
  1011. //
  1012. //
  1013. //
  1014. //
  1015. // cell.backgroundColor = [UIColor whiteColor];
  1016. // return cell;
  1017. }
  1018. break;
  1019. case 2:
  1020. {
  1021. NSString *CellIdentifier = @"OrderDetailModelCell";
  1022. OrderDetailModelCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  1023. NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  1024. int count = [[item_json valueForKey:@"count"] intValue];
  1025. NSDictionary * combine_json =[item_json objectForKey:@"combine"];
  1026. cell.bundle_item=combine_json;
  1027. double dprice=0.0;
  1028. if(cell.bundle_item!=nil)
  1029. {
  1030. int citem=0;
  1031. int bcount=[[cell.bundle_item valueForKey:@"count"] intValue];
  1032. for(int bc=0;bc<bcount;bc++)
  1033. {
  1034. NSDictionary * bitem = [cell.bundle_item objectForKey:[NSString stringWithFormat:@"item_%d",bc]];
  1035. int modulus= [[bitem valueForKey:@"modulus"] intValue];
  1036. citem+= modulus;
  1037. double uprice= [[bitem valueForKey:@"unit_price"]doubleValue];
  1038. dprice+= uprice*modulus;
  1039. }
  1040. if(citem==1)
  1041. [ cell.buttonBundle setTitle:[NSString stringWithFormat: @"%d bundle item with price of $ %.2f",citem,dprice ]forState:UIControlStateNormal];
  1042. else
  1043. [ cell.buttonBundle setTitle:[NSString stringWithFormat: @"%d bundle items with price of $ %.2f",citem,dprice ]forState:UIControlStateNormal];
  1044. cell.buttonBundle.hidden = NO;
  1045. }
  1046. else
  1047. {
  1048. cell.buttonBundle.hidden = YES;
  1049. }
  1050. NSString* img_url = [item_json valueForKey:@"img"];
  1051. NSString* description = [item_json valueForKey:@"Item Number"];
  1052. // NSString* description = [item_json valueForKey:@"Item Number"];
  1053. NSString* unitprice = [item_json valueForKey:@"The unit price"];
  1054. NSString* origin_price = [item_json valueForKey:@"origin_price"];
  1055. NSString* subtotal = [item_json valueForKey:@"Subtotal"];
  1056. NSString* qty = [item_json valueForKey:@"QTY"];
  1057. NSString* status = [item_json valueForKey:@"order_item_status"];
  1058. NSString* notes = [item_json valueForKey:@"note"];
  1059. if(notes.length>0)
  1060. {
  1061. cell.noteLabel.text = [@"Note: " stringByAppendingString:[notes stringByReplacingOccurrencesOfString:@"\n" withString:@" "]];
  1062. }
  1063. else
  1064. cell.noteLabel.text = nil;
  1065. if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
  1066. {
  1067. }
  1068. else
  1069. {
  1070. unitprice=nil;
  1071. origin_price=nil;
  1072. subtotal=nil;
  1073. }
  1074. float duprice = [unitprice floatValue];
  1075. float dsubtotal = (duprice+dprice)*[qty intValue];
  1076. cell.descriptionLabel.text=description;
  1077. if(dprice>0)
  1078. cell.unitpriceLabel.text = [NSString stringWithFormat:@"%.2f+%.2f",duprice,dprice];//unitprice;
  1079. else
  1080. cell.unitpriceLabel.text = [NSString stringWithFormat:@"%.2f",duprice];//unitprice;
  1081. cell.subtotalLabel.text = [NSString stringWithFormat:@"%.2f",dsubtotal];//subtotal;
  1082. cell.qtyLabel.text = qty;
  1083. cell.statusLabel.text = status;
  1084. cell.labelOldPrice.text = origin_price;
  1085. double discount =[[item_json valueForKey:@"discount"] doubleValue];
  1086. NSString* discountstr=[NSString stringWithFormat:@"%@%% off", [RAUtils FloatFormat:discount]];
  1087. cell.labelDiscount.text = discountstr;
  1088. bool isfree = [[item_json valueForKey:@"is_free"]boolValue];
  1089. if(isfree)
  1090. {
  1091. cell.labelOldPrice.hidden = false;
  1092. cell.labelOldPrice.textColor = [UIColor redColor];
  1093. cell.labelOldPrice.text=@"Free";
  1094. cell.labelOldPrice.hideline = true;
  1095. cell.labelDiscount.hidden = true;
  1096. }
  1097. else
  1098. {
  1099. cell.labelOldPrice.textColor = [UIColor blackColor];
  1100. cell.labelOldPrice.hideline = false;
  1101. if(discount==0)
  1102. {
  1103. cell.labelOldPrice.hidden = true;
  1104. cell.labelDiscount.hidden = true;
  1105. }
  1106. else
  1107. {
  1108. cell.labelOldPrice.hidden = false;
  1109. cell.labelDiscount.hidden = false;
  1110. }
  1111. }
  1112. if (![cell.imageName isEqualToString:img_url]) {
  1113. cell.imageName = img_url;
  1114. [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
  1115. NSString* file_name=[img_url lastPathComponent];
  1116. NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
  1117. if(img_data!=nil)
  1118. {
  1119. UIImage * img =[UIImage imageWithData:img_data];
  1120. [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
  1121. }
  1122. else
  1123. {
  1124. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1125. NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  1126. dispatch_async(dispatch_get_main_queue(), ^{
  1127. if(downloadimg_data!=nil)
  1128. {
  1129. [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
  1130. UIImage * img =[UIImage imageWithData:downloadimg_data];
  1131. [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
  1132. }
  1133. else
  1134. [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
  1135. });
  1136. });
  1137. }
  1138. }
  1139. cell.backgroundColor = [UIColor whiteColor];
  1140. return cell;
  1141. }
  1142. break;
  1143. case 3:
  1144. {
  1145. NSString *CellIdentifier = @"OrderDetailPriceCell";
  1146. OrderDetailPriceCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  1147. switch (indexPath.row) {
  1148. case 0:
  1149. {
  1150. cell.chargeLabel.text =@"Payments/Credits:";
  1151. NSString* price=[self.content_data valueForKey:@"Payments/Credits"];
  1152. if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
  1153. {
  1154. }
  1155. else
  1156. {
  1157. price=nil;
  1158. }
  1159. cell.priceLabel.text =price;
  1160. break;
  1161. }
  1162. case 1:
  1163. cell.chargeLabel.text = @"Shipping:";
  1164. cell.priceLabel.text =[self.content_data valueForKey:@"Shipping"];
  1165. break;
  1166. case 2:
  1167. cell.chargeLabel.text = @"Liftgate Fee(No loading dock):";
  1168. cell.priceLabel.text =[self.content_data valueForKey:@"Liftgate Fee(No loading dock)"];
  1169. break;
  1170. case 3:
  1171. cell.chargeLabel.text = @"Handling Fee:";
  1172. cell.priceLabel.text =[self.content_data valueForKey:@"Handling Fee"];
  1173. break;
  1174. case 4:
  1175. {
  1176. NSString* price=[self.content_data valueForKey:@"Total"];
  1177. if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
  1178. {
  1179. }
  1180. else
  1181. {
  1182. price=nil;
  1183. }
  1184. cell.chargeLabel.text = @"Total:";
  1185. cell.priceLabel.text =price;
  1186. break;
  1187. }
  1188. default:
  1189. break;
  1190. }
  1191. cell.backgroundColor = [UIColor whiteColor];
  1192. return cell;
  1193. }
  1194. }
  1195. return nil;
  1196. // if(tableView==self.itemListTable)
  1197. // {
  1198. // NSString *CellIdentifier = @"CartItemCell";
  1199. // ModelItemCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  1200. // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  1201. // NSDictionary * combine_json =[item_json objectForKey:@"combine"];
  1202. //
  1203. // cell.bundle_item=combine_json;
  1204. // NSString* img_url = [item_json valueForKey:@"img_url"];
  1205. // NSString* description = [item_json valueForKey:@"description"];
  1206. // // NSString* identifier = [item_json valueForKey:@"identifier"];
  1207. // // NSString* attribute = [item_json valueForKey:@"attribute"];
  1208. // NSString* currency = [item_json valueForKey:@"currency"];
  1209. // int count =[[item_json valueForKey:@"count"] intValue];
  1210. //
  1211. // int stockUom =[[item_json valueForKey:@"stockUom"] intValue];
  1212. //
  1213. // double totalprice =[[item_json valueForKey:@"subtotal_price"] doubleValue];
  1214. //
  1215. // double unitprice=[[item_json valueForKey:@"unit_price"] doubleValue];
  1216. // cell.unit_price = unitprice;
  1217. // // cell.labelAttribute.text = attribute;
  1218. // // cell.labelCurrency.text = currency;
  1219. // cell.labelDescription.text = description;
  1220. // // cell.labelIdentifier.text = identifier;
  1221. // cell.labelPrice.text = [NSString stringWithFormat:@"%.2f",totalprice];
  1222. //
  1223. // cell.labelUnitPrice.text = [NSString stringWithFormat:@"%.2f",unitprice];
  1224. //
  1225. //
  1226. //
  1227. // NSString* cart_item_id= [item_json valueForKey:@"cart_item_id"];
  1228. // cell.cart_id = cart_item_id;
  1229. // [cell init_Stepper:stockUom max:9999 min:stockUom value:count];
  1230. //
  1231. //
  1232. //
  1233. // [cell set_Count:count];
  1234. //
  1235. // NSString* file_name=[img_url lastPathComponent];
  1236. // NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
  1237. // if(img_data!=nil)
  1238. // {
  1239. //
  1240. // UIImage * img =[UIImage imageWithData:img_data];
  1241. // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
  1242. // }
  1243. // else
  1244. // {
  1245. //
  1246. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1247. //
  1248. // NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  1249. //
  1250. // dispatch_async(dispatch_get_main_queue(), ^{
  1251. //
  1252. //
  1253. //
  1254. // if(downloadimg_data!=nil)
  1255. // {
  1256. // [iSalesDB cache_img:downloadimg_data :file_name ];
  1257. //
  1258. // UIImage * img =[UIImage imageWithData:downloadimg_data];
  1259. // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
  1260. // }
  1261. //
  1262. // });
  1263. // });
  1264. //
  1265. //
  1266. // }
  1267. // return cell;
  1268. // }
  1269. // else
  1270. // {
  1271. // NSString *CellIdentifier = @"OrderInfoListItem";
  1272. // UITableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  1273. // return cell;
  1274. // }
  1275. }
  1276. #pragma mark - UIAlertViewDelegate
  1277. // Called when a button is clicked. The view will be automatically dismissed after this call returns
  1278. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  1279. {
  1280. if(buttonIndex!=alertView.cancelButtonIndex)
  1281. {
  1282. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Copy Order"];
  1283. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1284. NSDictionary* order_json = [iSalesNetwork copy_Order:self.order_code];
  1285. dispatch_async(dispatch_get_main_queue(), ^{
  1286. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1287. if([[order_json valueForKey:@"result"] intValue]==2)
  1288. {
  1289. // NSString* orderCode = [order_json valueForKey:@"orderCode"];
  1290. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1291. // if([appDelegate.order_code isEqualToString: self.order_code])
  1292. // {
  1293. // [appDelegate closeOrder];
  1294. //// appDelegate.order_code= nil;
  1295. // [appDelegate SetSo:nil];
  1296. //
  1297. //
  1298. // }
  1299. UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Copy successful." message:[NSString stringWithFormat:@"New order SO#: %@",[order_json valueForKey:@"so_id"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  1300. [alert show];
  1301. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1302. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  1303. [self.navigationController popViewControllerAnimated:false];
  1304. }
  1305. else
  1306. {
  1307. [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Cpoy Order" controller:self] ;
  1308. }
  1309. });
  1310. });
  1311. }
  1312. }
  1313. #pragma mark - web view delegate
  1314. //- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
  1315. //{
  1316. // if(navigationType != UIWebViewNavigationTypeLinkClicked)
  1317. // return true;
  1318. // // NSString *currentURL =[webView.request.URL lastPathComponent];// [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
  1319. //
  1320. // NSString* str = request.URL.absoluteString;
  1321. // if([str isEqualToString:@"about:blank"])
  1322. // return true;
  1323. // WebViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"WebViewController"];
  1324. // ViewController.url = str;
  1325. // // ViewController. = self.function_name;
  1326. // // ViewController.behavior =BEHAVIOR_SEARCH;
  1327. //
  1328. // [self.navigationController pushViewController:ViewController animated:YES];
  1329. // DebugLog(@"shouldStartLoadWithRequest");
  1330. // return false;
  1331. //}
  1332. - (void)webViewDidFinishLoad:(UIWebView *)webView
  1333. {
  1334. DebugLog(@"webViewDidFinishLoad @@@@@@@@@@@@@@@@@ entry");
  1335. UITableViewCell *cell = (UITableViewCell *)[[webView superview] superview];
  1336. NSIndexPath *indexPath = [self.detailTable indexPathForCell:cell];
  1337. if(indexPath==nil)
  1338. {//for ios7
  1339. cell = (UITableViewCell *) webView.superview.superview.superview;
  1340. indexPath = [self.detailTable indexPathForCell:cell];
  1341. }
  1342. float height= 0;
  1343. if(indexPath.section==0)
  1344. height=self.web_info_height;
  1345. else
  1346. height = self.web_moreinfo_height;
  1347. if(height>0)
  1348. return;
  1349. // UIScrollView *scrollerView = [webView.subviews objectAtIndex:0];
  1350. // CGSize size= webView.scrollView.contentSize;
  1351. // CGSize fittingSize = [webView sizeThatFits:CGSizeZero];
  1352. CGRect frame = webView.frame;
  1353. NSString *fitHeight = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight;"];
  1354. frame.size.height = [fitHeight floatValue];
  1355. //webView.frame = frame;
  1356. // DebugLog(@"webViewDidFinishLoad ^^^^^^^^^^^^^^^^^Saveheight height=%f section=%ld",webView.scrollView.contentSize.height,indexPath.section);
  1357. if(indexPath.section==0)
  1358. self.web_info_height=frame.size.height;
  1359. else
  1360. self.web_moreinfo_height = frame.size.height;
  1361. // [self.content.webviewHeight setObject:[NSString stringWithFormat:@"%f",frame.size.height/*webView.scrollView.contentSize.height*/] forKey:[NSString stringWithFormat:@"%ld",(long)indexPath.section]];
  1362. DebugLog(@"webViewDidFinishLoad ^^^^^^^^^^^^^^^^^reloadRowsAtIndexPaths");
  1363. // [self.table beginUpdates];
  1364. [self.detailTable reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
  1365. // [self.table endUpdates];
  1366. // [self.webviewoprationQueue addOperationWithBlock:^{
  1367. // }];
  1368. // [self.table endUpdates];
  1369. // }
  1370. }
  1371. @end