OrderDetailViewController.m 158 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004
  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 "RANetwork.h"
  15. #import "RTLabel.h"
  16. #import "DetailViewController.h"
  17. #import "RAPDFViewController.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. #import "OrderDetailPickInfoCell.h"
  25. #define DEF_CELL_HEIGHT 44
  26. #define DEF_TABLE_HEIGHT 44
  27. #define LINE_WIDTH 0
  28. #define CELL_MARGIN 0
  29. #define LABEL_MARGIN 15
  30. @interface OrderDetailViewController ()
  31. @property (nonatomic,assign) BOOL showModels;
  32. @end
  33. @implementation OrderDetailViewController
  34. - (void)saleOrderWithPath:(NSString *)path {
  35. RAPDFViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
  36. ViewController.url = path;
  37. ViewController.canSave = false;
  38. ViewController.isLocalfile=YES;
  39. NSString* subject;
  40. subject =[NSString stringWithFormat:@"Sales Order %@",self.order_code];
  41. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  42. NSString* customer_email= [appDelegate.customerInfo valueForKey:@"customer_email"];
  43. NSMutableArray* send_to = [[NSMutableArray alloc]init];
  44. if(customer_email.length>0)
  45. {
  46. send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
  47. }
  48. ViewController.mail_to = send_to;
  49. ViewController.filename = [NSString stringWithFormat:@"%@.pdf",self.order_code];
  50. ViewController.mail_subject = subject;
  51. ViewController.hidenavi = false;
  52. [self.navigationController pushViewController:ViewController animated:YES];
  53. }
  54. #ifndef RA_NOTIFICATION
  55. -(void) reload_container_getdata:(bool) update_data
  56. {
  57. [super reload_container_getdata:update_data];
  58. if(update_data)
  59. [self reload_data];
  60. else
  61. {
  62. [self.detailTable reloadData];
  63. }
  64. }
  65. #endif
  66. - (void)onBackClick:(UIButton *)sender {
  67. [self.navigationController popViewControllerAnimated:FALSE];
  68. }
  69. -(void)manually_refresh
  70. {
  71. UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
  72. if(self.isrefreshing)
  73. {
  74. [reF endRefreshing];
  75. return;
  76. }
  77. reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Refreshing"];
  78. if ([self respondsToSelector:@selector(reload_data)])
  79. [self performSelector:@selector(reload_data) withObject:nil afterDelay:1];
  80. // DebugLog(@"refresh!!!!!!!!");
  81. }
  82. - (void)viewDidLoad {
  83. [super viewDidLoad];
  84. self.label_net_err.layer.borderColor = [UIColor darkGrayColor].CGColor;
  85. self.label_net_err.layer.borderWidth = 2.0;
  86. self.label_net_err.layer.cornerRadius=15;
  87. self.label_net_err.layer.masksToBounds=true;
  88. self.showModels = YES;
  89. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(refresh_btn_click:)];
  90. // tap.minimumPressDuration = 0.8; //定义按的时间
  91. [self.label_net_err addGestureRecognizer:tap];
  92. UIRefreshControl *ref = [[UIRefreshControl alloc]init];
  93. ref.tag = 200 ;
  94. ref.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
  95. ref.tintColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
  96. // ref.hidden = true;
  97. [ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged];
  98. [self.detailTable addSubview:ref];
  99. NSMutableArray * items = [[NSMutableArray alloc]init];
  100. self.navigationItem.title=@"View Order Detail";
  101. UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  102. style:UIBarButtonItemStylePlain
  103. target:self
  104. action:@selector( onBackClick:)];
  105. // closeButton.tintColor = UIColorFromRGB(0x996633);
  106. self.navigationItem.leftBarButtonItem = closeButton;
  107. self.btnOpen = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  108. style:UIBarButtonItemStylePlain
  109. target:self
  110. action:@selector(onOpenOrderClick:)];//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onOpenOrderClick:)];
  111. // self.btnOpen.tintColor = UIColorFromRGB(0x996633);
  112. self.btnSign = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"signature"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  113. style:UIBarButtonItemStylePlain
  114. target:self
  115. action:@selector(onSignOrderClick:)];//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onOpenOrderClick:)];
  116. // self.btnSign.tintColor = UIColorFromRGB(0x996633);
  117. #if defined(BUILD_NPD) || defined(BUILD_USAI)
  118. self.btnCopy =[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"order_copy"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  119. style:UIBarButtonItemStylePlain
  120. target:self
  121. action:@selector(onCopyOrderClick:)];
  122. #else
  123. self.btnCopy =[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"copy"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  124. style:UIBarButtonItemStylePlain
  125. target:self
  126. action:@selector(onCopyOrderClick:)];// [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Commit", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCommitOrderClick:)];
  127. // self.btnCopy.tintColor = UIColorFromRGB(0x996633);
  128. #endif
  129. // self.btnSend = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Email", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onSendMailClick:)];
  130. self.btnRelease = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"unlock"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  131. style:UIBarButtonItemStylePlain
  132. target:self
  133. action:@selector(onReleaseOrderClick:)];
  134. // self.btnRelease.tintColor = UIColorFromRGB(0x996633);
  135. self.btnPDF = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"mail"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  136. style:UIBarButtonItemStylePlain
  137. target:self
  138. action:@selector(onDownloadOrderClick:)];//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Download", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onDownloadOrderClick:)];
  139. // self.btnPDF.tintColor = UIColorFromRGB(0x996633);
  140. // UIBarButtonItem *item1 = [[UIBarButtonItem alloc] init];
  141. // item1.title = @"item1";
  142. //// item1.image = [UIImage imageNamed:@"rect_setting"];
  143. // UIBarButtonItem *item2 = [[UIBarButtonItem alloc] init];
  144. //// item2.image = [UIImage imageNamed:@"rect_about"];
  145. // item2.title = @"item2";
  146. // UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
  147. // fixedItem.width = 0.0f;
  148. AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
  149. [items addObject:self.btnOpen];
  150. // [items addObject:fixedItem];
  151. // [items addObject:self.btnCommit];
  152. // [items addObject:fixedItem];
  153. if (appDelegate.user_type != USER_ROLE_CUSTOMER) {
  154. [items addObject:self.btnRelease];
  155. }
  156. // [items addObject:fixedItem];
  157. [items addObject:self.btnPDF];
  158. // [items addObject:fixedItem];
  159. [items addObject:self.btnSign];
  160. // [items addObject:fixedItem];
  161. if ((appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeCustomer) || appDelegate.user_type == USER_ROLE_EMPLOYEE) {
  162. [items addObject:self.btnCopy];
  163. }
  164. // [items addObject:item2];
  165. self.navigationItem.rightBarButtonItems=items;
  166. self.btnOpen.enabled =false;
  167. self.btnSign.enabled = false;
  168. self.btnCopy.enabled =false;
  169. self.btnPDF.enabled =false;
  170. self.btnRelease.enabled =false;
  171. // if(self.isTempOrder)
  172. // {
  173. //
  174. //
  175. // self.btnOpen.enabled =true;
  176. //
  177. //
  178. // self.btnCommit.enabled =true;
  179. // }
  180. // else
  181. // {
  182. //
  183. // [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
  184. //
  185. // [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
  186. // self.btnOpen.enabled =false;
  187. // self.btnCommit.enabled =false;
  188. // }
  189. // Do any additional setup after loading the view.
  190. // [self loaddata];
  191. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  192. }
  193. //
  194. //- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
  195. //// self.web_info_height = 0;
  196. ////
  197. //// [self.detailTable.indexPathsForVisibleRows enumerateObjectsUsingBlock:^(NSIndexPath * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  198. ////
  199. //// if (obj.section == 0 && obj.section == 0) {
  200. //// [self.detailTable reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic];
  201. //// }
  202. ////
  203. //// }];
  204. //
  205. //
  206. //}
  207. - (IBAction)onReleaseOrderClick:(id)sender {
  208. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Are you sure to release order?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  209. //block代码块取代了delegate
  210. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  211. UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order"];
  212. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  213. NSDictionary* order_json = [RANetwork release_Order:self.order_code withScreen:ScreenCodeOrderInfo];
  214. dispatch_async(dispatch_get_main_queue(), ^{
  215. [waitalert dismissViewControllerAnimated:YES completion:nil];
  216. if([[order_json valueForKey:@"result"] intValue]==2)
  217. {
  218. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  219. // appDelegate.order_code = nil;
  220. [appDelegate closeOrder];
  221. // appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
  222. //
  223. // appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
  224. // if(self.selectOrder)
  225. // self.selectOrder();
  226. [self.navigationController popToRootViewControllerAnimated:false];
  227. }
  228. else
  229. {
  230. [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
  231. }
  232. });
  233. });
  234. }];
  235. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  236. DebugLog(@"Cancel");
  237. }];
  238. [alertControl addAction:actionOne];
  239. [alertControl addAction:alertthree];
  240. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  241. [self presentViewController:alertControl animated:YES completion:nil];
  242. // get customer info
  243. }
  244. - (void)onDownloadOrderClick:(id)sender {
  245. //
  246. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  247. RAPDFViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
  248. ViewController.mail_content = [self.content_data valueForKey:@"email_content"];
  249. NSString* so = [self.content_data valueForKey:@"so#"];
  250. if(so==nil)
  251. so =@"";
  252. NSString* company = [self.content_data[@"customerInfo"] valueForKey:@"customer_name"];
  253. if(company==nil)
  254. company =@"";
  255. ViewController.save_name =so;
  256. ViewController.hidenavi = false;
  257. if(company==nil)
  258. company=@"";
  259. NSString* customer_email= [self.content_data[@"customerInfo"] valueForKey:@"customer_email"];
  260. // NSMutableArray* arr_subject = [[NSMutableArray alloc]init];
  261. // if(company.length>0)
  262. // [arr_subject addObject:company];
  263. // if(so.length>0)
  264. // [arr_subject addObject:so];
  265. if(company.length==0)
  266. company=@"";
  267. if(so.length==0)
  268. so=@"";
  269. NSMutableArray* send_to = [[NSMutableArray alloc]init];
  270. if(customer_email.length>0)
  271. {
  272. send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
  273. // customer_email compo
  274. // [send_to addObject:customer_email];
  275. }
  276. ViewController.mail_to = send_to;
  277. NSString* subject = nil;
  278. #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
  279. subject=[NSString stringWithFormat:@"%@ -- SO# %@ from %@",company,so,COMPANY_NAME];
  280. if (appDelegate.user_type == USER_ROLE_CUSTOMER&&self.is_shoporder) {
  281. NSString *companyName = [appDelegate.customerInfo objectForKey:@"customer_name"];
  282. subject=[NSString stringWithFormat:@"%@ -- SO# %@ from %@",company,so,companyName];
  283. }
  284. #endif
  285. #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
  286. subject=[NSString stringWithFormat:@"%@ -- SO# %@ from %@",company,so,COMPANY_NAME];
  287. if (appDelegate.user_type == USER_ROLE_CUSTOMER&&self.is_shoporder) {
  288. NSString *companyName = [appDelegate.customerInfo objectForKey:@"customer_name"];
  289. subject=[NSString stringWithFormat:@"%@ -- SO# %@ from %@",company,so,companyName];
  290. }
  291. #endif
  292. #ifdef BUILD_HMLG
  293. subject=[NSString stringWithFormat:@"%@ -- SO# %@ from Homelegance.",company,so];
  294. #endif
  295. ViewController.mail_subject = subject;
  296. int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
  297. NSString *alertTitle = @"View Sales Order:";
  298. if(appDelegate.user_type==USER_ROLE_CUSTOMER&&self.is_shoporder&& (status_code==1 /*||status_code==0*/||status_code==30)) {
  299. alertTitle = @"View Store Order";
  300. }
  301. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:alertTitle message:nil preferredStyle:UIAlertControllerStyleAlert];
  302. //block代码块取代了delegate
  303. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"With Thumbnails" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  304. #ifdef OFFLINE_MODE
  305. if(appDelegate.offline_mode)
  306. {
  307. __weak typeof(self) weakself = self;
  308. NSMutableDictionary* params = [@{
  309. @"thumb" : @"1",
  310. @"order_code" : self.order_code != nil ? self.order_code : @"",
  311. } mutableCopy];
  312. NSData *dicData = [OLDataProvider offline_request_salesorder:params];
  313. NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:dicData options:NSJSONReadingMutableContainers error:nil];
  314. if ([dic[@"result"] integerValue] == RESULT_TRUE) {
  315. NSString *path = dic[@"pdf_path"];
  316. [weakself saleOrderWithPath:path];
  317. // ViewController.url = path;
  318. // ViewController.isLocalfile = YES;
  319. //
  320. // [self.navigationController pushViewController:ViewController animated:YES];
  321. } else {
  322. [RAUtils message_alert:@"Sales Order Open Failed" title:@"Message" controller:weakself];
  323. }
  324. }
  325. else
  326. #endif
  327. {
  328. NSString* url=[self.content_data valueForKey:@"pdfUrl"];
  329. url= [url stringByAppendingString:@"&has_item_pic=true"];
  330. DebugLog(@"pdf url:%@",url);
  331. ViewController.url = url;
  332. [self.navigationController pushViewController:ViewController animated:YES];
  333. }
  334. }];
  335. NSString* alertthreetitle=@"Without Thumbnails";
  336. if(appDelegate.user_type==USER_ROLE_CUSTOMER&&self.is_shoporder&& (status_code==1 /*||status_code==0*/||status_code==30))
  337. {
  338. alertthreetitle=@"Print Quotation";
  339. }
  340. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:alertthreetitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  341. #ifdef OFFLINE_MODE
  342. if(appDelegate.offline_mode)
  343. {
  344. __weak typeof(self) weakself = self;
  345. NSMutableDictionary* params = [@{
  346. @"thumb" : @"0",
  347. @"order_code" : self.order_code != nil ? self.order_code : @"",
  348. } mutableCopy];
  349. NSData *dicData = [OLDataProvider offline_request_salesorder:params];
  350. NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:dicData options:NSJSONReadingMutableContainers error:nil];
  351. if ([dic[@"result"] integerValue] == RESULT_TRUE) {
  352. NSString *path = dic[@"pdf_path"];
  353. [weakself saleOrderWithPath:path];
  354. // ViewController.url = path;
  355. // ViewController.isLocalfile = YES;
  356. //
  357. // [self.navigationController pushViewController:ViewController animated:YES];
  358. } else {
  359. [RAUtils message_alert:@"Sales Order Open Failed" title:@"Message" controller:weakself];
  360. }
  361. }
  362. else
  363. #endif
  364. {
  365. NSString* url=[self.content_data valueForKey:@"pdfUrl"];
  366. DebugLog(@"pdf url:%@",url);
  367. ViewController.url = url;
  368. [self.navigationController pushViewController:ViewController animated:YES];
  369. }
  370. }];
  371. UIAlertAction *alertCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {}];
  372. if(appDelegate.user_type==USER_ROLE_CUSTOMER&&self.is_shoporder&& (status_code==1 /*||status_code==0*/||status_code==30))//[status isEqualToString:@"Saved Order"])
  373. {
  374. [alertControl addAction:alertthree];
  375. [alertControl addAction:alertCancel];
  376. }
  377. else
  378. {
  379. [alertControl addAction:actionOne];
  380. [alertControl addAction:alertthree];
  381. [alertControl addAction:alertCancel];
  382. }
  383. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  384. [self presentViewController:alertControl animated:YES completion:nil];
  385. // get customer info
  386. //
  387. }
  388. - (void)onCopyOrderClick:(id)sender {
  389. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  390. if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.order_code) {
  391. __weak typeof(self) weakself = self;
  392. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:@"You must release current order,are you sure to release the order then copy a new order?" preferredStyle:UIAlertControllerStyleAlert];
  393. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  394. }];
  395. UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  396. UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order"];
  397. dispatch_async(dispatch_get_global_queue(0, 0), ^{
  398. NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:ScreenCodeOrderInfo];
  399. dispatch_async(dispatch_get_main_queue(), ^{
  400. [waitalert dismissViewControllerAnimated:YES completion:nil];
  401. if([[order_json valueForKey:@"result"] intValue]==2)
  402. {
  403. [appDelegate closeOrder];
  404. [weakself copyOrder];
  405. } else {
  406. [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Release Order" controller:weakself] ;
  407. }
  408. });
  409. });
  410. }];
  411. [alertVC addAction:cancelAction];
  412. [alertVC addAction:yesAction];
  413. [self presentViewController:alertVC animated:YES completion:nil];
  414. } else {
  415. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Copy confirm" message:@"Are you sure to copy order?" preferredStyle:UIAlertControllerStyleAlert];
  416. UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"YES" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  417. [self copyOrder];
  418. }];
  419. UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"NO" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  420. }];
  421. [alertController addAction:action_2];
  422. [alertController addAction:action_3];
  423. [self presentViewController:alertController animated:YES completion:nil];
  424. // 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];
  425. // [alert show];
  426. }
  427. }
  428. //- (void)onCommitOrderClick:(id)sender {
  429. // // get customer info
  430. //
  431. // int model_count = [[self.content_data valueForKey:@"model_count"] intValue];
  432. // if(model_count==0)
  433. // {
  434. //// UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Error." message:@"Can not submit an order without models." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  435. ////
  436. //// [alert show];
  437. //
  438. //
  439. // [RAUtils alert_view:@"Cannot submit an order without models" title:@""];
  440. // }
  441. //
  442. // else
  443. // {
  444. //
  445. // 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];
  446. // [alert show];
  447. //
  448. // }
  449. //
  450. //
  451. //}
  452. -(void) upload_img :(UIImage*) img
  453. {
  454. #ifdef OFFLINE_MODE
  455. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  456. if(appDelegate.offline_mode)
  457. {
  458. NSData *data = [OLDataProvider offline_saveBusinesscard:UIImagePNGRepresentation(img)];;
  459. // 再将NSData转为字符串
  460. NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  461. // NSMutableString *str = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
  462. DebugLog(@"data string: %@",jsonStr);
  463. NSError *error=nil;
  464. NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error];
  465. if([[json valueForKey:@"result"] intValue]==2)
  466. {
  467. NSString* img_url_down = json[@"img_url_aname"];
  468. NSString* img_url_up = json[@"img_url"];
  469. {
  470. UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Signature"];
  471. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  472. NSDictionary* order_json = [RANetwork sign_Order:self.order_code path:img_url_up];
  473. dispatch_async(dispatch_get_main_queue(), ^{
  474. [waitalert dismissViewControllerAnimated:YES completion:nil];
  475. if([[order_json valueForKey:@"result"] intValue]==2)
  476. {
  477. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  478. // appDelegate.order_code = self.order_code;
  479. // [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
  480. //
  481. //
  482. // appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
  483. //
  484. // appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
  485. // [self.navigationController popViewControllerAnimated:false];
  486. //
  487. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  488. // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  489. // if(self.selectOrder)
  490. // self.selectOrder(self.content_data);
  491. #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
  492. int count = [[self.content_data objectForKey:@"count"] intValue];
  493. for (int i = 0; i < count; i++) {
  494. NSString *key = [NSString stringWithFormat:@"section_%d",i];
  495. NSMutableDictionary *section = [[self.content_data objectForKey:key] mutableCopy];
  496. NSString *type = [section objectForKey:@"type"];
  497. if ([type isEqualToString:@"sign_url"]) {
  498. [section setObject:img_url_down forKey:@"data"];
  499. [self.content_data setObject:section forKey:key];
  500. break;
  501. }
  502. }
  503. #endif
  504. #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
  505. int count = [[self.content_data objectForKey:@"count"] intValue];
  506. for (int i = 0; i < count; i++) {
  507. NSString *key = [NSString stringWithFormat:@"section_%d",i];
  508. NSMutableDictionary *section = [[self.content_data objectForKey:key] mutableCopy];
  509. NSString *type = [section objectForKey:@"type"];
  510. if ([type isEqualToString:@"sign_url"]) {
  511. [section setObject:img_url_down forKey:@"data"];
  512. [self.content_data setObject:section forKey:key];
  513. break;
  514. }
  515. }
  516. #endif
  517. #ifdef BUILD_HMLG
  518. [self.content_data setValue:img_url_down forKey:@"sign_url"];
  519. #endif
  520. //self.btnSign.enabled = false;
  521. [self.detailTable reloadData];
  522. [RAUtils message_alert:@"Successful." title:@"Signature" controller:self];
  523. }
  524. else
  525. {
  526. [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Signature" controller:self] ;
  527. }
  528. });
  529. });
  530. }
  531. }
  532. else
  533. {
  534. [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Upload Image" controller:self] ;
  535. }
  536. }
  537. else
  538. #endif
  539. {
  540. NSData *imageData = UIImagePNGRepresentation(img);
  541. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  542. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  543. if(appDelegate.user!=nil)
  544. [params setValue:appDelegate.user forKey:@"user"];
  545. if(appDelegate.password!=nil)
  546. [params setValue:appDelegate.password forKey:@"password"];
  547. UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Signature"];
  548. __weak typeof(self) weakSelf = self;
  549. [NetworkUtils upload:imageData FileName:@"test.jpg" Params:params ToHost:URL_UPLOAD_IMG Result:^(NSMutableDictionary *json) {
  550. if([[json valueForKey:@"result"] intValue]==2)
  551. {
  552. NSString* img_url_down = json[@"img_url_aname"];
  553. NSString* img_url_up = json[@"img_url"];
  554. {
  555. // UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Signature"];
  556. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  557. NSDictionary* order_json = [RANetwork sign_Order:weakSelf.order_code path:img_url_up];
  558. dispatch_async(dispatch_get_main_queue(), ^{
  559. [waitalert dismissViewControllerAnimated:YES completion:nil];
  560. if([[order_json valueForKey:@"result"] intValue]==2)
  561. {
  562. #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
  563. int count = [[weakSelf.content_data objectForKey:@"count"] intValue];
  564. for (int i = 0; i < count; i++) {
  565. NSString *key = [NSString stringWithFormat:@"section_%d",i];
  566. NSMutableDictionary *section = [[weakSelf.content_data objectForKey:key] mutableCopy];
  567. NSString *type = [section objectForKey:@"type"];
  568. if ([type isEqualToString:@"sign_url"]) {
  569. [section setObject:img_url_down forKey:@"data"];
  570. [weakSelf.content_data setObject:section forKey:key];
  571. break;
  572. }
  573. }
  574. #endif
  575. #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
  576. int count = [[weakSelf.content_data objectForKey:@"count"] intValue];
  577. for (int i = 0; i < count; i++) {
  578. NSString *key = [NSString stringWithFormat:@"section_%d",i];
  579. NSMutableDictionary *section = [[weakSelf.content_data objectForKey:key] mutableCopy];
  580. NSString *type = [section objectForKey:@"type"];
  581. if ([type isEqualToString:@"sign_url"]) {
  582. [section setObject:img_url_down forKey:@"data"];
  583. [weakSelf.content_data setObject:section forKey:key];
  584. break;
  585. }
  586. }
  587. #endif
  588. #ifdef BUILD_HMLG
  589. [weakSelf.content_data setValue:img_url_down forKey:@"sign_url"];
  590. #endif
  591. //self.btnSign.enabled = false;
  592. [weakSelf.detailTable reloadData];
  593. [RAUtils message_alert:@"Successful." title:@"Signature" controller:weakSelf];
  594. }
  595. else
  596. {
  597. [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Signature" controller:weakSelf] ;
  598. }
  599. });
  600. });
  601. }
  602. }
  603. else
  604. {
  605. dispatch_async(dispatch_get_main_queue(), ^{
  606. [waitalert dismissViewControllerAnimated:YES completion:nil];
  607. NSString *msg = [json valueForKey:@"err_msg"];
  608. if (msg.length == 0) {
  609. msg = [json objectForKey:@"msg"];
  610. }
  611. [RAUtils message_alert:msg title:@"Upload Image" controller:weakSelf] ;
  612. });
  613. }
  614. } Progress:nil DecryptHandler:nil];
  615. // AFHTTPRequestSerializer* serializer=[AFHTTPRequestSerializer serializer] ;
  616. // DebugLog(URL_UPLOAD_IMG);
  617. //
  618. // NSMutableURLRequest *request = [serializer multipartFormRequestWithMethod:@"POST" URLString:URL_UPLOAD_IMG parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
  619. // [formData appendPartWithFileData:imageData name:@"upfile" fileName:@"test.jpg" mimeType:@"image/png"];
  620. // } error:nil];
  621. //
  622. //
  623. // // NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:WEBSERVICE_URL parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
  624. // // [formData appendPartWithFileData:imageData name:@"upfile" fileName:@"test" mimeType:@"image/png"];
  625. // // } error:nil];
  626. // //
  627. // AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
  628. //
  629. //
  630. //
  631. // //manager.responseSerializer.acceptableContentTypes = [self.operationManager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
  632. //
  633. //
  634. //
  635. // //
  636. // NSProgress *progress = nil;
  637. //
  638. // NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
  639. //
  640. // // [progress removeObserver:self forKeyPath:@"fractionCompleted"];
  641. //
  642. //
  643. //
  644. //
  645. // if (error) {
  646. //
  647. // NSString* err_msg = [error localizedDescription];
  648. // DebugLog(@"%@",err_msg);// [self.view updateWithMessage:[NSString stringWithFormat:@"Error : %@!", error.debugDescription]];
  649. //
  650. //
  651. // NSMutableString *str = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
  652. //
  653. // DebugLog(@"data string: %@",str);
  654. //
  655. // [RAUtils message_alert:@"Can not connect to server please try again." title:@"Upload Image" controller:self] ;
  656. //
  657. // } else {
  658. // DebugLog(@"response ");
  659. //
  660. //
  661. //
  662. // NSData *data = [NSJSONSerialization dataWithJSONObject:(NSDictionary*)responseObject options:kNilOptions error:nil];
  663. //
  664. // // 再将NSData转为字符串
  665. // NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
  666. //
  667. // // NSMutableString *str = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
  668. //
  669. // DebugLog(@"data string: %@",jsonStr);
  670. //
  671. // NSDictionary* json = responseObject;
  672. //
  673. // if([[json valueForKey:@"result"] intValue]==2)
  674. // {
  675. // NSString* img_url_down = json[@"img_url_aname"];
  676. // NSString* img_url_up = json[@"img_url"];
  677. //
  678. // {
  679. // UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Signature"];
  680. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  681. //
  682. // NSDictionary* order_json = [iSalesNetwork sign_Order:self.order_code path:img_url_up];
  683. //
  684. // dispatch_async(dispatch_get_main_queue(), ^{
  685. // [waitalert dismissViewControllerAnimated:YES completion:nil];
  686. // if([[order_json valueForKey:@"result"] intValue]==2)
  687. // {
  688. // // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  689. // // appDelegate.order_code = self.order_code;
  690. // // [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
  691. // //
  692. // //
  693. // // appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
  694. // //
  695. // // appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
  696. // // [self.navigationController popViewControllerAnimated:false];
  697. // //
  698. // // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  699. // // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  700. // // if(self.selectOrder)
  701. // // self.selectOrder(self.content_data);
  702. //
  703. //#if defined(BUILD_NPD) || defined(BUILD_USAI)
  704. // int count = [[self.content_data objectForKey:@"count"] intValue];
  705. // for (int i = 0; i < count; i++) {
  706. // NSString *key = [NSString stringWithFormat:@"section_%d",i];
  707. // NSMutableDictionary *section = [[self.content_data objectForKey:key] mutableCopy];
  708. // NSString *type = [section objectForKey:@"type"];
  709. // if ([type isEqualToString:@"sign_url"]) {
  710. // [section setObject:img_url_down forKey:@"data"];
  711. // [self.content_data setObject:section forKey:key];
  712. // break;
  713. // }
  714. // }
  715. //#endif
  716. //
  717. //#ifdef BUILD_HOMER
  718. // int count = [[self.content_data objectForKey:@"count"] intValue];
  719. // for (int i = 0; i < count; i++) {
  720. // NSString *key = [NSString stringWithFormat:@"section_%d",i];
  721. // NSMutableDictionary *section = [[self.content_data objectForKey:key] mutableCopy];
  722. // NSString *type = [section objectForKey:@"type"];
  723. // if ([type isEqualToString:@"sign_url"]) {
  724. // [section setObject:img_url_down forKey:@"data"];
  725. // [self.content_data setObject:section forKey:key];
  726. // break;
  727. // }
  728. // }
  729. //#endif
  730. //#ifdef BUILD_GATIT
  731. // int count = [[self.content_data objectForKey:@"count"] intValue];
  732. // for (int i = 0; i < count; i++) {
  733. // NSString *key = [NSString stringWithFormat:@"section_%d",i];
  734. // NSMutableDictionary *section = [[self.content_data objectForKey:key] mutableCopy];
  735. // NSString *type = [section objectForKey:@"type"];
  736. // if ([type isEqualToString:@"sign_url"]) {
  737. // [section setObject:img_url_down forKey:@"data"];
  738. // [self.content_data setObject:section forKey:key];
  739. // break;
  740. // }
  741. // }
  742. //#endif
  743. //
  744. //#ifdef BUILD_HMLG
  745. // [self.content_data setValue:img_url_down forKey:@"sign_url"];
  746. //#endif
  747. // //self.btnSign.enabled = false;
  748. // [self.detailTable reloadData];
  749. //
  750. // [RAUtils message_alert:@"Successful." title:@"Signature" controller:self];
  751. //
  752. //
  753. // }
  754. // else
  755. // {
  756. // [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Signature" controller:self] ;
  757. // }
  758. //
  759. //
  760. //
  761. // });
  762. // });
  763. // }
  764. //
  765. //
  766. // }
  767. // else
  768. // {
  769. // [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Upload Image" controller:self] ;
  770. // }
  771. //
  772. //
  773. //
  774. //
  775. //
  776. //
  777. // }
  778. // // [waitalert dismissViewControllerAnimated:YES completion:nil];
  779. // }];
  780. //
  781. // [uploadTask resume];
  782. }
  783. }
  784. - (IBAction)onSignOrderClick:(id)sender {
  785. AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
  786. if (appDelegate.order_code.length > 0 && [self.order_code isEqualToString:appDelegate.order_code]) {
  787. [self showSignaturePanel];
  788. } else {
  789. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:@"you need open the order first" preferredStyle:UIAlertControllerStyleAlert];
  790. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  791. }];
  792. [alertVC addAction:cancelAction];
  793. __weak typeof(self) weakSelf = self;
  794. UIAlertAction *openAction = [UIAlertAction actionWithTitle:@"Open" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  795. [self opentOrder:^{
  796. [weakSelf showSignaturePanel];
  797. }];
  798. }];
  799. [alertVC addAction:openAction];
  800. [self presentViewController:alertVC animated:YES completion:nil];
  801. }
  802. }
  803. - (void)showSignaturePanel {
  804. __block UIImage* signimg=nil;
  805. SignatureViewController * vc =[ [UIStoryboard storyboardWithName:@"signature" bundle:nil] instantiateViewControllerWithIdentifier:@"SignatureViewController"];
  806. vc.onReturnImg = ^(UIImage* img)
  807. {
  808. signimg = img;
  809. if(signimg!=nil)
  810. [self upload_img:signimg];
  811. };
  812. [self.navigationController pushViewController:vc animated:NO];
  813. }
  814. - (void)opentOrder:(void(^)(void))completionBlk {
  815. UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Open Order"];
  816. [RANetwork request_open_order:self.order_code completionHandler:^(NSMutableDictionary *result) {
  817. NSDictionary* order_json = result;
  818. [waitalert dismissViewControllerAnimated:YES completion:nil];
  819. if([[order_json valueForKey:@"result"] intValue]==2)
  820. {
  821. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  822. appDelegate.order_code = self.order_code;
  823. appDelegate.order_status = self.order_status;
  824. [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
  825. appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
  826. appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
  827. // [self.navigationController popViewControllerAnimated:false];
  828. #ifdef RA_NOTIFICATION
  829. [ActiveViewController Notify:@"CartViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  830. #else
  831. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  832. [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  833. [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
  834. #endif
  835. if (completionBlk) {
  836. completionBlk();
  837. }
  838. // if(self.selectOrder)
  839. // self.selectOrder(self.content_data);
  840. }
  841. else
  842. {
  843. [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
  844. }
  845. }];
  846. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  847. //
  848. // NSDictionary* order_json = [RANetwork open_Order:self.order_code];
  849. //
  850. // dispatch_async(dispatch_get_main_queue(), ^{
  851. // [waitalert dismissViewControllerAnimated:YES completion:nil];
  852. // if([[order_json valueForKey:@"result"] intValue]==2)
  853. // {
  854. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  855. // appDelegate.order_code = self.order_code;
  856. // appDelegate.order_status = self.order_status;
  857. // [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
  858. //
  859. //
  860. // appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
  861. //
  862. // appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
  863. //
  864. //// [self.navigationController popViewControllerAnimated:false];
  865. //
  866. //#ifdef RA_NOTIFICATION
  867. // [ActiveViewController Notify:@"CartViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  868. //#else
  869. //// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  870. // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  871. // [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
  872. //#endif
  873. //
  874. // if (completionBlk) {
  875. // completionBlk();
  876. // }
  877. //
  878. //// if(self.selectOrder)
  879. //// self.selectOrder(self.content_data);
  880. // }
  881. // else
  882. // {
  883. // [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
  884. // }
  885. //
  886. //
  887. //
  888. // });
  889. // });
  890. }
  891. - (IBAction)onOpenOrderClick:(id)sender {
  892. // get customer info
  893. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Are you sure to open order?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  894. //block代码块取代了delegate
  895. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  896. [self opentOrder:^{
  897. [self.navigationController popViewControllerAnimated:false];
  898. if(self.selectOrder)
  899. self.selectOrder(self.content_data);
  900. }];
  901. }];
  902. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  903. DebugLog(@"Cancel");
  904. }];
  905. [alertControl addAction:actionOne];
  906. [alertControl addAction:alertthree];
  907. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  908. [self presentViewController:alertControl animated:YES completion:nil];
  909. }
  910. - (void)didReceiveMemoryWarning {
  911. [super didReceiveMemoryWarning];
  912. // Dispose of any resources that can be recreated.
  913. }
  914. -(void) loaddata
  915. {
  916. UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Loading"];
  917. dispatch_async(dispatch_get_main_queue(), ^{
  918. if(self.isrefreshing)
  919. return;
  920. self.detailTable.hidden = true;
  921. self.label_net_err.hidden=true;
  922. self.isrefreshing=true;
  923. self.mum.center = self.view.center;
  924. self.mum.hidden = false;
  925. [self.mum startAnimating];
  926. DebugLog(@"reloading...");
  927. self.web_info_height=0;
  928. self.web_moreinfo_height=0;
  929. // self.content_data = nil;
  930. self.btnOpen.enabled =false;
  931. self.btnSign.enabled = false;
  932. self.btnCopy.enabled =false;
  933. self.btnPDF.enabled =false;
  934. self.btnRelease.enabled =false;
  935. NSMutableDictionary *params = [NSMutableDictionary dictionary];
  936. [params setValue:self.orderid forKey:@"orderId"];
  937. if (self.erpSerialNo) {
  938. [params setValue:self.erpSerialNo forKey:@"erp_order_serial_no"];
  939. }
  940. [RANetwork request_orderdetail:params completionHandler:^(NSMutableDictionary *result) {
  941. NSDictionary* order_json = result;
  942. [waitalert dismissViewControllerAnimated:YES completion:nil];
  943. [self.mum stopAnimating];
  944. if([[order_json valueForKey:@"result"] intValue]==2)
  945. {
  946. self.detailTable.hidden = false;
  947. self.content_data = [order_json mutableCopy];
  948. }
  949. else {
  950. self.content_data = nil;
  951. if([[order_json valueForKey:@"result"] intValue]==RESULT_NET_ERROR)
  952. {
  953. self.label_net_err.hidden=false;
  954. self.detailTable.hidden=true;
  955. }
  956. else
  957. {
  958. [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Loading Order Detail" controller:self] ;
  959. }
  960. }
  961. bool web_order =[[self.content_data valueForKey:@"from_online"] boolValue];
  962. if(web_order)
  963. self.btnCopy.enabled = false;
  964. else
  965. self.btnCopy.enabled = true;
  966. int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
  967. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  968. int model_count =[[self.content_data valueForKey:@"model_count"] intValue];
  969. if(model_count>0)/*&& ! appDelegate.offline_mode*/
  970. {
  971. if(appDelegate.user_type== USER_ROLE_EMPLOYEE || (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeCustomer))
  972. self.btnPDF.enabled =true;
  973. else
  974. {
  975. // || appDelegate.user_type==USER_ROLE_CUSTOMER
  976. if(self.is_shoporder)
  977. {
  978. if(status_code==1||status_code==30)
  979. self.btnPDF.enabled =true;
  980. }
  981. else
  982. {
  983. if(status_code==2)
  984. self.btnPDF.enabled =true;
  985. }
  986. }
  987. }
  988. // [self.btnPDF setImage:[[UIImage imageNamed:@"download"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  989. // NSString* status = [self.content_data valueForKey:@"order_status"];
  990. NSString* lock_user = [self.content_data valueForKey:@"opened_customer"];
  991. bool offline_edit =[[self.content_data valueForKey:@"offline_edit"] boolValue];
  992. if(status_code==1)//[status isEqualToString:@"Saved Order"])
  993. {
  994. // [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  995. //
  996. // [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  997. BOOL condition = offline_edit;
  998. #ifdef OFFLINE_MODE
  999. condition = condition || appDelegate.offline_mode==false;
  1000. #else
  1001. condition = YES;
  1002. #endif
  1003. if(condition)
  1004. {
  1005. self.btnOpen.enabled =true;
  1006. self.btnSign.enabled = true;
  1007. }
  1008. // if([lock_user isEqualToString:appDelegate.user])
  1009. // {
  1010. // self.btnCommit.enabled =true;
  1011. // }
  1012. // else
  1013. // self.btnCommit.enabled =false;
  1014. }
  1015. else
  1016. if(status_code==0)//[status isEqualToString:@"Quote Saved"])
  1017. {
  1018. // [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  1019. //
  1020. // [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
  1021. BOOL condition = offline_edit;
  1022. #ifdef OFFLINE_MODE
  1023. condition = condition || appDelegate.offline_mode==false;
  1024. #else
  1025. condition = YES;
  1026. #endif
  1027. if (condition)
  1028. {
  1029. self.btnOpen.enabled =true;
  1030. self.btnSign.enabled = true;
  1031. }
  1032. // self.btnCommit.enabled =false;
  1033. }
  1034. BOOL lock_condition_1 = [lock_user isEqualToString:appDelegate.user];
  1035. BOOL lock_condition_2 = false;
  1036. #ifdef OFFLINE_MODE
  1037. lock_condition_1 = !appDelegate.offline_mode && lock_condition_1;
  1038. lock_condition_2 = appDelegate.offline_mode && [self.order_code isEqualToString:appDelegate.order_code];
  1039. #endif
  1040. if((lock_condition_1 || lock_condition_2)&& (status_code==1||status_code==0))
  1041. {
  1042. // [self.btnRelease setImage:[[UIImage imageNamed:@"order"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  1043. self.btnRelease.enabled =true;
  1044. }
  1045. else
  1046. {
  1047. // [self.btnRelease setImage:[[UIImage imageNamed:@"order"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
  1048. self.btnRelease.enabled =false;
  1049. }
  1050. [self.detailTable reloadData];
  1051. self.isrefreshing=false;
  1052. if (self.order_code == nil) {
  1053. self.btnCopy.enabled = false;
  1054. } else {
  1055. self.btnCopy.enabled = true;
  1056. }
  1057. }];
  1058. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1059. //
  1060. //
  1061. // NSDictionary* order_json = [RANetwork request_OrderDetail:params];
  1062. //
  1063. // dispatch_async(dispatch_get_main_queue(), ^{
  1064. //
  1065. // [waitalert dismissViewControllerAnimated:YES completion:nil];
  1066. // [self.mum stopAnimating];
  1067. // if([[order_json valueForKey:@"result"] intValue]==2)
  1068. // {
  1069. // self.detailTable.hidden = false;
  1070. // self.content_data = [order_json mutableCopy];
  1071. //
  1072. //
  1073. // }
  1074. // else {
  1075. // self.content_data = nil;
  1076. // if([[order_json valueForKey:@"result"] intValue]==RESULT_NET_ERROR)
  1077. // {
  1078. // self.label_net_err.hidden=false;
  1079. // self.detailTable.hidden=true;
  1080. // }
  1081. // else
  1082. // {
  1083. // [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Loading Order Detail" controller:self] ;
  1084. // }
  1085. // }
  1086. //
  1087. // bool web_order =[[self.content_data valueForKey:@"from_online"] boolValue];
  1088. // if(web_order)
  1089. // self.btnCopy.enabled = false;
  1090. // else
  1091. // self.btnCopy.enabled = true;
  1092. // int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
  1093. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1094. // int model_count =[[self.content_data valueForKey:@"model_count"] intValue];
  1095. // if(model_count>0)/*&& ! appDelegate.offline_mode*/
  1096. // {
  1097. // if(appDelegate.user_type== USER_ROLE_EMPLOYEE || (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeCustomer))
  1098. // self.btnPDF.enabled =true;
  1099. // else
  1100. // {
  1101. // // || appDelegate.user_type==USER_ROLE_CUSTOMER
  1102. // if(self.is_shoporder)
  1103. // {
  1104. // if(status_code==1||status_code==30)
  1105. // self.btnPDF.enabled =true;
  1106. //
  1107. // }
  1108. // else
  1109. // {
  1110. // if(status_code==2)
  1111. // self.btnPDF.enabled =true;
  1112. // }
  1113. // }
  1114. // }
  1115. // // [self.btnPDF setImage:[[UIImage imageNamed:@"download"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  1116. //
  1117. //// NSString* status = [self.content_data valueForKey:@"order_status"];
  1118. //
  1119. // NSString* lock_user = [self.content_data valueForKey:@"opened_customer"];
  1120. //
  1121. // bool offline_edit =[[self.content_data valueForKey:@"offline_edit"] boolValue];
  1122. // if(status_code==1)//[status isEqualToString:@"Saved Order"])
  1123. // {
  1124. // // [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  1125. // //
  1126. // // [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  1127. //
  1128. // BOOL condition = offline_edit;
  1129. //#ifdef OFFLINE_MODE
  1130. // condition = condition || appDelegate.offline_mode==false;
  1131. //#else
  1132. // condition = YES;
  1133. //#endif
  1134. // if(condition)
  1135. // {
  1136. // self.btnOpen.enabled =true;
  1137. //
  1138. // self.btnSign.enabled = true;
  1139. // }
  1140. // // if([lock_user isEqualToString:appDelegate.user])
  1141. // // {
  1142. // // self.btnCommit.enabled =true;
  1143. // // }
  1144. // // else
  1145. // // self.btnCommit.enabled =false;
  1146. // }
  1147. // else
  1148. // if(status_code==0)//[status isEqualToString:@"Quote Saved"])
  1149. // {
  1150. // // [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  1151. // //
  1152. // // [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
  1153. //
  1154. // BOOL condition = offline_edit;
  1155. //#ifdef OFFLINE_MODE
  1156. // condition = condition || appDelegate.offline_mode==false;
  1157. //#else
  1158. // condition = YES;
  1159. //#endif
  1160. // if (condition)
  1161. // {
  1162. // self.btnOpen.enabled =true;
  1163. //
  1164. // self.btnSign.enabled = true;
  1165. // }
  1166. // // self.btnCommit.enabled =false;
  1167. // }
  1168. // BOOL lock_condition_1 = [lock_user isEqualToString:appDelegate.user];
  1169. // BOOL lock_condition_2 = false;
  1170. //#ifdef OFFLINE_MODE
  1171. // lock_condition_1 = !appDelegate.offline_mode && lock_condition_1;
  1172. // lock_condition_2 = appDelegate.offline_mode && [self.order_code isEqualToString:appDelegate.order_code];
  1173. //#endif
  1174. //
  1175. // if((lock_condition_1 || lock_condition_2)&& (status_code==1||status_code==0))
  1176. // {
  1177. // // [self.btnRelease setImage:[[UIImage imageNamed:@"order"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  1178. //
  1179. //
  1180. // self.btnRelease.enabled =true;
  1181. // }
  1182. // else
  1183. // {
  1184. //
  1185. //
  1186. // // [self.btnRelease setImage:[[UIImage imageNamed:@"order"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
  1187. // self.btnRelease.enabled =false;
  1188. // }
  1189. //
  1190. // [self.detailTable reloadData];
  1191. // self.isrefreshing=false;
  1192. //
  1193. // if (self.order_code == nil) {
  1194. // self.btnCopy.enabled = false;
  1195. // } else {
  1196. // self.btnCopy.enabled = true;
  1197. // }
  1198. //
  1199. // });
  1200. //
  1201. // });
  1202. });
  1203. }
  1204. - (void)viewWillAppear:(BOOL)animated
  1205. {
  1206. [super viewWillAppear:animated];
  1207. // if(appDelegate.can_submit_order)
  1208. // {
  1209. //
  1210. //
  1211. // [self.btnCommit setImage:[UIImage imageNamed:@"commit"]];
  1212. // self.btnCommit.enabled = true;
  1213. // }
  1214. // else
  1215. // {
  1216. // [self.btnCommit setImage:nil];
  1217. // self.btnCommit.enabled = false;
  1218. // }
  1219. //
  1220. [[self navigationController] setNavigationBarHidden:NO animated:NO];
  1221. }
  1222. - (IBAction)imgbtnClicked:(UIButton*)sender {
  1223. // 这里有问题,npd 里order 提交后,product id 为空,暂时屏蔽掉
  1224. return;
  1225. // 以下为屏蔽前的代码
  1226. //
  1227. // UITableViewCell* cell =(UITableViewCell*) sender.superview.superview;
  1228. //
  1229. // NSIndexPath * indexPath = [self.detailTable indexPathForCell:cell];
  1230. //
  1231. //// if(indexPath.section!=1)
  1232. //// return ;
  1233. // // DebugLog(@"shouldchangeedit %d_%d",indexPath.section,indexPath.row);
  1234. // NSDictionary * item_json = self.content_data[[NSString stringWithFormat:@"section_%ld",(long)indexPath.section]][@"data"][[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  1235. //// NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  1236. //
  1237. // NSString* product_id = [item_json valueForKey:@"product_id"];
  1238. //
  1239. // DetailViewController* dvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Model" bundle:nil] instantiateViewControllerWithIdentifier:@"DetailViewController" ];
  1240. // // dvc
  1241. //
  1242. // dvc.product_id=product_id;
  1243. // dvc.category_id=nil;
  1244. // dvc.ispush=true;
  1245. // [dvc reload];
  1246. // [self.navigationController pushViewController:dvc animated:true];
  1247. }
  1248. /*
  1249. #pragma mark - Navigation
  1250. // In a storyboard-based application, you will often want to do a little preparation before navigation
  1251. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  1252. // Get the new view controller using [segue destinationViewController].
  1253. // Pass the selected object to the new view controller.
  1254. }
  1255. */
  1256. #pragma mark - Table view data source
  1257. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
  1258. {
  1259. // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  1260. // if([item_json objectForKey:@"combine"] == nil)
  1261. // {
  1262. // return 120;
  1263. // }
  1264. // else
  1265. // return 150;
  1266. #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
  1267. NSDictionary *section_item = [self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",indexPath.section]];
  1268. NSDictionary *data = [section_item objectForKey:@"data"];
  1269. NSString *type = [section_item objectForKey:@"type"];
  1270. if ([type isEqualToString:@"order_info"]) {
  1271. float height= self.web_info_height;
  1272. if(height==0)
  1273. height=DEF_TABLE_HEIGHT;
  1274. return height;
  1275. } else if ([type isEqualToString:@"sign_url"]) {
  1276. return 148;
  1277. } else if ([type isEqualToString:@"more_order_info"]) {
  1278. float height= self.web_moreinfo_height;
  1279. if(height==0)
  1280. height=DEF_TABLE_HEIGHT;
  1281. return height;
  1282. } else if ([type isEqualToString:@"sub_order"]) {
  1283. NSDictionary *item = [data objectForKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]];
  1284. NSString *item_type = [item objectForKey:@"type"];
  1285. if ([item_type isEqualToString:@"pick_info"]) {
  1286. return 218;
  1287. } else {
  1288. NSString* notes =[item valueForKey:@"note"];
  1289. if(notes.length>0)
  1290. {
  1291. return 190;
  1292. }
  1293. else
  1294. return 162;
  1295. }
  1296. } else if ([type isEqualToString:@"price_info"]) {
  1297. return 44;
  1298. }
  1299. #endif
  1300. #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
  1301. NSDictionary *section_item = [self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",indexPath.section]];
  1302. NSDictionary *data = [section_item objectForKey:@"data"];
  1303. NSString *type = [section_item objectForKey:@"type"];
  1304. if ([type isEqualToString:@"order_info"]) {
  1305. float height= self.web_info_height;
  1306. if(height==0)
  1307. height=DEF_TABLE_HEIGHT;
  1308. return height;
  1309. } else if ([type isEqualToString:@"sign_url"]) {
  1310. return 148;
  1311. } else if ([type isEqualToString:@"more_order_info"]) {
  1312. float height= self.web_moreinfo_height;
  1313. if(height==0)
  1314. height=DEF_TABLE_HEIGHT;
  1315. return height;
  1316. } else if ([type isEqualToString:@"sub_order"]) {
  1317. NSDictionary *item = [data objectForKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]];
  1318. NSString *item_type = [item objectForKey:@"type"];
  1319. if ([item_type isEqualToString:@"pick_info"]) {
  1320. return 218;
  1321. } else {
  1322. NSString* notes =[item valueForKey:@"note"];
  1323. if(notes.length>0)
  1324. {
  1325. return 190;
  1326. }
  1327. else
  1328. return 162;
  1329. }
  1330. } else if ([type isEqualToString:@"price_info"]) {
  1331. return 44;
  1332. }
  1333. #endif
  1334. #ifdef BUILD_HMLG
  1335. switch (indexPath.section) {
  1336. case 0:
  1337. {
  1338. if(indexPath.row==0)
  1339. {
  1340. float height= self.web_info_height;
  1341. if(height==0)
  1342. height=DEF_TABLE_HEIGHT;
  1343. return height;
  1344. }
  1345. else
  1346. return 148;
  1347. }
  1348. break;
  1349. case 1:
  1350. {
  1351. float height= self.web_moreinfo_height;
  1352. if(height==0)
  1353. height=DEF_TABLE_HEIGHT;
  1354. // DebugLog(@"heightForRowAtIndexPath...............webview,hight = %f section=%ld",height,indexPath.section);
  1355. //wait(1000);
  1356. return height;
  1357. }
  1358. break;
  1359. case 2:
  1360. {
  1361. NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  1362. NSString* notes =[item_json valueForKey:@"note"];
  1363. if(notes.length>0)
  1364. {
  1365. return 190;
  1366. }
  1367. else
  1368. return 162;
  1369. }
  1370. case 3:
  1371. return 44;
  1372. default:
  1373. break;
  1374. }
  1375. #endif
  1376. return 44;
  1377. }
  1378. //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  1379. //{
  1380. // return 0;
  1381. //}
  1382. //- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  1383. //{
  1384. // return 0;
  1385. //}
  1386. //- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  1387. //{
  1388. // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  1389. // return myView;
  1390. //
  1391. //}
  1392. //- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  1393. //{
  1394. // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  1395. //// myView.backgroundColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
  1396. //// UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 90, 22)];
  1397. //// titleLabel.textColor=[UIColor whiteColor];
  1398. //// titleLabel.backgroundColor = [UIColor clearColor];
  1399. //// if(section==0)
  1400. //// titleLabel.text=NSLocalizedString(@"display_items", nil);
  1401. //// else
  1402. //// titleLabel.text=NSLocalizedString(@"hide_items", nil);
  1403. //// [titleLabel sizeToFit];
  1404. //// [myView addSubview:titleLabel];
  1405. ////
  1406. // return myView;
  1407. //}
  1408. //
  1409. - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  1410. {
  1411. NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  1412. if(value==nil)
  1413. value=@"";
  1414. unsigned long color = strtoul([value UTF8String],0,16);
  1415. DefaultTableHeaderView* myView = [[DefaultTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  1416. // myView.backgroundColor = UIColorFromRGB(0x996633);;
  1417. myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath;
  1418. // myView.layer.masksToBounds = false;
  1419. //添加四个边阴影
  1420. myView.layer.shadowColor = [UIColor blackColor].CGColor;
  1421. myView.layer.shadowOffset = CGSizeMake(0, 0);
  1422. myView.layer.shadowOpacity = 0.5;
  1423. myView.layer.shadowRadius = 2.0;
  1424. myView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  1425. NSString*labeltitle = nil;
  1426. #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
  1427. NSDictionary *section_item = [self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",section]];
  1428. NSString *title = [section_item objectForKey:@"title"];
  1429. labeltitle = title;
  1430. if ([title isEqualToString:@"More Info"]) {
  1431. NSString* btntitle=nil ;
  1432. if(self.showMore)
  1433. {
  1434. btntitle=@"Hide";
  1435. }
  1436. else{
  1437. btntitle=@"Show";
  1438. }
  1439. UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
  1440. btn.tag=section;
  1441. [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
  1442. [btn setTitle:btntitle forState:UIControlStateNormal];
  1443. btn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  1444. [myView addSubview:btn];
  1445. } else if ([title containsString:@"Models"] || [title containsString:@"Invoice#"]) {
  1446. BOOL item_switch = [[section_item objectForKey:@"switch"] boolValue];
  1447. NSString *normalTitle = @"Show";
  1448. NSString *selectedTitle = @"Hide";
  1449. if (item_switch == YES) {
  1450. normalTitle = @"Hide";
  1451. selectedTitle = @"Show";
  1452. }
  1453. UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
  1454. btn.tag=section;
  1455. [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
  1456. [btn setTitle:normalTitle forState:UIControlStateNormal];
  1457. [btn setTitle:selectedTitle forState:UIControlStateSelected];
  1458. btn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  1459. [myView addSubview:btn];
  1460. }
  1461. #endif
  1462. #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
  1463. NSDictionary *section_item = [self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",section]];
  1464. NSString *title = [section_item objectForKey:@"title"];
  1465. labeltitle = title;
  1466. if ([title isEqualToString:@"More Info"]) {
  1467. NSString* btntitle=nil ;
  1468. if(self.showMore)
  1469. {
  1470. btntitle=@"Hide";
  1471. }
  1472. else{
  1473. btntitle=@"Show";
  1474. }
  1475. UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
  1476. btn.tag=section;
  1477. [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
  1478. [btn setTitle:btntitle forState:UIControlStateNormal];
  1479. btn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  1480. [myView addSubview:btn];
  1481. } else if ([title containsString:@"Models"] || [title containsString:@"Invoice#"]) {
  1482. BOOL item_switch = [[section_item objectForKey:@"switch"] boolValue];
  1483. NSString *normalTitle = @"Show";
  1484. NSString *selectedTitle = @"Hide";
  1485. if (item_switch == YES) {
  1486. normalTitle = @"Hide";
  1487. selectedTitle = @"Show";
  1488. }
  1489. UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
  1490. btn.tag=section;
  1491. [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
  1492. [btn setTitle:normalTitle forState:UIControlStateNormal];
  1493. [btn setTitle:selectedTitle forState:UIControlStateSelected];
  1494. btn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  1495. [myView addSubview:btn];
  1496. }
  1497. #endif
  1498. #ifdef BUILD_HMLG
  1499. switch (section) {
  1500. case 0:
  1501. labeltitle= @"Order Info";
  1502. break;
  1503. case 1:
  1504. {
  1505. labeltitle= @"More Info";
  1506. NSString* btntitle=nil ;
  1507. if(self.showMore)
  1508. {
  1509. btntitle=@"Hide";
  1510. // [section setValue:@"false" forKey:@"hide"];
  1511. // [sender setTitle:@"Show" forState:UIControlStateNormal];
  1512. }
  1513. else{
  1514. btntitle=@"Show";
  1515. }
  1516. UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
  1517. btn.tag=section;
  1518. [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
  1519. [btn setTitle:btntitle forState:UIControlStateNormal];
  1520. btn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  1521. [myView addSubview:btn];
  1522. }
  1523. break;
  1524. case 2:{
  1525. labeltitle= @"Models";
  1526. NSString* btntitle=nil ;
  1527. if(self.showModels)
  1528. {
  1529. btntitle=@"Hide";
  1530. }
  1531. else{
  1532. btntitle=@"Show";
  1533. }
  1534. UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
  1535. btn.tag=section;
  1536. [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
  1537. [btn setTitle:btntitle forState:UIControlStateNormal];
  1538. btn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  1539. [myView addSubview:btn];
  1540. }
  1541. break;
  1542. case 3:
  1543. labeltitle= @"Price Info";
  1544. default:
  1545. break;
  1546. }
  1547. #endif
  1548. UILabel *titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 5.5, 200, 20)];
  1549. titlelabel.textColor=UIColorFromRGB(color);;
  1550. titlelabel.backgroundColor = [UIColor clearColor];
  1551. titlelabel.text=NSLocalizedString(labeltitle, nil);
  1552. [titlelabel sizeToFit];
  1553. titlelabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
  1554. [myView addSubview:titlelabel];
  1555. //
  1556. return myView;
  1557. }
  1558. #pragma mark - hide section button clicked
  1559. - (void)HideSction:(UIButton *)sender {
  1560. /*
  1561. NSMutableDictionary* section= [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",sender.tag]] mutableCopy];
  1562. bool hide = [[section valueForKey:@"hide"]boolValue];
  1563. if(hide)
  1564. {
  1565. [section setValue:@"false" forKey:@"hide"];
  1566. [sender setTitle:@"Show" forState:UIControlStateNormal];
  1567. }
  1568. else{
  1569. [section setValue:@"true" forKey:@"hide"];
  1570. [sender setTitle:@"Hide" forState:UIControlStateNormal];
  1571. }
  1572. [self.content_data_download setObject:section forKey:[NSString stringWithFormat:@"section_%d",sender.tag]];
  1573. self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
  1574. */
  1575. #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
  1576. NSUInteger section = sender.tag;
  1577. NSMutableDictionary *section_item = [[self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",section]] mutableCopy];
  1578. NSString *title = [section_item objectForKey:@"title"];
  1579. if ([title isEqualToString:@"More Info"]) {
  1580. self.showMore = !self.showMore;
  1581. NSRange range = NSMakeRange(section, 1);
  1582. NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
  1583. [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
  1584. } else if ([title containsString:@"Models"] || [title containsString:@"Invoice#"]) {
  1585. BOOL item_switch = [[section_item objectForKey:@"switch"] boolValue];
  1586. if (item_switch == YES) {
  1587. [section_item setObject:@(NO) forKey:@"switch"];
  1588. } else {
  1589. [section_item setObject:@(YES) forKey:@"switch"];
  1590. }
  1591. [self.content_data setObject:section_item forKey:[NSString stringWithFormat:@"section_%ld",section]];
  1592. sender.selected = !sender.selected;
  1593. NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndex:section];
  1594. [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
  1595. }
  1596. #endif
  1597. #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
  1598. NSUInteger section = sender.tag;
  1599. NSMutableDictionary *section_item = [[self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",section]] mutableCopy];
  1600. NSString *title = [section_item objectForKey:@"title"];
  1601. if ([title isEqualToString:@"More Info"]) {
  1602. self.showMore = !self.showMore;
  1603. NSRange range = NSMakeRange(section, 1);
  1604. NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
  1605. [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
  1606. } else if ([title containsString:@"Models"] || [title containsString:@"Invoice#"]) {
  1607. BOOL item_switch = [[section_item objectForKey:@"switch"] boolValue];
  1608. if (item_switch == YES) {
  1609. [section_item setObject:@(NO) forKey:@"switch"];
  1610. } else {
  1611. [section_item setObject:@(YES) forKey:@"switch"];
  1612. }
  1613. [self.content_data setObject:section_item forKey:[NSString stringWithFormat:@"section_%ld",section]];
  1614. sender.selected = !sender.selected;
  1615. NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndex:section];
  1616. [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
  1617. }
  1618. #endif
  1619. #ifdef BUILD_HMLG
  1620. switch (sender.tag) {
  1621. case 0:{
  1622. }
  1623. break;
  1624. case 1:{
  1625. self.showMore=!self.showMore;
  1626. NSRange range = NSMakeRange(1, 1);
  1627. NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
  1628. [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
  1629. }
  1630. break;
  1631. case 2:{
  1632. self.showModels = !self.showModels;
  1633. NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndex:2];
  1634. [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
  1635. }
  1636. break;
  1637. default:
  1638. break;
  1639. }
  1640. #endif
  1641. }
  1642. - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  1643. switch (section) {
  1644. case 0:
  1645. return @"Order Info";
  1646. break;
  1647. case 1:
  1648. return @"More Info";
  1649. break;
  1650. case 2:
  1651. return @"Models";
  1652. case 3:
  1653. return @"Price Info";
  1654. default:
  1655. break;
  1656. }
  1657. return nil;
  1658. }
  1659. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  1660. {
  1661. if(self.content_data==nil)
  1662. return 0;
  1663. #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
  1664. return [[self.content_data objectForKey:@"count"] integerValue];
  1665. #endif
  1666. //#ifdef BUILD_USAI
  1667. // return [[self.content_data objectForKey:@"count"] integerValue];
  1668. //#endif
  1669. #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
  1670. return [[self.content_data objectForKey:@"count"] integerValue];
  1671. #endif
  1672. #ifdef BUILD_HMLG
  1673. return 4;
  1674. #endif
  1675. }
  1676. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  1677. {
  1678. return 33;
  1679. }
  1680. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  1681. {
  1682. #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
  1683. NSDictionary *section_item = [self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",section]];
  1684. NSDictionary *data = [section_item objectForKey:@"data"];
  1685. NSString *section_type = [section_item objectForKey:@"type"];
  1686. if ([section_type isEqualToString:@"sub_order"]) {
  1687. BOOL item_switch = [[section_item objectForKey:@"switch"] boolValue];
  1688. if (item_switch == YES) {
  1689. return [[data objectForKey:@"count"] integerValue];
  1690. } else {
  1691. return 0;
  1692. }
  1693. } else if ([section_type isEqualToString:@"order_info"]){
  1694. if (self.showModels) {
  1695. return 1;
  1696. } else {
  1697. return 0;
  1698. }
  1699. } else if ([section_type isEqualToString:@"sign_url"]){
  1700. return 1;
  1701. } else if ([section_type isEqualToString:@"more_order_info"]){
  1702. if(self.showMore)
  1703. return 1;
  1704. else
  1705. return 0;
  1706. }else if ([section_type isEqualToString:@"price_info"]){
  1707. return [[data objectForKey:@"count"] integerValue];
  1708. }
  1709. return 0;
  1710. #endif
  1711. #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
  1712. NSDictionary *section_item = [self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",section]];
  1713. NSDictionary *data = [section_item objectForKey:@"data"];
  1714. NSString *section_type = [section_item objectForKey:@"type"];
  1715. if ([section_type isEqualToString:@"sub_order"]) {
  1716. BOOL item_switch = [[section_item objectForKey:@"switch"] boolValue];
  1717. if (item_switch == YES) {
  1718. return [[data objectForKey:@"count"] integerValue];
  1719. } else {
  1720. return 0;
  1721. }
  1722. } else if ([section_type isEqualToString:@"order_info"]){
  1723. if (self.showModels) {
  1724. return 1;
  1725. } else {
  1726. return 0;
  1727. }
  1728. } else if ([section_type isEqualToString:@"sign_url"]){
  1729. return 1;
  1730. } else if ([section_type isEqualToString:@"more_order_info"]){
  1731. if(self.showMore)
  1732. return 1;
  1733. else
  1734. return 0;
  1735. }else if ([section_type isEqualToString:@"price_info"]){
  1736. return [[data objectForKey:@"count"] integerValue];
  1737. }
  1738. return 0;
  1739. #endif
  1740. #ifdef BUILD_HMLG
  1741. // NSDictionary * item_json = [self.content_data objectForKey:@"items"];
  1742. if(section==0)
  1743. return 2;
  1744. if(section==1)
  1745. {
  1746. if(self.showMore)
  1747. return 1;
  1748. else
  1749. return 0;
  1750. }
  1751. if(section==2)
  1752. {
  1753. if (self.showModels) {
  1754. int count =[[self.content_data valueForKey:@"model_count"] intValue];
  1755. return count;
  1756. } else {
  1757. return 0;
  1758. }
  1759. }
  1760. if(section==3) {
  1761. #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
  1762. return 6;
  1763. #endif
  1764. #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
  1765. return 6;
  1766. #endif
  1767. #ifdef BUILD_HMLG
  1768. return 4;
  1769. #endif
  1770. }
  1771. #endif
  1772. return 0;
  1773. }
  1774. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  1775. {
  1776. UIApplication * app = [UIApplication sharedApplication];
  1777. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  1778. #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
  1779. /**
  1780. * ver1.90
  1781. */
  1782. NSDictionary *section = [self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",indexPath.section]];
  1783. NSString *type = [section objectForKey:@"type"];
  1784. if ([type isEqualToString:@"order_info"]) {/** Order Info */
  1785. NSString *CellIdentifier = @"OrderDetailHtmlCell";
  1786. OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  1787. cell.html = nil;
  1788. cell.wkwebview.tag = indexPath.section;
  1789. cell.wkwebview.navigationDelegate = self;
  1790. // cell.webView.scrollView.contentSize.height = 0;
  1791. cell.wkwebview.scrollView.bounces=NO;
  1792. cell.wkwebview.scrollView.directionalLockEnabled = true;
  1793. CGSize size= cell.wkwebview.scrollView.contentSize;
  1794. size.height=10;
  1795. cell.wkwebview.scrollView.contentSize=size;
  1796. cell.backgroundColor = [UIColor whiteColor];
  1797. cell.wkwebview.userInteractionEnabled = YES;
  1798. cell.html =[section valueForKey:@"data"];
  1799. NSLog(@"webview loadHTMLString 0");
  1800. [cell.wkwebview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
  1801. NSLog(@"webview loadHTMLString 1");
  1802. return cell;
  1803. } else if ([type isEqualToString:@"sign_url"]) { /** Sign */
  1804. NSString *CellIdentifier = @"OrderDetailSignatureCell";
  1805. OrderDetailSignatureCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  1806. NSString* img_url = [section valueForKey:@"data"];
  1807. cell.sign_img.userInteractionEnabled = NO;
  1808. __block BOOL hasTapGesture = NO;
  1809. [cell.sign_img.gestureRecognizers enumerateObjectsUsingBlock:^(__kindof UIGestureRecognizer * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  1810. if ([obj isKindOfClass:[UITapGestureRecognizer class]]) {
  1811. hasTapGesture = YES;
  1812. *stop = YES;
  1813. }
  1814. }];
  1815. if (!hasTapGesture) {
  1816. UITapGestureRecognizer *signatureTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onSignOrderClick:)];
  1817. [cell.sign_img addGestureRecognizer:signatureTap];
  1818. }
  1819. int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
  1820. bool offline_edit =[[self.content_data valueForKey:@"offline_edit"] boolValue];
  1821. if(status_code==1) {
  1822. BOOL condition = offline_edit;
  1823. #ifdef OFFLINE_MODE
  1824. condition = condition || appDelegate.offline_mode==false;
  1825. #else
  1826. condition = YES;
  1827. #endif
  1828. if (condition)
  1829. {
  1830. cell.sign_img.userInteractionEnabled = YES;
  1831. }
  1832. }
  1833. else if(status_code==0) {
  1834. BOOL condition = offline_edit;
  1835. #ifdef OFFLINE_MODE
  1836. condition = condition || appDelegate.offline_mode==false;
  1837. #else
  1838. condition = YES;
  1839. #endif
  1840. if (condition)
  1841. {
  1842. cell.sign_img.userInteractionEnabled = YES;
  1843. }
  1844. }
  1845. NSString* file_name=[img_url lastPathComponent];
  1846. NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
  1847. if(img_data!=nil)
  1848. {
  1849. UIImage * img =[UIImage imageWithData:img_data];
  1850. cell.sign_img.image=img ;
  1851. }
  1852. else
  1853. {
  1854. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1855. NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  1856. dispatch_async(dispatch_get_main_queue(), ^{
  1857. if(downloadimg_data!=nil)
  1858. {
  1859. [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
  1860. UIImage * img =[UIImage imageWithData:downloadimg_data];
  1861. cell.sign_img.image=img ;
  1862. }
  1863. else {
  1864. if (cell.sign_img.userInteractionEnabled) {
  1865. cell.sign_img.image=[UIImage imageNamed:@"taptosign_s"];
  1866. } else {
  1867. cell.sign_img.image = nil;
  1868. }
  1869. }
  1870. });
  1871. });
  1872. }
  1873. cell.backgroundColor = [UIColor whiteColor];
  1874. return cell;
  1875. } else if ([type isEqualToString:@"more_order_info"]) { /** More Info */
  1876. NSString *CellIdentifier = @"OrderDetailHtmlCell";
  1877. OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  1878. cell.wkwebview.tag = indexPath.section;
  1879. cell.wkwebview.navigationDelegate = self;
  1880. // cell.webView.scrollView.contentSize.height = 0;
  1881. cell.wkwebview.scrollView.bounces=NO;
  1882. cell.wkwebview.scrollView.directionalLockEnabled = true;
  1883. CGSize size= cell.wkwebview.scrollView.contentSize;
  1884. size.height=10;
  1885. cell.wkwebview.scrollView.contentSize=size;
  1886. NSLog(@"webview loadHTMLString 3");
  1887. [cell.wkwebview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
  1888. NSLog(@"webview loadHTMLString 4");
  1889. cell.backgroundColor = [UIColor whiteColor];
  1890. return cell;
  1891. } else if ([type isEqualToString:@"sub_order"]) { /** Sub Order */
  1892. NSDictionary *data = [section objectForKey:@"data"];
  1893. NSDictionary *item = [data objectForKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]];
  1894. NSString *item_type = [item objectForKey:@"type"];
  1895. if ([item_type isEqualToString:@"pick_info"]) { /** Pick Info */
  1896. NSString *CellIdentifier = @"OrderDetailPickInfoCell";
  1897. OrderDetailPickInfoCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  1898. NSString *carrier = [item objectForKey:@"delivery_carrier"];
  1899. NSString *web_url = [item objectForKey:@"delivery_web_url"];
  1900. NSString *track_number = [item objectForKey:@"tracking_number"];
  1901. NSString *status = [item objectForKey:@"status"];
  1902. cell.track_number_lb.text = track_number;
  1903. cell.status_lb.text = status;
  1904. cell.carrier_lb.text = carrier;
  1905. cell.url_lb.text = web_url;
  1906. return cell;
  1907. } else if ([item_type isEqualToString:@"order_item"]) { /** Item Info */
  1908. NSString *CellIdentifier = @"OrderDetailModelCell";
  1909. OrderDetailModelCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  1910. NSDictionary * item_json = item;
  1911. // int count = [[item_json valueForKey:@"count"] intValue];
  1912. NSDictionary * combine_json =[item_json objectForKey:@"combine"];
  1913. cell.bundle_item=combine_json;
  1914. NSDictionary * master_json = [item_json objectForKey:@"combine_master"];
  1915. if (cell.masterBtn != nil) {
  1916. if (master_json == nil) {
  1917. cell.masterBtn.hidden = YES;
  1918. } else{
  1919. cell.masterBtn.hidden = NO;
  1920. cell.master_items = master_json;
  1921. }
  1922. }
  1923. double dprice=0.0;
  1924. if(cell.bundle_item!=nil)
  1925. {
  1926. int citem=0;
  1927. int bcount=[[cell.bundle_item valueForKey:@"count"] intValue];
  1928. for(int bc=0;bc<bcount;bc++)
  1929. {
  1930. NSDictionary * bitem = [cell.bundle_item objectForKey:[NSString stringWithFormat:@"item_%d",bc]];
  1931. int modulus= [[bitem valueForKey:@"modulus"] intValue];
  1932. citem+= modulus;
  1933. double uprice= [[bitem valueForKey:@"unit_price"]doubleValue];
  1934. dprice+= uprice*modulus;
  1935. }
  1936. if(citem==1)
  1937. [ cell.buttonBundle setTitle:[NSString stringWithFormat: @"%d bundle item with price of $ %.2f",citem,dprice ]forState:UIControlStateNormal];
  1938. else
  1939. [ cell.buttonBundle setTitle:[NSString stringWithFormat: @"%d bundle items with price of $ %.2f",citem,dprice ]forState:UIControlStateNormal];
  1940. cell.buttonBundle.hidden = NO;
  1941. }
  1942. else
  1943. {
  1944. cell.buttonBundle.hidden = YES;
  1945. }
  1946. NSString* img_url = [item_json valueForKey:@"img"];
  1947. NSString* description = [item_json valueForKey:@"Item Number"];
  1948. NSString* unitprice = [item_json valueForKey:@"The unit price"];
  1949. NSString* origin_price = [item_json valueForKey:@"origin_price"];
  1950. NSString* subtotal = [item_json valueForKey:@"Subtotal"];
  1951. NSString* qty = [item_json valueForKey:@"QTY"];
  1952. NSString* status = [item_json valueForKey:@"order_item_status"];
  1953. NSString* notes = [item_json valueForKey:@"note"];
  1954. if(notes.length>0)
  1955. {
  1956. cell.noteLabel.text = [@"Note: " stringByAppendingString:[notes stringByReplacingOccurrencesOfString:@"\n" withString:@" "]];
  1957. }
  1958. else
  1959. cell.noteLabel.text = nil;
  1960. if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
  1961. {
  1962. }
  1963. else
  1964. {
  1965. unitprice=nil;
  1966. origin_price=nil;
  1967. subtotal=nil;
  1968. }
  1969. float duprice = [unitprice floatValue];
  1970. float dsubtotal = (duprice+dprice)*[qty intValue];
  1971. cell.descriptionLabel.text=description;
  1972. if(dprice>0)
  1973. cell.unitpriceLabel.text = [NSString stringWithFormat:@"%.2f+%.2f",duprice,dprice];//unitprice;
  1974. else
  1975. cell.unitpriceLabel.text = [NSString stringWithFormat:@"%.2f",duprice];//unitprice;
  1976. cell.subtotalLabel.text = [NSString stringWithFormat:@"%.2f",dsubtotal];//subtotal;
  1977. cell.qtyLabel.text = qty;
  1978. cell.statusLabel.text = status;
  1979. cell.labelOldPrice.text = origin_price;
  1980. double discount =[[item_json valueForKey:@"discount"] doubleValue];
  1981. NSString* discountstr=[NSString stringWithFormat:@"%@%% off", [RAUtils FloatFormat:discount]];
  1982. cell.labelDiscount.text = discountstr;
  1983. bool isfree = [[item_json valueForKey:@"is_free"]boolValue];
  1984. if(isfree)
  1985. {
  1986. cell.labelOldPrice.hidden = false;
  1987. cell.labelOldPrice.textColor = [UIColor redColor];
  1988. cell.labelOldPrice.text=@"Free";
  1989. cell.labelOldPrice.hideline = true;
  1990. cell.labelDiscount.hidden = true;
  1991. }
  1992. else
  1993. {
  1994. cell.labelOldPrice.textColor = [UIColor blackColor];
  1995. cell.labelOldPrice.hideline = false;
  1996. if(discount==0)
  1997. {
  1998. cell.labelOldPrice.hidden = true;
  1999. cell.labelDiscount.hidden = true;
  2000. }
  2001. else
  2002. {
  2003. cell.labelOldPrice.hidden = false;
  2004. cell.labelDiscount.hidden = false;
  2005. }
  2006. }
  2007. // Button 设置了大小约束,Size就不会随内容变化
  2008. [cell.imgbtn setContentMode:UIViewContentModeScaleAspectFit];
  2009. [cell.imgbtn setContentEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
  2010. [cell.imgbtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentFill];
  2011. [cell.imgbtn setContentVerticalAlignment:UIControlContentVerticalAlignmentFill];
  2012. cell.imgbtn.imageView.contentMode = UIViewContentModeScaleAspectFit;
  2013. if (![cell.imageName isEqualToString:img_url]) {
  2014. cell.imageName = img_url;
  2015. // [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
  2016. [cell.imgbtn setImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
  2017. NSString* file_name=[img_url lastPathComponent];
  2018. NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
  2019. if(img_data!=nil)
  2020. {
  2021. UIImage * img =[UIImage imageWithData:img_data];
  2022. // [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
  2023. [cell.imgbtn setImage:img forState:UIControlStateNormal];
  2024. }
  2025. else
  2026. {
  2027. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2028. NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  2029. dispatch_async(dispatch_get_main_queue(), ^{
  2030. if(downloadimg_data!=nil)
  2031. {
  2032. [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
  2033. UIImage * img =[UIImage imageWithData:downloadimg_data];
  2034. // [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
  2035. [cell.imgbtn setImage:img forState:UIControlStateNormal];
  2036. }
  2037. else
  2038. // [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
  2039. [cell.imgbtn setImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
  2040. });
  2041. });
  2042. }
  2043. }
  2044. cell.backgroundColor = [UIColor whiteColor];
  2045. return cell;
  2046. }
  2047. } else if ([type isEqualToString:@"price_info"]) { /** Price */
  2048. NSString *CellIdentifier = @"OrderDetailPriceCell";
  2049. OrderDetailPriceCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2050. NSDictionary *data = [section objectForKey:@"data"];
  2051. NSDictionary *item = [data objectForKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]];
  2052. NSString *title = [item objectForKey:@"title"];
  2053. NSString *value = [item objectForKey:@"value"];
  2054. if ([title isEqualToString:@"Sub-Total"] || [title isEqualToString:@"Total"]) {
  2055. if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
  2056. {
  2057. }
  2058. else
  2059. {
  2060. value=nil;
  2061. }
  2062. }
  2063. cell.chargeLabel.text = [title stringByAppendingString:@":"];
  2064. cell.priceLabel.text = value;
  2065. cell.backgroundColor = [UIColor whiteColor];
  2066. return cell;
  2067. }
  2068. #endif
  2069. #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
  2070. /**
  2071. * ver1.90
  2072. */
  2073. NSDictionary *section = [self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",indexPath.section]];
  2074. NSString *type = [section objectForKey:@"type"];
  2075. if ([type isEqualToString:@"order_info"]) {/** Order Info */
  2076. // NSString *CellIdentifier = @"OrderDetailHtmlCell";
  2077. // OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2078. //
  2079. //
  2080. //
  2081. //
  2082. //
  2083. // cell.webview.tag = indexPath.section;
  2084. //
  2085. // cell.webview.delegate = self;
  2086. // // cell.webView.scrollView.contentSize.height = 0;
  2087. // cell.webview.scrollView.bounces=NO;
  2088. // cell.webview.scrollView.directionalLockEnabled = true;
  2089. // CGSize size= cell.webview.scrollView.contentSize;
  2090. // size.height=10;
  2091. // cell.webview.scrollView.contentSize=size;
  2092. //
  2093. // [cell.webview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
  2094. //
  2095. // cell.backgroundColor = [UIColor whiteColor];
  2096. // return cell;
  2097. //
  2098. //
  2099. //
  2100. NSString *CellIdentifier = @"OrderDetailHtmlCell";
  2101. OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2102. cell.html = nil;
  2103. cell.wkwebview.tag = indexPath.section;
  2104. cell.wkwebview.navigationDelegate = self;
  2105. // cell.webView.scrollView.contentSize.height = 0;
  2106. cell.wkwebview.scrollView.bounces=NO;
  2107. cell.wkwebview.scrollView.directionalLockEnabled = true;
  2108. CGSize size= cell.wkwebview.scrollView.contentSize;
  2109. size.height=10;
  2110. cell.wkwebview.scrollView.contentSize=size;
  2111. cell.backgroundColor = [UIColor whiteColor];
  2112. cell.wkwebview.userInteractionEnabled = YES;
  2113. cell.html =[section valueForKey:@"data"];
  2114. NSLog(@"webview loadHTMLString 0");
  2115. [cell.wkwebview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
  2116. NSLog(@"webview loadHTMLString 1");
  2117. return cell;
  2118. } else if ([type isEqualToString:@"sign_url"]) { /** Sign */
  2119. NSString *CellIdentifier = @"OrderDetailSignatureCell";
  2120. OrderDetailSignatureCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2121. NSString* img_url = [section valueForKey:@"data"];
  2122. cell.sign_img.userInteractionEnabled = NO;
  2123. __block BOOL hasTapGesture = NO;
  2124. [cell.sign_img.gestureRecognizers enumerateObjectsUsingBlock:^(__kindof UIGestureRecognizer * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  2125. if ([obj isKindOfClass:[UITapGestureRecognizer class]]) {
  2126. hasTapGesture = YES;
  2127. *stop = YES;
  2128. }
  2129. }];
  2130. if (!hasTapGesture) {
  2131. UITapGestureRecognizer *signatureTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onSignOrderClick:)];
  2132. [cell.sign_img addGestureRecognizer:signatureTap];
  2133. }
  2134. int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
  2135. bool offline_edit =[[self.content_data valueForKey:@"offline_edit"] boolValue];
  2136. if(status_code==1) {
  2137. BOOL condition = offline_edit;
  2138. #ifdef OFFLINE_MODE
  2139. condition = condition || appDelegate.offline_mode==false;
  2140. #else
  2141. condition = YES;
  2142. #endif
  2143. if (condition)
  2144. {
  2145. cell.sign_img.userInteractionEnabled = YES;
  2146. }
  2147. }
  2148. else if(status_code==0) {
  2149. BOOL condition = offline_edit;
  2150. #ifdef OFFLINE_MODE
  2151. condition = condition || appDelegate.offline_mode==false;
  2152. #else
  2153. condition = YES;
  2154. #endif
  2155. if (condition)
  2156. {
  2157. cell.sign_img.userInteractionEnabled = YES;
  2158. }
  2159. }
  2160. NSString* file_name=[img_url lastPathComponent];
  2161. NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
  2162. if(img_data!=nil)
  2163. {
  2164. UIImage * img =[UIImage imageWithData:img_data];
  2165. cell.sign_img.image=img ;
  2166. }
  2167. else
  2168. {
  2169. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2170. NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  2171. dispatch_async(dispatch_get_main_queue(), ^{
  2172. if(downloadimg_data!=nil)
  2173. {
  2174. [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
  2175. UIImage * img =[UIImage imageWithData:downloadimg_data];
  2176. cell.sign_img.image=img ;
  2177. }
  2178. else {
  2179. if (cell.sign_img.userInteractionEnabled) {
  2180. cell.sign_img.image=[UIImage imageNamed:@"taptosign_s"];
  2181. } else {
  2182. cell.sign_img.image = nil;
  2183. }
  2184. }
  2185. });
  2186. });
  2187. }
  2188. cell.backgroundColor = [UIColor whiteColor];
  2189. return cell;
  2190. } else if ([type isEqualToString:@"more_order_info"]) { /** More Info */
  2191. // NSString *CellIdentifier = @"OrderDetailHtmlCell";
  2192. // OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2193. //
  2194. //
  2195. //
  2196. //
  2197. // cell.webview.tag = indexPath.section;
  2198. // cell.webview.delegate = self;
  2199. // // cell.webView.scrollView.contentSize.height = 0;
  2200. // cell.webview.scrollView.bounces=NO;
  2201. // cell.webview.scrollView.directionalLockEnabled = true;
  2202. // CGSize size= cell.webview.scrollView.contentSize;
  2203. // size.height=10;
  2204. // cell.webview.scrollView.contentSize=size;
  2205. //
  2206. //
  2207. //
  2208. // [cell.webview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
  2209. //
  2210. // cell.backgroundColor = [UIColor whiteColor];
  2211. // return cell;
  2212. NSString *CellIdentifier = @"OrderDetailHtmlCell";
  2213. OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2214. cell.wkwebview.tag = indexPath.section;
  2215. cell.wkwebview.navigationDelegate = self;
  2216. // cell.webView.scrollView.contentSize.height = 0;
  2217. cell.wkwebview.scrollView.bounces=NO;
  2218. cell.wkwebview.scrollView.directionalLockEnabled = true;
  2219. CGSize size= cell.wkwebview.scrollView.contentSize;
  2220. size.height=10;
  2221. cell.wkwebview.scrollView.contentSize=size;
  2222. NSLog(@"webview loadHTMLString 3");
  2223. [cell.wkwebview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
  2224. NSLog(@"webview loadHTMLString 4");
  2225. cell.backgroundColor = [UIColor whiteColor];
  2226. return cell;
  2227. } else if ([type isEqualToString:@"sub_order"]) { /** Sub Order */
  2228. NSDictionary *data = [section objectForKey:@"data"];
  2229. NSDictionary *item = [data objectForKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]];
  2230. NSString *item_type = [item objectForKey:@"type"];
  2231. if ([item_type isEqualToString:@"pick_info"]) { /** Pick Info */
  2232. NSString *CellIdentifier = @"OrderDetailPickInfoCell";
  2233. OrderDetailPickInfoCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2234. NSString *carrier = [item objectForKey:@"delivery_carrier"];
  2235. NSString *web_url = [item objectForKey:@"delivery_web_url"];
  2236. NSString *track_number = [item objectForKey:@"tracking_number"];
  2237. NSString *status = [item objectForKey:@"status"];
  2238. cell.track_number_lb.text = track_number;
  2239. cell.status_lb.text = status;
  2240. cell.carrier_lb.text = carrier;
  2241. cell.url_lb.text = web_url;
  2242. return cell;
  2243. } else if ([item_type isEqualToString:@"order_item"]) { /** Item Info */
  2244. NSString *CellIdentifier = @"OrderDetailModelCell";
  2245. OrderDetailModelCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2246. NSDictionary * item_json = item;
  2247. // int count = [[item_json valueForKey:@"count"] intValue];
  2248. NSDictionary * combine_json =[item_json objectForKey:@"combine"];
  2249. cell.bundle_item=combine_json;
  2250. NSDictionary * master_json = [item_json objectForKey:@"combine_master"];
  2251. if (cell.masterBtn != nil) {
  2252. if (master_json == nil) {
  2253. cell.masterBtn.hidden = YES;
  2254. } else{
  2255. cell.masterBtn.hidden = NO;
  2256. cell.master_items = master_json;
  2257. }
  2258. }
  2259. double dprice=0.0;
  2260. if(cell.bundle_item!=nil)
  2261. {
  2262. int citem=0;
  2263. int bcount=[[cell.bundle_item valueForKey:@"count"] intValue];
  2264. for(int bc=0;bc<bcount;bc++)
  2265. {
  2266. NSDictionary * bitem = [cell.bundle_item objectForKey:[NSString stringWithFormat:@"item_%d",bc]];
  2267. int modulus= [[bitem valueForKey:@"modulus"] intValue];
  2268. citem+= modulus;
  2269. double uprice= [[bitem valueForKey:@"unit_price"]doubleValue];
  2270. dprice+= uprice*modulus;
  2271. }
  2272. if(citem==1)
  2273. [ cell.buttonBundle setTitle:[NSString stringWithFormat: @"%d bundle item with price of $ %.2f",citem,dprice ]forState:UIControlStateNormal];
  2274. else
  2275. [ cell.buttonBundle setTitle:[NSString stringWithFormat: @"%d bundle items with price of $ %.2f",citem,dprice ]forState:UIControlStateNormal];
  2276. cell.buttonBundle.hidden = NO;
  2277. }
  2278. else
  2279. {
  2280. cell.buttonBundle.hidden = YES;
  2281. }
  2282. NSString* img_url = [item_json valueForKey:@"img"];
  2283. NSString* description = [item_json valueForKey:@"Item Number"];
  2284. NSString* unitprice = [item_json valueForKey:@"The unit price"];
  2285. NSString* origin_price = [item_json valueForKey:@"origin_price"];
  2286. NSString* subtotal = [item_json valueForKey:@"Subtotal"];
  2287. NSString* qty = [item_json valueForKey:@"QTY"];
  2288. NSString* status = [item_json valueForKey:@"order_item_status"];
  2289. NSString* notes = [item_json valueForKey:@"note"];
  2290. if(notes.length>0)
  2291. {
  2292. cell.noteLabel.text = [@"Note: " stringByAppendingString:[notes stringByReplacingOccurrencesOfString:@"\n" withString:@" "]];
  2293. }
  2294. else
  2295. cell.noteLabel.text = nil;
  2296. if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
  2297. {
  2298. }
  2299. else
  2300. {
  2301. unitprice=nil;
  2302. origin_price=nil;
  2303. subtotal=nil;
  2304. }
  2305. float duprice = [unitprice floatValue];
  2306. float dsubtotal = (duprice+dprice)*[qty intValue];
  2307. cell.descriptionLabel.text=description;
  2308. if(dprice>0)
  2309. cell.unitpriceLabel.text = [NSString stringWithFormat:@"%.2f+%.2f",duprice,dprice];//unitprice;
  2310. else
  2311. cell.unitpriceLabel.text = [NSString stringWithFormat:@"%.2f",duprice];//unitprice;
  2312. cell.subtotalLabel.text = [NSString stringWithFormat:@"%.2f",dsubtotal];//subtotal;
  2313. cell.qtyLabel.text = qty;
  2314. cell.statusLabel.text = status;
  2315. cell.labelOldPrice.text = origin_price;
  2316. double discount =[[item_json valueForKey:@"discount"] doubleValue];
  2317. NSString* discountstr=[NSString stringWithFormat:@"%@%% off", [RAUtils FloatFormat:discount]];
  2318. cell.labelDiscount.text = discountstr;
  2319. bool isfree = [[item_json valueForKey:@"is_free"]boolValue];
  2320. if(isfree)
  2321. {
  2322. cell.labelOldPrice.hidden = false;
  2323. cell.labelOldPrice.textColor = [UIColor redColor];
  2324. cell.labelOldPrice.text=@"Free";
  2325. cell.labelOldPrice.hideline = true;
  2326. cell.labelDiscount.hidden = true;
  2327. }
  2328. else
  2329. {
  2330. cell.labelOldPrice.textColor = [UIColor blackColor];
  2331. cell.labelOldPrice.hideline = false;
  2332. if(discount==0)
  2333. {
  2334. cell.labelOldPrice.hidden = true;
  2335. cell.labelDiscount.hidden = true;
  2336. }
  2337. else
  2338. {
  2339. cell.labelOldPrice.hidden = false;
  2340. cell.labelDiscount.hidden = false;
  2341. }
  2342. }
  2343. // Button 设置了大小约束,Size就不会随内容变化
  2344. [cell.imgbtn setContentMode:UIViewContentModeScaleAspectFit];
  2345. [cell.imgbtn setContentEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
  2346. [cell.imgbtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentFill];
  2347. [cell.imgbtn setContentVerticalAlignment:UIControlContentVerticalAlignmentFill];
  2348. cell.imgbtn.imageView.contentMode = UIViewContentModeScaleAspectFit;
  2349. if (![cell.imageName isEqualToString:img_url]) {
  2350. cell.imageName = img_url;
  2351. // [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
  2352. [cell.imgbtn setImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
  2353. NSString* file_name=[img_url lastPathComponent];
  2354. NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
  2355. if(img_data!=nil)
  2356. {
  2357. UIImage * img =[UIImage imageWithData:img_data];
  2358. // [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
  2359. [cell.imgbtn setImage:img forState:UIControlStateNormal];
  2360. }
  2361. else
  2362. {
  2363. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2364. NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  2365. dispatch_async(dispatch_get_main_queue(), ^{
  2366. if(downloadimg_data!=nil)
  2367. {
  2368. [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
  2369. UIImage * img =[UIImage imageWithData:downloadimg_data];
  2370. // [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
  2371. [cell.imgbtn setImage:img forState:UIControlStateNormal];
  2372. }
  2373. else
  2374. // [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
  2375. [cell.imgbtn setImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
  2376. });
  2377. });
  2378. }
  2379. }
  2380. cell.backgroundColor = [UIColor whiteColor];
  2381. return cell;
  2382. }
  2383. } else if ([type isEqualToString:@"price_info"]) { /** Price */
  2384. NSString *CellIdentifier = @"OrderDetailPriceCell";
  2385. OrderDetailPriceCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2386. NSDictionary *data = [section objectForKey:@"data"];
  2387. NSDictionary *item = [data objectForKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]];
  2388. NSString *title = [item objectForKey:@"title"];
  2389. NSString *value = [item objectForKey:@"value"];
  2390. if ([title isEqualToString:@"Sub-Total"] || [title isEqualToString:@"Total"]) {
  2391. if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
  2392. {
  2393. }
  2394. else
  2395. {
  2396. value=nil;
  2397. }
  2398. }
  2399. cell.chargeLabel.text = [title stringByAppendingString:@":"];
  2400. cell.priceLabel.text = value;
  2401. cell.backgroundColor = [UIColor whiteColor];
  2402. return cell;
  2403. }
  2404. #endif
  2405. #ifdef BUILD_HMLG
  2406. switch(indexPath.section)
  2407. {
  2408. case 0:
  2409. {
  2410. if(indexPath.row==0)
  2411. {
  2412. NSString *CellIdentifier = @"OrderDetailHtmlCell";
  2413. OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2414. cell.html = nil;
  2415. cell.wkwebview.tag = indexPath.section;
  2416. cell.wkwebview.navigationDelegate = self;
  2417. // cell.webView.scrollView.contentSize.height = 0;
  2418. cell.wkwebview.scrollView.bounces=NO;
  2419. cell.wkwebview.scrollView.directionalLockEnabled = true;
  2420. CGSize size= cell.wkwebview.scrollView.contentSize;
  2421. size.height=10;
  2422. cell.wkwebview.scrollView.contentSize=size;
  2423. cell.backgroundColor = [UIColor whiteColor];
  2424. cell.wkwebview.userInteractionEnabled = YES;
  2425. cell.html =[self.content_data valueForKey:@"order_info"];
  2426. [cell.wkwebview loadHTMLString:[self.content_data valueForKey:@"order_info"] baseURL:nil];
  2427. // [cell.wkwebview loadHTMLString:[self.content_data valueForKey:@"order_info"] baseURL:nil];
  2428. // cell.backgroundColor = [UIColor whiteColor];
  2429. return cell;
  2430. //
  2431. // NSString *CellIdentifier = @"OrderDetailHtmlCell";
  2432. // OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2433. //
  2434. // cell.html = nil;
  2435. //
  2436. //
  2437. //
  2438. // cell.wkwebview.tag = indexPath.section;
  2439. //
  2440. // cell.wkwebview.navigationDelegate = self;
  2441. // // cell.webView.scrollView.contentSize.height = 0;
  2442. // cell.wkwebview.scrollView.bounces=NO;
  2443. // cell.wkwebview.scrollView.directionalLockEnabled = true;
  2444. // CGSize size= cell.wkwebview.scrollView.contentSize;
  2445. // size.height=10;
  2446. // cell.wkwebview.scrollView.contentSize=size;
  2447. // cell.backgroundColor = [UIColor whiteColor];
  2448. //
  2449. // cell.wkwebview.userInteractionEnabled = YES;
  2450. //
  2451. // cell.html =[section valueForKey:@"data"];
  2452. // NSLog(@"webview loadHTMLString 0");
  2453. // [cell.wkwebview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
  2454. // NSLog(@"webview loadHTMLString 1");
  2455. //
  2456. // return cell;
  2457. }
  2458. else
  2459. {
  2460. NSString *CellIdentifier = @"OrderDetailSignatureCell";
  2461. OrderDetailSignatureCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2462. NSString* img_url = [self.content_data valueForKey:@"sign_url"];
  2463. cell.sign_img.userInteractionEnabled = NO;
  2464. __block BOOL hasTapGesture = NO;
  2465. [cell.sign_img.gestureRecognizers enumerateObjectsUsingBlock:^(__kindof UIGestureRecognizer * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  2466. if ([obj isKindOfClass:[UITapGestureRecognizer class]]) {
  2467. hasTapGesture = YES;
  2468. *stop = YES;
  2469. }
  2470. }];
  2471. if (!hasTapGesture) {
  2472. UITapGestureRecognizer *signatureTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onSignOrderClick:)];
  2473. [cell.sign_img addGestureRecognizer:signatureTap];
  2474. }
  2475. int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
  2476. bool offline_edit =[[self.content_data valueForKey:@"offline_edit"] boolValue];
  2477. if(status_code==1) {
  2478. BOOL condition = offline_edit;
  2479. #ifdef OFFLINE_MODE
  2480. condition = condition || appDelegate.offline_mode==false;
  2481. #else
  2482. condition = YES;
  2483. #endif
  2484. if (condition)
  2485. {
  2486. cell.sign_img.userInteractionEnabled = YES;
  2487. }
  2488. }
  2489. else if(status_code==0) {
  2490. BOOL condition = offline_edit;
  2491. #ifdef OFFLINE_MODE
  2492. condition = condition || appDelegate.offline_mode==false;
  2493. #else
  2494. condition = YES;
  2495. #endif
  2496. if (condition)
  2497. {
  2498. cell.sign_img.userInteractionEnabled = YES;
  2499. }
  2500. }
  2501. NSString* file_name=[img_url lastPathComponent];
  2502. NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
  2503. if(img_data!=nil)
  2504. {
  2505. UIImage * img =[UIImage imageWithData:img_data];
  2506. cell.sign_img.image=img ;
  2507. }
  2508. else
  2509. {
  2510. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2511. NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  2512. dispatch_async(dispatch_get_main_queue(), ^{
  2513. if(downloadimg_data!=nil)
  2514. {
  2515. [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
  2516. UIImage * img =[UIImage imageWithData:downloadimg_data];
  2517. cell.sign_img.image=img ;
  2518. }
  2519. else {
  2520. if (cell.sign_img.userInteractionEnabled) {
  2521. cell.sign_img.image=[UIImage imageNamed:@"taptosign_s"];
  2522. } else {
  2523. cell.sign_img.image = nil;
  2524. }
  2525. }
  2526. });
  2527. });
  2528. }
  2529. cell.backgroundColor = [UIColor whiteColor];
  2530. return cell;
  2531. }
  2532. }
  2533. break;
  2534. case 1:
  2535. {
  2536. NSString *CellIdentifier = @"OrderDetailHtmlCell";
  2537. OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2538. cell.wkwebview.tag = indexPath.section;
  2539. cell.wkwebview.navigationDelegate = self;
  2540. // cell.webView.scrollView.contentSize.height = 0;
  2541. cell.wkwebview.scrollView.bounces=NO;
  2542. cell.wkwebview.scrollView.directionalLockEnabled = true;
  2543. CGSize size= cell.wkwebview.scrollView.contentSize;
  2544. size.height=10;
  2545. cell.wkwebview.scrollView.contentSize=size;
  2546. NSLog(@"webview loadHTMLString 3");
  2547. [cell.wkwebview loadHTMLString:[self.content_data valueForKey:@"more_order_info"] baseURL:nil];
  2548. NSLog(@"webview loadHTMLString 4");
  2549. cell.backgroundColor = [UIColor whiteColor];
  2550. return cell;
  2551. // cell.webview.tag = indexPath.section;
  2552. // cell.webview.delegate = self;
  2553. // // cell.webView.scrollView.contentSize.height = 0;
  2554. // cell.webview.scrollView.bounces=NO;
  2555. // cell.webview.scrollView.directionalLockEnabled = true;
  2556. // CGSize size= cell.webview.scrollView.contentSize;
  2557. // size.height=10;
  2558. // cell.webview.scrollView.contentSize=size;
  2559. //
  2560. //
  2561. //
  2562. // [cell.webview loadHTMLString:[self.content_data valueForKey:@"more_order_info"] baseURL:nil];
  2563. //
  2564. // cell.backgroundColor = [UIColor whiteColor];
  2565. return cell;
  2566. // { /** More Info */
  2567. //
  2568. // NSString *CellIdentifier = @"OrderDetailHtmlCell";
  2569. // OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2570. //
  2571. //
  2572. //
  2573. //
  2574. // cell.wkwebview.tag = indexPath.section;
  2575. // cell.wkwebview.navigationDelegate = self;
  2576. // // cell.webView.scrollView.contentSize.height = 0;
  2577. // cell.wkwebview.scrollView.bounces=NO;
  2578. // cell.wkwebview.scrollView.directionalLockEnabled = true;
  2579. // CGSize size= cell.wkwebview.scrollView.contentSize;
  2580. // size.height=10;
  2581. // cell.wkwebview.scrollView.contentSize=size;
  2582. //
  2583. //
  2584. //
  2585. // NSLog(@"webview loadHTMLString 3");
  2586. // [cell.wkwebview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
  2587. // NSLog(@"webview loadHTMLString 4");
  2588. //
  2589. // cell.backgroundColor = [UIColor whiteColor];
  2590. // return cell;
  2591. //
  2592. // }
  2593. // NSString *CellIdentifier = @"OrderDetailInfoCell";
  2594. // OrderDetailInfoCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2595. //
  2596. // cell.infoLabel.text =[self.content_data valueForKey:@"more_order_info"];
  2597. //
  2598. //
  2599. //
  2600. //// float width = tableView.frame.size.width;
  2601. //// width-=CELL_MARGIN*2;
  2602. //// CGSize constraintkey = CGSizeMake(width-2*LABEL_MARGIN, 10.0f);//key label width is 40% cell width;
  2603. ////
  2604. //// NSString* key =[self.content_data valueForKey:@"order_info"];
  2605. ////
  2606. ////
  2607. ////
  2608. //// CGRect frame;
  2609. //// frame.size = constraintkey;
  2610. //// frame.origin.x=0;
  2611. //// frame.origin.y=0;
  2612. ////
  2613. //// RTLabel* rtlabel = [[RTLabel alloc] initWithFrame:frame];
  2614. ////
  2615. //// [rtlabel setText: key];
  2616. //// CGSize optimumSize = [rtlabel optimumSize];
  2617. ////
  2618. //// float height = optimumSize.height;
  2619. //// height = MAX(height+LINE_WIDTH+2*LABEL_MARGIN, DEF_CELL_HEIGHT);
  2620. ////
  2621. ////
  2622. //// frame.origin.x=LABEL_MARGIN;
  2623. //// frame.size=CGSizeMake(width, height);
  2624. ////
  2625. //// cell.infoLabel.frame = frame;
  2626. //
  2627. //
  2628. //
  2629. //
  2630. // cell.backgroundColor = [UIColor whiteColor];
  2631. // return cell;
  2632. }
  2633. break;
  2634. case 2:
  2635. {
  2636. NSString *CellIdentifier = @"OrderDetailModelCell";
  2637. OrderDetailModelCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2638. NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  2639. int count = [[item_json valueForKey:@"count"] intValue];
  2640. NSDictionary * combine_json =[item_json objectForKey:@"combine"];
  2641. cell.bundle_item=combine_json;
  2642. NSDictionary * master_json = [item_json objectForKey:@"combine_master"];
  2643. if (cell.masterBtn != nil) {
  2644. if (master_json == nil) {
  2645. cell.masterBtn.hidden = YES;
  2646. } else{
  2647. cell.masterBtn.hidden = NO;
  2648. cell.master_items = master_json;
  2649. }
  2650. }
  2651. double dprice=0.0;
  2652. if(cell.bundle_item!=nil)
  2653. {
  2654. int citem=0;
  2655. int bcount=[[cell.bundle_item valueForKey:@"count"] intValue];
  2656. for(int bc=0;bc<bcount;bc++)
  2657. {
  2658. NSDictionary * bitem = [cell.bundle_item objectForKey:[NSString stringWithFormat:@"item_%d",bc]];
  2659. int modulus= [[bitem valueForKey:@"modulus"] intValue];
  2660. citem+= modulus;
  2661. double uprice= [[bitem valueForKey:@"unit_price"]doubleValue];
  2662. dprice+= uprice*modulus;
  2663. }
  2664. if(citem==1)
  2665. [ cell.buttonBundle setTitle:[NSString stringWithFormat: @"%d bundle item with price of $ %.2f",citem,dprice ]forState:UIControlStateNormal];
  2666. else
  2667. [ cell.buttonBundle setTitle:[NSString stringWithFormat: @"%d bundle items with price of $ %.2f",citem,dprice ]forState:UIControlStateNormal];
  2668. cell.buttonBundle.hidden = NO;
  2669. }
  2670. else
  2671. {
  2672. cell.buttonBundle.hidden = YES;
  2673. }
  2674. NSString* img_url = [item_json valueForKey:@"img"];
  2675. NSString* description = [item_json valueForKey:@"Item Number"];
  2676. // NSString* description = [item_json valueForKey:@"Item Number"];
  2677. NSString* unitprice = [item_json valueForKey:@"The unit price"];
  2678. NSString* origin_price = [item_json valueForKey:@"origin_price"];
  2679. NSString* subtotal = [item_json valueForKey:@"Subtotal"];
  2680. NSString* qty = [item_json valueForKey:@"QTY"];
  2681. NSString* status = [item_json valueForKey:@"order_item_status"];
  2682. NSString* notes = [item_json valueForKey:@"note"];
  2683. if(notes.length>0)
  2684. {
  2685. cell.noteLabel.text = [@"Note: " stringByAppendingString:[notes stringByReplacingOccurrencesOfString:@"\n" withString:@" "]];
  2686. }
  2687. else
  2688. cell.noteLabel.text = nil;
  2689. if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
  2690. {
  2691. }
  2692. else
  2693. {
  2694. unitprice=nil;
  2695. origin_price=nil;
  2696. subtotal=nil;
  2697. }
  2698. float duprice = [unitprice floatValue];
  2699. float dsubtotal = (duprice+dprice)*[qty intValue];
  2700. cell.descriptionLabel.text=description;
  2701. if(dprice>0)
  2702. cell.unitpriceLabel.text = [NSString stringWithFormat:@"%.2f+%.2f",duprice,dprice];//unitprice;
  2703. else
  2704. cell.unitpriceLabel.text = [NSString stringWithFormat:@"%.2f",duprice];//unitprice;
  2705. cell.subtotalLabel.text = [NSString stringWithFormat:@"%.2f",dsubtotal];//subtotal;
  2706. cell.qtyLabel.text = qty;
  2707. cell.statusLabel.text = status;
  2708. cell.labelOldPrice.text = origin_price;
  2709. double discount =[[item_json valueForKey:@"discount"] doubleValue];
  2710. NSString* discountstr=[NSString stringWithFormat:@"%@%% off", [RAUtils FloatFormat:discount]];
  2711. cell.labelDiscount.text = discountstr;
  2712. bool isfree = [[item_json valueForKey:@"is_free"]boolValue];
  2713. if(isfree)
  2714. {
  2715. cell.labelOldPrice.hidden = false;
  2716. cell.labelOldPrice.textColor = [UIColor redColor];
  2717. cell.labelOldPrice.text=@"Free";
  2718. cell.labelOldPrice.hideline = true;
  2719. cell.labelDiscount.hidden = true;
  2720. }
  2721. else
  2722. {
  2723. cell.labelOldPrice.textColor = [UIColor blackColor];
  2724. cell.labelOldPrice.hideline = false;
  2725. if(discount==0)
  2726. {
  2727. cell.labelOldPrice.hidden = true;
  2728. cell.labelDiscount.hidden = true;
  2729. }
  2730. else
  2731. {
  2732. cell.labelOldPrice.hidden = false;
  2733. cell.labelDiscount.hidden = false;
  2734. }
  2735. }
  2736. // Button 设置了大小约束,Size就不会随内容变化
  2737. [cell.imgbtn setContentMode:UIViewContentModeScaleAspectFit];
  2738. [cell.imgbtn setContentEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
  2739. [cell.imgbtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentFill];
  2740. [cell.imgbtn setContentVerticalAlignment:UIControlContentVerticalAlignmentFill];
  2741. cell.imgbtn.imageView.contentMode = UIViewContentModeScaleAspectFit;
  2742. if (![cell.imageName isEqualToString:img_url]) {
  2743. cell.imageName = img_url;
  2744. // [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
  2745. [cell.imgbtn setImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
  2746. NSString* file_name=[img_url lastPathComponent];
  2747. NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
  2748. if(img_data!=nil)
  2749. {
  2750. UIImage * img =[UIImage imageWithData:img_data];
  2751. // [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
  2752. [cell.imgbtn setImage:img forState:UIControlStateNormal];
  2753. }
  2754. else
  2755. {
  2756. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2757. NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  2758. dispatch_async(dispatch_get_main_queue(), ^{
  2759. if(downloadimg_data!=nil)
  2760. {
  2761. [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
  2762. UIImage * img =[UIImage imageWithData:downloadimg_data];
  2763. // [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
  2764. [cell.imgbtn setImage:img forState:UIControlStateNormal];
  2765. }
  2766. else
  2767. // [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
  2768. [cell.imgbtn setImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
  2769. });
  2770. });
  2771. }
  2772. }
  2773. cell.backgroundColor = [UIColor whiteColor];
  2774. return cell;
  2775. }
  2776. break;
  2777. case 3:
  2778. {
  2779. NSString *CellIdentifier = @"OrderDetailPriceCell";
  2780. OrderDetailPriceCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2781. switch (indexPath.row) {
  2782. case 0:
  2783. {
  2784. cell.chargeLabel.text =@"Sub-Total:";
  2785. NSString* price=[self.content_data valueForKey:@"Sub-Total"];
  2786. if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
  2787. {
  2788. }
  2789. else
  2790. {
  2791. price=nil;
  2792. }
  2793. cell.priceLabel.text =price;
  2794. break;
  2795. }
  2796. case 1:
  2797. cell.chargeLabel.text = @"Shipping:";
  2798. cell.priceLabel.text =[self.content_data valueForKey:@"Shipping"];
  2799. break;
  2800. case 2: {
  2801. #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
  2802. cell.chargeLabel.text = @"Liftgate Fee(No loading dock):";
  2803. cell.priceLabel.text =[self.content_data valueForKey:@"Liftgate Fee(No loading dock)"];
  2804. #endif
  2805. #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
  2806. cell.chargeLabel.text = @"Liftgate Fee(No loading dock):";
  2807. cell.priceLabel.text =[self.content_data valueForKey:@"Liftgate Fee(No loading dock)"];
  2808. #endif
  2809. #ifdef BUILD_HMLG
  2810. cell.chargeLabel.text = @"Tax:";
  2811. NSString *tax = [self.content_data valueForKey:@"Tax"] ? [self.content_data valueForKey:@"Tax"] : @"$0.00";
  2812. cell.priceLabel.text = tax;
  2813. #endif
  2814. }
  2815. break;
  2816. case 3: {
  2817. #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
  2818. cell.chargeLabel.text = @"Handling Fee:";
  2819. cell.priceLabel.text =[self.content_data valueForKey:@"Handling Fee"];
  2820. #endif
  2821. #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
  2822. cell.chargeLabel.text = @"Handling Fee:";
  2823. cell.priceLabel.text =[self.content_data valueForKey:@"Handling Fee"];
  2824. #endif
  2825. #ifdef BUILD_HMLG
  2826. NSString* price=[self.content_data valueForKey:@"Total"];
  2827. if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
  2828. {
  2829. }
  2830. else
  2831. {
  2832. price=nil;
  2833. }
  2834. cell.chargeLabel.text = @"Total:";
  2835. cell.priceLabel.text =price;
  2836. #endif
  2837. }
  2838. break;
  2839. case 4: {
  2840. cell.chargeLabel.text = @"Tax:";
  2841. NSString *tax = [self.content_data valueForKey:@"Tax"] ? [self.content_data valueForKey:@"Tax"] : @"$0.00";
  2842. cell.priceLabel.text = tax;
  2843. }
  2844. break;
  2845. case 5:
  2846. {
  2847. NSString* price=[self.content_data valueForKey:@"Total"];
  2848. if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
  2849. {
  2850. }
  2851. else
  2852. {
  2853. price=nil;
  2854. }
  2855. cell.chargeLabel.text = @"Total:";
  2856. cell.priceLabel.text =price;
  2857. break;
  2858. }
  2859. default:
  2860. break;
  2861. }
  2862. cell.backgroundColor = [UIColor whiteColor];
  2863. return cell;
  2864. }
  2865. }
  2866. #endif
  2867. return nil;
  2868. // if(tableView==self.itemListTable)
  2869. // {
  2870. // NSString *CellIdentifier = @"CartItemCell";
  2871. // ModelItemCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2872. // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  2873. // NSDictionary * combine_json =[item_json objectForKey:@"combine"];
  2874. //
  2875. // cell.bundle_item=combine_json;
  2876. // NSString* img_url = [item_json valueForKey:@"img_url"];
  2877. // NSString* description = [item_json valueForKey:@"description"];
  2878. // // NSString* identifier = [item_json valueForKey:@"identifier"];
  2879. // // NSString* attribute = [item_json valueForKey:@"attribute"];
  2880. // NSString* currency = [item_json valueForKey:@"currency"];
  2881. // int count =[[item_json valueForKey:@"count"] intValue];
  2882. //
  2883. // int stockUom =[[item_json valueForKey:@"stockUom"] intValue];
  2884. //
  2885. // double totalprice =[[item_json valueForKey:@"subtotal_price"] doubleValue];
  2886. //
  2887. // double unitprice=[[item_json valueForKey:@"unit_price"] doubleValue];
  2888. // cell.unit_price = unitprice;
  2889. // // cell.labelAttribute.text = attribute;
  2890. // // cell.labelCurrency.text = currency;
  2891. // cell.labelDescription.text = description;
  2892. // // cell.labelIdentifier.text = identifier;
  2893. // cell.labelPrice.text = [NSString stringWithFormat:@"%.2f",totalprice];
  2894. //
  2895. // cell.labelUnitPrice.text = [NSString stringWithFormat:@"%.2f",unitprice];
  2896. //
  2897. //
  2898. //
  2899. // NSString* cart_item_id= [item_json valueForKey:@"cart_item_id"];
  2900. // cell.cart_id = cart_item_id;
  2901. // [cell init_Stepper:stockUom max:9999 min:stockUom value:count];
  2902. //
  2903. //
  2904. //
  2905. // [cell set_Count:count];
  2906. //
  2907. // NSString* file_name=[img_url lastPathComponent];
  2908. // NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
  2909. // if(img_data!=nil)
  2910. // {
  2911. //
  2912. // UIImage * img =[UIImage imageWithData:img_data];
  2913. // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
  2914. // }
  2915. // else
  2916. // {
  2917. //
  2918. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2919. //
  2920. // NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  2921. //
  2922. // dispatch_async(dispatch_get_main_queue(), ^{
  2923. //
  2924. //
  2925. //
  2926. // if(downloadimg_data!=nil)
  2927. // {
  2928. // [iSalesDB cache_img:downloadimg_data :file_name ];
  2929. //
  2930. // UIImage * img =[UIImage imageWithData:downloadimg_data];
  2931. // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
  2932. // }
  2933. //
  2934. // });
  2935. // });
  2936. //
  2937. //
  2938. // }
  2939. // return cell;
  2940. // }
  2941. // else
  2942. // {
  2943. // NSString *CellIdentifier = @"OrderInfoListItem";
  2944. // UITableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  2945. // return cell;
  2946. // }
  2947. }
  2948. //#pragma mark - UIAlertViewDelegate
  2949. //// Called when a button is clicked. The view will be automatically dismissed after this call returns
  2950. //- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  2951. //{
  2952. //
  2953. // if(buttonIndex!=alertView.cancelButtonIndex)
  2954. // {
  2955. // [self copyOrder];
  2956. // }
  2957. //}
  2958. - (void)copyOrder {
  2959. UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Copy Order"];
  2960. [RANetwork request_copy_order:self.order_code completionHandler:^(NSMutableDictionary *result) {
  2961. NSDictionary* order_json = result;
  2962. [waitalert dismissViewControllerAnimated:YES completion:nil];
  2963. if([[order_json valueForKey:@"result"] intValue]==2)
  2964. {
  2965. // NSString* orderCode = [order_json valueForKey:@"orderCode"];
  2966. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2967. // if([appDelegate.order_code isEqualToString: self.order_code])
  2968. // {
  2969. // [appDelegate closeOrder];
  2970. //// appDelegate.order_code= nil;
  2971. // [appDelegate SetSo:nil];
  2972. //
  2973. //
  2974. // }
  2975. [RAUtils message_alert:[NSString stringWithFormat:@"New order SO#: %@",[order_json valueForKey:@"so_id"]] title:@"Copy successful." controller:self];
  2976. // 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];
  2977. //
  2978. // [alert show];
  2979. //
  2980. #ifdef RA_NOTIFICATION
  2981. [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  2982. #else
  2983. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2984. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  2985. #endif
  2986. [self.navigationController popViewControllerAnimated:false];
  2987. }
  2988. else
  2989. {
  2990. [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Cpoy Order" controller:self] ;
  2991. }
  2992. }];
  2993. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2994. //
  2995. // NSDictionary* order_json = [RANetwork copy_Order:self.order_code];
  2996. //
  2997. // dispatch_async(dispatch_get_main_queue(), ^{
  2998. // [waitalert dismissViewControllerAnimated:YES completion:nil];
  2999. // if([[order_json valueForKey:@"result"] intValue]==2)
  3000. // {
  3001. // // NSString* orderCode = [order_json valueForKey:@"orderCode"];
  3002. //
  3003. // // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3004. // // if([appDelegate.order_code isEqualToString: self.order_code])
  3005. // // {
  3006. // // [appDelegate closeOrder];
  3007. // //// appDelegate.order_code= nil;
  3008. // // [appDelegate SetSo:nil];
  3009. // //
  3010. // //
  3011. // // }
  3012. // 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];
  3013. //
  3014. // [alert show];
  3015. //
  3016. //
  3017. //
  3018. //#ifdef RA_NOTIFICATION
  3019. // [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  3020. //#else
  3021. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3022. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  3023. //#endif
  3024. //
  3025. // [self.navigationController popViewControllerAnimated:false];
  3026. //
  3027. // }
  3028. // else
  3029. // {
  3030. // [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Cpoy Order" controller:self] ;
  3031. // }
  3032. //
  3033. //
  3034. //
  3035. // });
  3036. // });
  3037. }
  3038. - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
  3039. {
  3040. // message.body -- Allowed types are NSNumber, NSString, NSDate, NSArray,NSDictionary, and NSNull.
  3041. NSLog(@"%@",message.name);
  3042. NSLog(@"body:%@",message.body);
  3043. }
  3044. #pragma mark - WKNavigationDelegate
  3045. - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
  3046. {
  3047. NSLog(@"webview didFinishNavigation");
  3048. // [webView evaluateJavaScript:@"document.documentElement.outerHTML.toString()" completionHandler:^(id _Nullable html ,NSError * _Nullable error) {
  3049. //
  3050. // NSLog(html);
  3051. // }];
  3052. UITableViewCell *cell = (UITableViewCell *)[[webView superview] superview];
  3053. NSIndexPath *indexPath = [self.detailTable indexPathForCell:cell];
  3054. if(indexPath==nil)
  3055. {//for ios7
  3056. cell = (UITableViewCell *) webView.superview.superview.superview;
  3057. indexPath = [self.detailTable indexPathForCell:cell];
  3058. }
  3059. if(indexPath==nil)
  3060. return;
  3061. float height= 0;
  3062. if(indexPath.section==0)
  3063. height=self.web_info_height;
  3064. else
  3065. height = self.web_moreinfo_height;
  3066. if(height>0)
  3067. return;
  3068. // UIScrollView *scrollerView = [webView.subviews objectAtIndex:0];
  3069. // CGSize size= webView.scrollView.contentSize;
  3070. // CGSize fittingSize = [webView sizeThatFits:CGSizeZero];
  3071. [webView evaluateJavaScript:@"document.body.scrollHeight;" completionHandler:^(id _Nullable fitHeight,NSError * _Nullable error) {
  3072. NSLog(@"webview evaluateJavaScript");
  3073. CGRect frame = webView.frame;
  3074. if(height==[fitHeight floatValue])
  3075. {
  3076. NSLog(@"webview return no need reload table");
  3077. return;
  3078. }
  3079. frame.size.height = [fitHeight floatValue];
  3080. //webView.frame = frame;
  3081. // DebugLog(@"webViewDidFinishLoad ^^^^^^^^^^^^^^^^^Saveheight height=%f section=%ld",webView.scrollView.contentSize.height,indexPath.section);
  3082. if(indexPath.section==0)
  3083. self.web_info_height=frame.size.height;
  3084. else
  3085. self.web_moreinfo_height = frame.size.height;
  3086. // [self.content.webviewHeight setObject:[NSString stringWithFormat:@"%f",frame.size.height/*webView.scrollView.contentSize.height*/] forKey:[NSString stringWithFormat:@"%ld",(long)indexPath.section]];
  3087. NSLog(@"webview need call table reload");
  3088. dispatch_async(dispatch_get_main_queue(), ^{
  3089. NSLog(@"reload tableview!!! %f",frame.size.height);
  3090. // UI更新代码
  3091. // [self.detailTable reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
  3092. // [self.detailTable reloadData];
  3093. [self.detailTable reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationNone];
  3094. // [self performSelector:@selector(rtable) withObject:nil afterDelay:1];
  3095. //[self.editorTable reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
  3096. });
  3097. }];
  3098. //
  3099. // NSString *fitHeight = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight;"];
  3100. //
  3101. // [self.table beginUpdates];
  3102. // [self.table endUpdates];
  3103. // [self.webviewoprationQueue addOperationWithBlock:^{
  3104. // }];
  3105. // [self.table endUpdates];
  3106. // }
  3107. }
  3108. //-(void) rtable
  3109. //{
  3110. // [self.detailTable reloadData];
  3111. //}
  3112. ////禁止链接跳转
  3113. //- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
  3114. //
  3115. // NSLog(@"%s",__func__);
  3116. // NSLog(@"navigationAction = %@, \r!!!!!!!!!!!!!!!!!!!!!!\n request = %@",navigationAction,navigationAction.request.URL);
  3117. //
  3118. //// NSString *url = navigationAction.request.URL.absoluteString;
  3119. //// if (![url containsString:[NSBundle mainBundle].bundleURL.absoluteString]) {
  3120. //// self.url = url;
  3121. //// }
  3122. //
  3123. //
  3124. //
  3125. //
  3126. //
  3127. //
  3128. // if (navigationAction.navigationType != WKNavigationTypeLinkActivated ) {
  3129. // return decisionHandler(WKNavigationActionPolicyAllow);
  3130. // }
  3131. //
  3132. // if ([[UIApplication sharedApplication] canOpenURL:navigationAction.request.URL]) {
  3133. // [[UIApplication sharedApplication] openURL:navigationAction.request.URL];
  3134. // }
  3135. //
  3136. // return decisionHandler(WKNavigationActionPolicyCancel);
  3137. //}
  3138. #pragma mark - web view delegate
  3139. - (void)reRefreshView {
  3140. [self.detailTable reloadData];
  3141. }
  3142. #pragma mark - RA_NOTIFICAITON
  3143. -(void) refresh_ui
  3144. {
  3145. [self.detailTable reloadData];
  3146. }
  3147. -(void) reload_data
  3148. {
  3149. UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
  3150. [reF endRefreshing];
  3151. reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
  3152. [self loaddata];
  3153. }
  3154. -(void) refresh_price
  3155. {
  3156. [self refresh_ui];
  3157. }
  3158. @end