OrderDetailViewController.m 157 KB

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