OrderDetailViewController.m 71 KB

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