| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464 |
- //
- // OrderDetailViewController.m
- // RedAnt ERP Mobile
- //
- // Created by Ray on 8/28/15.
- // Copyright (c) 2015 United Software Applications, Inc. All rights reserved.
- //
- #import "OrderDetailViewController.h"
- #import "OrderDetailInfoCell.h"
- #import "OrderDetailHtmlCell.h"
- #import "OrderDetailModelCell.h"
- #import "OrderDetailPriceCell.h"
- #import "OrderDetailSignatureCell.h"
- #import "RANetwork.h"
- #import "RTLabel.h"
- #import "DetailViewController.h"
- #import "RAPDFViewController.h"
- #import "SignatureViewController.h"
- #import "MainViewController.h"
- //#import "AFHTTPSessionManager.h"
- #import "DefaultAppearance.h"
- #import "DefaultTableHeaderView.h"
- #import "OLDataProvider.h"
- #import "OrderDetailPickInfoCell.h"
- #define DEF_CELL_HEIGHT 44
- #define DEF_TABLE_HEIGHT 44
- #define LINE_WIDTH 0
- #define CELL_MARGIN 0
- #define LABEL_MARGIN 15
- @interface OrderDetailViewController ()
- @property (nonatomic,assign) BOOL showModels;
- @end
- @implementation OrderDetailViewController
- - (void)saleOrderWithPath:(NSString *)path {
-
- RAPDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
-
- ViewController.url = path;
- ViewController.canSave = false;
- ViewController.isLocalfile=YES;
- NSString* subject;
-
- subject =[NSString stringWithFormat:@"Sales Order %@",self.order_code];
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- NSString* customer_email= [appDelegate.customerInfo valueForKey:@"customer_email"];
-
-
- NSMutableArray* send_to = [[NSMutableArray alloc]init];
- if(customer_email.length>0)
- {
- send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
- }
- ViewController.mail_to = send_to;
- ViewController.filename = [NSString stringWithFormat:@"%@.pdf",self.order_code];
- ViewController.mail_subject = subject;
-
- ViewController.hidenavi = false;
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- -(void) reload_container_getdata:(bool) update_data
- {
-
- [super reload_container_getdata:update_data];
- if(update_data)
- [self reload_data];
- else
- {
- [self.detailTable reloadData];
-
- }
- }
- - (void)onBackClick:(UIButton *)sender {
-
-
- [self.navigationController popViewControllerAnimated:FALSE];
- }
- -(void)manually_refresh
- {
- UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
-
- if(self.isrefreshing)
- {
- [reF endRefreshing];
- return;
- }
- reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Refreshing"];
-
-
- if ([self respondsToSelector:@selector(reload_data)])
- [self performSelector:@selector(reload_data) withObject:nil afterDelay:1];
- // DebugLog(@"refresh!!!!!!!!");
-
- }
- -(void) reload_data
- {
-
- UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
-
- [reF endRefreshing];
-
- reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
-
- [self loaddata];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
-
-
- self.label_net_err.layer.borderColor = [UIColor darkGrayColor].CGColor;
- self.label_net_err.layer.borderWidth = 2.0;
- self.label_net_err.layer.cornerRadius=15;
- self.label_net_err.layer.masksToBounds=true;
-
- self.showModels = YES;
-
-
-
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(refresh_btn_click:)];
- // tap.minimumPressDuration = 0.8; //定义按的时间
- [self.label_net_err addGestureRecognizer:tap];
-
-
-
- UIRefreshControl *ref = [[UIRefreshControl alloc]init];
- ref.tag = 200 ;
- ref.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
- ref.tintColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
- // ref.hidden = true;
- [ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged];
- [self.detailTable addSubview:ref];
-
-
- NSMutableArray * items = [[NSMutableArray alloc]init];
-
-
- self.navigationItem.title=@"View Order Detail";
-
-
-
-
- UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector( onBackClick:)];
-
- // closeButton.tintColor = UIColorFromRGB(0x996633);
-
-
-
- self.navigationItem.leftBarButtonItem = closeButton;
-
-
-
- self.btnOpen = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(onOpenOrderClick:)];//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onOpenOrderClick:)];
-
- // self.btnOpen.tintColor = UIColorFromRGB(0x996633);
-
-
-
- self.btnSign = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"signature"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(onSignOrderClick:)];//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onOpenOrderClick:)];
-
- // self.btnSign.tintColor = UIColorFromRGB(0x996633);
-
-
- self.btnCopy =[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"copy"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(onCopyOrderClick:)];// [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Commit", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCommitOrderClick:)];
-
- // self.btnCopy.tintColor = UIColorFromRGB(0x996633);
-
- // self.btnSend = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Email", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onSendMailClick:)];
-
-
-
- self.btnRelease = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"unlock"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(onReleaseOrderClick:)];
- // self.btnRelease.tintColor = UIColorFromRGB(0x996633);
-
- self.btnPDF = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"mail"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(onDownloadOrderClick:)];//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Download", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onDownloadOrderClick:)];
-
-
- // self.btnPDF.tintColor = UIColorFromRGB(0x996633);
-
- // UIBarButtonItem *item1 = [[UIBarButtonItem alloc] init];
- // item1.title = @"item1";
- //// item1.image = [UIImage imageNamed:@"rect_setting"];
- // UIBarButtonItem *item2 = [[UIBarButtonItem alloc] init];
- //// item2.image = [UIImage imageNamed:@"rect_about"];
- // item2.title = @"item2";
-
- // UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
- // fixedItem.width = 0.0f;
- AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
- [items addObject:self.btnOpen];
- // [items addObject:fixedItem];
- // [items addObject:self.btnCommit];
- // [items addObject:fixedItem];
- if (appDelegate.user_type != USER_ROLE_CUSTOMER) {
- [items addObject:self.btnRelease];
- }
- // [items addObject:fixedItem];
- [items addObject:self.btnPDF];
- // [items addObject:fixedItem];
- [items addObject:self.btnSign];
- // [items addObject:fixedItem];
- if (appDelegate.user_type != USER_ROLE_CUSTOMER) {
- [items addObject:self.btnCopy];
- }
-
- // [items addObject:item2];
- self.navigationItem.rightBarButtonItems=items;
-
- self.btnOpen.enabled =false;
- self.btnSign.enabled = false;
-
- self.btnCopy.enabled =false;
- self.btnPDF.enabled =false;
- self.btnRelease.enabled =false;
- // if(self.isTempOrder)
- // {
- //
- //
- // self.btnOpen.enabled =true;
- //
- //
- // self.btnCommit.enabled =true;
- // }
- // else
- // {
- //
- // [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
- //
- // [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
- // self.btnOpen.enabled =false;
- // self.btnCommit.enabled =false;
- // }
- // Do any additional setup after loading the view.
-
-
- // [self loaddata];
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- }
- - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
- // self.web_info_height = 0;
- //
- // [self.detailTable.indexPathsForVisibleRows enumerateObjectsUsingBlock:^(NSIndexPath * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- //
- // if (obj.section == 0 && obj.section == 0) {
- // [self.detailTable reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic];
- // }
- //
- // }];
-
-
- }
- - (IBAction)onReleaseOrderClick:(id)sender {
-
-
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Are you sure to release order?" message:nil preferredStyle:UIAlertControllerStyleAlert];
- //block代码块取代了delegate
-
-
-
- UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Release Order"];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* order_json = [RANetwork release_Order:self.order_code withScreen:ScreenCodeOrderInfo];
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- if([[order_json valueForKey:@"result"] intValue]==2)
- {
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // appDelegate.order_code = nil;
- [appDelegate closeOrder];
-
- // appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
- //
- // appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
- // if(self.selectOrder)
- // self.selectOrder();
- [self.navigationController popToRootViewControllerAnimated:false];
-
- }
- else
- {
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
- }
-
-
-
- });
- });
-
- }];
-
- UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
- DebugLog(@"Cancel");
- }];
- [alertControl addAction:actionOne];
-
- [alertControl addAction:alertthree];
-
- //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
-
-
- [self presentViewController:alertControl animated:YES completion:nil];
-
-
-
-
-
- // get customer info
-
-
-
-
- }
- - (void)onDownloadOrderClick:(id)sender {
- __weak typeof(self) weakself = self;
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- RAPDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
-
- ViewController.mail_content = [self.content_data valueForKey:@"email_content"];
-
- NSString* so = [self.content_data valueForKey:@"so#"];
- if(so==nil)
- so =@"";
-
- NSString* company = [self.content_data[@"customerInfo"] valueForKey:@"customer_name"];
- if(company==nil)
- company =@"";
-
-
- ViewController.save_name =so;
- ViewController.hidenavi = false;
- if(company==nil)
- company=@"";
- NSString* customer_email= [self.content_data[@"customerInfo"] valueForKey:@"customer_email"];
- // NSMutableArray* arr_subject = [[NSMutableArray alloc]init];
-
- // if(company.length>0)
- // [arr_subject addObject:company];
- // if(so.length>0)
- // [arr_subject addObject:so];
-
- if(company.length==0)
- company=@"";
- if(so.length==0)
- so=@"";
-
- NSMutableArray* send_to = [[NSMutableArray alloc]init];
- if(customer_email.length>0)
- {
- send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
- // customer_email compo
- // [send_to addObject:customer_email];
- }
- ViewController.mail_to = send_to;
- NSString* subject = nil;
-
- #ifdef BUILD_NPD
- subject=[NSString stringWithFormat:@"%@ -- SO# %@ from NEW PACIFIC DIRECT,INC.",company,so];
-
- if (appDelegate.user_type == USER_ROLE_CUSTOMER&&self.is_shoporder) {
- NSString *companyName = [appDelegate.customerInfo objectForKey:@"customer_name"];
- subject=[NSString stringWithFormat:@"%@ -- SO# %@ from %@",company,so,companyName];
- }
- #endif
-
- #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
- subject=[NSString stringWithFormat:@"%@ -- SO# %@ from %@",company,so,COMPANY_NAME];
-
- if (appDelegate.user_type == USER_ROLE_CUSTOMER&&self.is_shoporder) {
- NSString *companyName = [appDelegate.customerInfo objectForKey:@"customer_name"];
- subject=[NSString stringWithFormat:@"%@ -- SO# %@ from %@",company,so,companyName];
- }
- #endif
-
-
- #ifdef BUILD_HMLG
-
- subject=[NSString stringWithFormat:@"%@ -- SO# %@ from Homelegance.",company,so];
-
- #endif
-
- ViewController.mail_subject = subject;
-
- int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
-
- NSString *alertTitle = @"View Sales Order:";
- if(appDelegate.user_type==USER_ROLE_CUSTOMER&&self.is_shoporder&& (status_code==1 /*||status_code==0*/||status_code==30)) {
- alertTitle = @"View Store Order";
- }
-
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:alertTitle message:nil preferredStyle:UIAlertControllerStyleAlert];
- //block代码块取代了delegate
-
-
-
- UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"With Thumbnails" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
- #ifdef OFFLINE_MODE
- if(appDelegate.offline_mode)
- {
- NSMutableDictionary* params = [@{
- @"thumb" : @"1",
- @"order_code" : self.order_code,
- } mutableCopy];
- NSData *dicData = [OLDataProvider offline_request_salesorder:params];
- NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:dicData options:NSJSONReadingMutableContainers error:nil];
- if ([dic[@"result"] integerValue] == RESULT_TRUE) {
- NSString *path = dic[@"pdf_path"];
- [weakself saleOrderWithPath:path];
- // ViewController.url = path;
- // ViewController.isLocalfile = YES;
- //
- // [self.navigationController pushViewController:ViewController animated:YES];
- } else {
- [RAUtils message_alert:@"Sales Order Open Failed" title:@"Message" controller:weakself];
- }
- }
- else
- #endif
- {
- NSString* url=[self.content_data valueForKey:@"pdfUrl"];
-
-
- url= [url stringByAppendingString:@"&has_item_pic=true"];
- DebugLog(@"pdf url:%@",url);
-
- ViewController.url = url;
-
- [self.navigationController pushViewController:ViewController animated:YES];
- }
-
- }];
-
-
- NSString* alertthreetitle=@"Without Thumbnails";
- if(appDelegate.user_type==USER_ROLE_CUSTOMER&&self.is_shoporder&& (status_code==1 /*||status_code==0*/||status_code==30))
- {
- alertthreetitle=@"Print Quotation";
- }
- UIAlertAction *alertthree = [UIAlertAction actionWithTitle:alertthreetitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
- #ifdef OFFLINE_MODE
- if(appDelegate.offline_mode)
- {
- NSMutableDictionary* params = [@{
- @"thumb" : @"0",
- @"order_code" : self.order_code,
- } mutableCopy];
- NSData *dicData = [OLDataProvider offline_request_salesorder:params];
- NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:dicData options:NSJSONReadingMutableContainers error:nil];
- if ([dic[@"result"] integerValue] == RESULT_TRUE) {
- NSString *path = dic[@"pdf_path"];
- [weakself saleOrderWithPath:path];
- // ViewController.url = path;
- // ViewController.isLocalfile = YES;
- //
- // [self.navigationController pushViewController:ViewController animated:YES];
- } else {
-
- [RAUtils message_alert:@"Sales Order Open Failed" title:@"Message" controller:weakself];
-
- }
- }
- else
- #endif
- {
- NSString* url=[self.content_data valueForKey:@"pdfUrl"];
- DebugLog(@"pdf url:%@",url);
- ViewController.url = url;
-
- [self.navigationController pushViewController:ViewController animated:YES];
- }
-
- }];
-
-
- UIAlertAction *alertCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {}];
-
-
- if(appDelegate.user_type==USER_ROLE_CUSTOMER&&self.is_shoporder&& (status_code==1 /*||status_code==0*/||status_code==30))//[status isEqualToString:@"Saved Order"])
- {
- [alertControl addAction:alertthree];
- [alertControl addAction:alertCancel];
- }
- else
- {
- [alertControl addAction:actionOne];
-
- [alertControl addAction:alertthree];
- [alertControl addAction:alertCancel];
- }
-
-
- //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
-
-
- [self presentViewController:alertControl animated:YES completion:nil];
-
-
-
- // get customer info
-
- //
-
-
-
-
-
-
- }
- - (void)onCopyOrderClick:(id)sender {
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.order_code) {
-
- __weak typeof(self) weakself = self;
- 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];
-
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
-
- UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Release Order"];
-
- dispatch_async(dispatch_get_global_queue(0, 0), ^{
-
- NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:ScreenCodeOrderInfo];
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- if([[order_json valueForKey:@"result"] intValue]==2)
- {
- [appDelegate closeOrder];
-
- [weakself copyOrder];
-
- } else {
-
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Release Order" controller:weakself] ;
- }
- });
-
- });
-
- }];
-
- [alertVC addAction:cancelAction];
- [alertVC addAction:yesAction];
-
- [self presentViewController:alertVC animated:YES completion:nil];
-
- } else {
-
- 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];
- [alert show];
-
- }
-
-
-
-
- }
- //- (void)onCommitOrderClick:(id)sender {
- // // get customer info
- //
- // int model_count = [[self.content_data valueForKey:@"model_count"] intValue];
- // if(model_count==0)
- // {
- //// UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Error." message:@"Can not submit an order without models." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- ////
- //// [alert show];
- //
- //
- // [RAUtils alert_view:@"Cannot submit an order without models" title:@""];
- // }
- //
- // else
- // {
- //
- // 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];
- // [alert show];
- //
- // }
- //
- //
- //}
- -(void) upload_img :(UIImage*) img
- {
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- #ifdef OFFLINE_MODE
- if(appDelegate.offline_mode)
- {
-
- NSData *data = [OLDataProvider offline_saveBusinesscard:UIImagePNGRepresentation(img)];;
-
- // 再将NSData转为字符串
- NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
-
- // NSMutableString *str = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
-
- DebugLog(@"data string: %@",jsonStr);
- NSError *error=nil;
- NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error];
-
-
-
- if([[json valueForKey:@"result"] intValue]==2)
- {
- NSString* img_url_down = json[@"img_url_aname"];
- NSString* img_url_up = json[@"img_url"];
-
- {
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Signature"];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* order_json = [RANetwork sign_Order:self.order_code path:img_url_up];
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- if([[order_json valueForKey:@"result"] intValue]==2)
- {
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // appDelegate.order_code = self.order_code;
- // [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
- //
- //
- // appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
- //
- // appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
- // [self.navigationController popViewControllerAnimated:false];
- //
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- // if(self.selectOrder)
- // self.selectOrder(self.content_data);
- #ifdef BUILD_NPD
- int count = [[self.content_data objectForKey:@"count"] intValue];
- for (int i = 0; i < count; i++) {
- NSString *key = [NSString stringWithFormat:@"section_%d",i];
- NSMutableDictionary *section = [[self.content_data objectForKey:key] mutableCopy];
- NSString *type = [section objectForKey:@"type"];
- if ([type isEqualToString:@"sign_url"]) {
- [section setObject:img_url_down forKey:@"data"];
- [self.content_data setObject:section forKey:key];
- break;
- }
- }
- #endif
-
- #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
- int count = [[self.content_data objectForKey:@"count"] intValue];
- for (int i = 0; i < count; i++) {
- NSString *key = [NSString stringWithFormat:@"section_%d",i];
- NSMutableDictionary *section = [[self.content_data objectForKey:key] mutableCopy];
- NSString *type = [section objectForKey:@"type"];
- if ([type isEqualToString:@"sign_url"]) {
- [section setObject:img_url_down forKey:@"data"];
- [self.content_data setObject:section forKey:key];
- break;
- }
- }
- #endif
-
-
- #ifdef BUILD_HMLG
-
- [self.content_data setValue:img_url_down forKey:@"sign_url"];
- #endif
- //self.btnSign.enabled = false;
- [self.detailTable reloadData];
-
- [RAUtils message_alert:@"Successful." title:@"Signature" controller:self];
-
-
- }
- else
- {
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Signature" controller:self] ;
- }
-
-
-
- });
- });
- }
- }
- else
- {
- [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Upload Image" controller:self] ;
- }
- }
- else
- #endif
- {
- NSData *imageData = UIImagePNGRepresentation(img);
- NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- if(appDelegate.user!=nil)
- [params setValue:appDelegate.user forKey:@"user"];
- if(appDelegate.password!=nil)
- [params setValue:appDelegate.password forKey:@"password"];
-
- __weak typeof(self) weakSelf = self;
- [NetworkUtils upload:imageData FileName:@"test.jpg" Params:params ToHost:URL_UPLOAD_IMG Result:^(NSMutableDictionary *json) {
-
- if([[json valueForKey:@"result"] intValue]==2)
- {
- NSString* img_url_down = json[@"img_url_aname"];
- NSString* img_url_up = json[@"img_url"];
-
- {
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Signature"];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* order_json = [RANetwork sign_Order:weakSelf.order_code path:img_url_up];
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- if([[order_json valueForKey:@"result"] intValue]==2)
- {
-
- #ifdef BUILD_NPD
- int count = [[weakSelf.content_data objectForKey:@"count"] intValue];
- for (int i = 0; i < count; i++) {
- NSString *key = [NSString stringWithFormat:@"section_%d",i];
- NSMutableDictionary *section = [[weakSelf.content_data objectForKey:key] mutableCopy];
- NSString *type = [section objectForKey:@"type"];
- if ([type isEqualToString:@"sign_url"]) {
- [section setObject:img_url_down forKey:@"data"];
- [weakSelf.content_data setObject:section forKey:key];
- break;
- }
- }
- #endif
-
- #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
- int count = [[weakSelf.content_data objectForKey:@"count"] intValue];
- for (int i = 0; i < count; i++) {
- NSString *key = [NSString stringWithFormat:@"section_%d",i];
- NSMutableDictionary *section = [[weakSelf.content_data objectForKey:key] mutableCopy];
- NSString *type = [section objectForKey:@"type"];
- if ([type isEqualToString:@"sign_url"]) {
- [section setObject:img_url_down forKey:@"data"];
- [weakSelf.content_data setObject:section forKey:key];
- break;
- }
- }
- #endif
-
- #ifdef BUILD_HMLG
- [weakSelf.content_data setValue:img_url_down forKey:@"sign_url"];
- #endif
- //self.btnSign.enabled = false;
- [weakSelf.detailTable reloadData];
-
- [RAUtils message_alert:@"Successful." title:@"Signature" controller:weakSelf];
-
-
- }
- else
- {
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Signature" controller:weakSelf] ;
- }
-
-
-
- });
- });
- }
-
-
- }
- else
- {
- [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Upload Image" controller:weakSelf] ;
- }
-
- } Progress:nil DecryptHandler:nil];
-
- // AFHTTPRequestSerializer* serializer=[AFHTTPRequestSerializer serializer] ;
- // DebugLog(URL_UPLOAD_IMG);
- //
- // NSMutableURLRequest *request = [serializer multipartFormRequestWithMethod:@"POST" URLString:URL_UPLOAD_IMG parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
- // [formData appendPartWithFileData:imageData name:@"upfile" fileName:@"test.jpg" mimeType:@"image/png"];
- // } error:nil];
- //
- //
- // // NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:WEBSERVICE_URL parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
- // // [formData appendPartWithFileData:imageData name:@"upfile" fileName:@"test" mimeType:@"image/png"];
- // // } error:nil];
- // //
- // AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
- //
- //
- //
- // //manager.responseSerializer.acceptableContentTypes = [self.operationManager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
- //
- //
- //
- // //
- // NSProgress *progress = nil;
- //
- // NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
- //
- // // [progress removeObserver:self forKeyPath:@"fractionCompleted"];
- //
- //
- //
- //
- // if (error) {
- //
- // NSString* err_msg = [error localizedDescription];
- // DebugLog(@"%@",err_msg);// [self.view updateWithMessage:[NSString stringWithFormat:@"Error : %@!", error.debugDescription]];
- //
- //
- // NSMutableString *str = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
- //
- // DebugLog(@"data string: %@",str);
- //
- // [RAUtils message_alert:@"Can not connect to server please try again." title:@"Upload Image" controller:self] ;
- //
- // } else {
- // DebugLog(@"response ");
- //
- //
- //
- // NSData *data = [NSJSONSerialization dataWithJSONObject:(NSDictionary*)responseObject options:kNilOptions error:nil];
- //
- // // 再将NSData转为字符串
- // NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
- //
- // // NSMutableString *str = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
- //
- // DebugLog(@"data string: %@",jsonStr);
- //
- // NSDictionary* json = responseObject;
- //
- // if([[json valueForKey:@"result"] intValue]==2)
- // {
- // NSString* img_url_down = json[@"img_url_aname"];
- // NSString* img_url_up = json[@"img_url"];
- //
- // {
- // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Signature"];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* order_json = [iSalesNetwork sign_Order:self.order_code path:img_url_up];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- // if([[order_json valueForKey:@"result"] intValue]==2)
- // {
- // // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // // appDelegate.order_code = self.order_code;
- // // [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
- // //
- // //
- // // appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
- // //
- // // appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
- // // [self.navigationController popViewControllerAnimated:false];
- // //
- // // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- // // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- // // if(self.selectOrder)
- // // self.selectOrder(self.content_data);
- //
- //#ifdef BUILD_NPD
- // int count = [[self.content_data objectForKey:@"count"] intValue];
- // for (int i = 0; i < count; i++) {
- // NSString *key = [NSString stringWithFormat:@"section_%d",i];
- // NSMutableDictionary *section = [[self.content_data objectForKey:key] mutableCopy];
- // NSString *type = [section objectForKey:@"type"];
- // if ([type isEqualToString:@"sign_url"]) {
- // [section setObject:img_url_down forKey:@"data"];
- // [self.content_data setObject:section forKey:key];
- // break;
- // }
- // }
- //#endif
- //
- //#ifdef BUILD_HOMER
- // int count = [[self.content_data objectForKey:@"count"] intValue];
- // for (int i = 0; i < count; i++) {
- // NSString *key = [NSString stringWithFormat:@"section_%d",i];
- // NSMutableDictionary *section = [[self.content_data objectForKey:key] mutableCopy];
- // NSString *type = [section objectForKey:@"type"];
- // if ([type isEqualToString:@"sign_url"]) {
- // [section setObject:img_url_down forKey:@"data"];
- // [self.content_data setObject:section forKey:key];
- // break;
- // }
- // }
- //#endif
- //#ifdef BUILD_GATIT
- // int count = [[self.content_data objectForKey:@"count"] intValue];
- // for (int i = 0; i < count; i++) {
- // NSString *key = [NSString stringWithFormat:@"section_%d",i];
- // NSMutableDictionary *section = [[self.content_data objectForKey:key] mutableCopy];
- // NSString *type = [section objectForKey:@"type"];
- // if ([type isEqualToString:@"sign_url"]) {
- // [section setObject:img_url_down forKey:@"data"];
- // [self.content_data setObject:section forKey:key];
- // break;
- // }
- // }
- //#endif
- //
- //#ifdef BUILD_HMLG
- // [self.content_data setValue:img_url_down forKey:@"sign_url"];
- //#endif
- // //self.btnSign.enabled = false;
- // [self.detailTable reloadData];
- //
- // [RAUtils message_alert:@"Successful." title:@"Signature" controller:self];
- //
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Signature" controller:self] ;
- // }
- //
- //
- //
- // });
- // });
- // }
- //
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Upload Image" controller:self] ;
- // }
- //
- //
- //
- //
- //
- //
- // }
- // // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- // }];
- //
- // [uploadTask resume];
- }
-
- }
- - (IBAction)onSignOrderClick:(id)sender {
-
- // SignatureViewController * vc;
-
- __block UIImage* signimg=nil;
- SignatureViewController * vc =[ [UIStoryboard storyboardWithName:@"signature" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"SignatureViewController"];
-
- vc.onReturnImg = ^(UIImage* img)
- {
- signimg = img;
-
- if(signimg!=nil)
- [self upload_img:signimg];
-
-
- };
- // orderinfoVC.url_type = URL_REMOTE;
- // orderinfoVC.request_url=URL_CARTDELIVERY;
- //
- // orderinfoVC.params = params;
- //
- // orderinfoVC.delegate=self;
- //
- // if(checked.count==count)
- // {
- // orderinfoVC.have_tail = true
- // }
-
- [self.navigationController pushViewController:vc animated:true];
- }
- - (IBAction)onOpenOrderClick:(id)sender {
- // get customer info
-
-
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Are you sure to open order?" message:nil preferredStyle:UIAlertControllerStyleAlert];
- //block代码块取代了delegate
-
-
-
- UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-
- {
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Open Order"];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* order_json = [RANetwork open_Order:self.order_code];
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- if([[order_json valueForKey:@"result"] intValue]==2)
- {
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- appDelegate.order_code = self.order_code;
- appDelegate.order_status = self.order_status;
- [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
-
-
- appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
-
- appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
- [self.navigationController popViewControllerAnimated:false];
-
- [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
- if(self.selectOrder)
- self.selectOrder(self.content_data);
-
-
- }
- else
- {
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
- }
-
-
-
- });
- });
- }
-
-
-
-
-
-
- }];
-
- UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
- DebugLog(@"Cancel");
- }];
- [alertControl addAction:actionOne];
-
- [alertControl addAction:alertthree];
-
- //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
-
-
- [self presentViewController:alertControl animated:YES completion:nil];
-
-
-
-
-
-
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- -(void) loaddata
- {
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Loading"];
-
-
-
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
- if(self.isrefreshing)
- return;
-
- self.detailTable.hidden = true;
- self.label_net_err.hidden=true;
- self.isrefreshing=true;
-
- self.mum.center = self.view.center;
- self.mum.hidden = false;
- [self.mum startAnimating];
-
- DebugLog(@"reloading...");
-
- self.web_info_height=0;
- self.web_moreinfo_height=0;
- // self.content_data = nil;
-
- self.btnOpen.enabled =false;
- self.btnSign.enabled = false;
-
- self.btnCopy.enabled =false;
- self.btnPDF.enabled =false;
- self.btnRelease.enabled =false;
-
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* order_json = [RANetwork request_OrderDetail:self.orderid];
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- [self.mum stopAnimating];
- if([[order_json valueForKey:@"result"] intValue]==2)
- {
- self.detailTable.hidden = false;
- self.content_data = [order_json mutableCopy];
-
-
- }
- else {
- self.content_data = nil;
- if([[order_json valueForKey:@"result"] intValue]==RESULT_NET_ERROR)
- {
- self.label_net_err.hidden=false;
- self.detailTable.hidden=true;
- }
- else
- {
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Loading Order Detail" controller:self] ;
- }
- }
-
- bool web_order =[[self.content_data valueForKey:@"from_online"] boolValue];
- if(web_order)
- self.btnCopy.enabled = false;
- else
- self.btnCopy.enabled = true;
- int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- int model_count =[[self.content_data valueForKey:@"model_count"] intValue];
- if(model_count>0)/*&& ! appDelegate.offline_mode*/
- {
- if(appDelegate.user_type== USER_ROLE_EMPLOYEE)
- self.btnPDF.enabled =true;
- else
- {
- // || appDelegate.user_type==USER_ROLE_CUSTOMER
- if(self.is_shoporder)
- {
- if(status_code==1||status_code==30)
- self.btnPDF.enabled =true;
- }
- else
- {
- if(status_code==2)
- self.btnPDF.enabled =true;
- }
- }
- }
- // [self.btnPDF setImage:[[UIImage imageNamed:@"download"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
-
- // NSString* status = [self.content_data valueForKey:@"order_status"];
- NSString* lock_user = [self.content_data valueForKey:@"opened_customer"];
- bool offline_edit =[[self.content_data valueForKey:@"offline_edit"] boolValue];
- if(status_code==1)//[status isEqualToString:@"Saved Order"])
- {
- // [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
- //
- // [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
-
- BOOL condition = offline_edit;
- #ifdef OFFLINE_MODE
- condition = condition || appDelegate.offline_mode==false;
- #else
- condition = YES;
- #endif
- if(condition)
- {
- self.btnOpen.enabled =true;
-
- self.btnSign.enabled = true;
- }
- // if([lock_user isEqualToString:appDelegate.user])
- // {
- // self.btnCommit.enabled =true;
- // }
- // else
- // self.btnCommit.enabled =false;
- }
- else
- if(status_code==0)//[status isEqualToString:@"Quote Saved"])
- {
- // [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
- //
- // [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
-
- BOOL condition = offline_edit;
- #ifdef OFFLINE_MODE
- condition = condition || appDelegate.offline_mode==false;
- #else
- condition = YES;
- #endif
- if (condition)
- {
- self.btnOpen.enabled =true;
-
- self.btnSign.enabled = true;
- }
- // self.btnCommit.enabled =false;
- }
- BOOL lock_condition_1 = [lock_user isEqualToString:appDelegate.user];
- BOOL lock_condition_2 = false;
- #ifdef OFFLINE_MODE
- lock_condition_1 = !appDelegate.offline_mode && lock_condition_1;
- lock_condition_2 = appDelegate.offline_mode && [self.order_code isEqualToString:appDelegate.order_code];
- #endif
-
- if((lock_condition_1 || lock_condition_2)&& (status_code==1||status_code==0))
- {
- // [self.btnRelease setImage:[[UIImage imageNamed:@"order"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
-
-
- self.btnRelease.enabled =true;
- }
- else
- {
-
-
- // [self.btnRelease setImage:[[UIImage imageNamed:@"order"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
- self.btnRelease.enabled =false;
- }
-
- [self.detailTable reloadData];
- self.isrefreshing=false;
-
- });
-
- });
- });
- }
- - (void)viewWillAppear:(BOOL)animated
- {
-
- [super viewWillAppear:animated];
- // if(appDelegate.can_submit_order)
- // {
- //
- //
- // [self.btnCommit setImage:[UIImage imageNamed:@"commit"]];
- // self.btnCommit.enabled = true;
- // }
- // else
- // {
- // [self.btnCommit setImage:nil];
- // self.btnCommit.enabled = false;
- // }
- //
- [[self navigationController] setNavigationBarHidden:NO animated:NO];
-
- }
- - (IBAction)imgbtnClicked:(UIButton*)sender {
- UITableViewCell* cell =(UITableViewCell*) sender.superview.superview;
-
- NSIndexPath * indexPath = [self.detailTable indexPathForCell:cell];
-
- if(indexPath.section!=1)
- return ;
- // DebugLog(@"shouldchangeedit %d_%d",indexPath.section,indexPath.row);
- NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
-
- NSString* product_id = [item_json valueForKey:@"product_id"];
-
- DetailViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController" ];
- // dvc
-
- dvc.product_id=product_id;
- dvc.category_id=nil;
- dvc.ispush=true;
- [dvc reload];
- [self.navigationController pushViewController:dvc animated:true];
- }
- /*
- #pragma mark - Navigation
-
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- #pragma mark - Table view data source
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
- {
- // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
- // if([item_json objectForKey:@"combine"] == nil)
- // {
- // return 120;
- // }
- // else
- // return 150;
-
-
- #ifdef BUILD_NPD
- NSDictionary *section_item = [self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",indexPath.section]];
- NSDictionary *data = [section_item objectForKey:@"data"];
- NSString *type = [section_item objectForKey:@"type"];
- if ([type isEqualToString:@"order_info"]) {
-
- float height= self.web_info_height;
- if(height==0)
- height=DEF_TABLE_HEIGHT;
-
- return height;
- } else if ([type isEqualToString:@"sign_url"]) {
- return 148;
- } else if ([type isEqualToString:@"more_order_info"]) {
-
- float height= self.web_moreinfo_height;
- if(height==0)
- height=DEF_TABLE_HEIGHT;
-
- return height;
-
- } else if ([type isEqualToString:@"sub_order"]) {
-
- NSDictionary *item = [data objectForKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]];
- NSString *item_type = [item objectForKey:@"type"];
- if ([item_type isEqualToString:@"pick_info"]) {
- return 218;
- } else {
- NSString* notes =[item valueForKey:@"note"];
- if(notes.length>0)
- {
- return 190;
- }
- else
- return 162;
- }
-
-
- } else if ([type isEqualToString:@"price_info"]) {
- return 44;
- }
-
- #endif
-
- #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
- NSDictionary *section_item = [self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",indexPath.section]];
- NSDictionary *data = [section_item objectForKey:@"data"];
- NSString *type = [section_item objectForKey:@"type"];
- if ([type isEqualToString:@"order_info"]) {
-
- float height= self.web_info_height;
- if(height==0)
- height=DEF_TABLE_HEIGHT;
-
- return height;
-
- } else if ([type isEqualToString:@"sign_url"]) {
- return 148;
- } else if ([type isEqualToString:@"more_order_info"]) {
-
- float height= self.web_moreinfo_height;
- if(height==0)
- height=DEF_TABLE_HEIGHT;
-
- return height;
-
- } else if ([type isEqualToString:@"sub_order"]) {
-
- NSDictionary *item = [data objectForKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]];
- NSString *item_type = [item objectForKey:@"type"];
- if ([item_type isEqualToString:@"pick_info"]) {
- return 218;
- } else {
- NSString* notes =[item valueForKey:@"note"];
- if(notes.length>0)
- {
- return 190;
- }
- else
- return 162;
- }
-
-
- } else if ([type isEqualToString:@"price_info"]) {
- return 44;
- }
-
- #endif
-
- #ifdef BUILD_HMLG
- switch (indexPath.section) {
- case 0:
- {
- if(indexPath.row==0)
- {
- float height= self.web_info_height;
- if(height==0)
- height=DEF_TABLE_HEIGHT;
-
-
- return height;
- }
- else
- return 148;
-
- }
- break;
-
- case 1:
- {
- float height= self.web_moreinfo_height;
- if(height==0)
- height=DEF_TABLE_HEIGHT;
-
-
- // DebugLog(@"heightForRowAtIndexPath...............webview,hight = %f section=%ld",height,indexPath.section);
- //wait(1000);
- return height;
- }
- break;
- case 2:
-
- {
- NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
-
- NSString* notes =[item_json valueForKey:@"note"];
- if(notes.length>0)
- {
- return 190;
- }
- else
- return 162;
- }
- case 3:
- return 44;
- default:
- break;
- }
- #endif
- return 44;
-
- }
- //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- //{
- // return 0;
- //}
- //- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- //{
- // return 0;
- //}
- //- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
- //{
- // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
- // return myView;
- //
- //}
- //- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- //{
- // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
- //// myView.backgroundColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
- //// UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 90, 22)];
- //// titleLabel.textColor=[UIColor whiteColor];
- //// titleLabel.backgroundColor = [UIColor clearColor];
- //// if(section==0)
- //// titleLabel.text=NSLocalizedString(@"display_items", nil);
- //// else
- //// titleLabel.text=NSLocalizedString(@"hide_items", nil);
- //// [titleLabel sizeToFit];
- //// [myView addSubview:titleLabel];
- ////
- // return myView;
- //}
- //
- - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- {
-
-
- NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
-
- if(value==nil)
- value=@"";
- unsigned long color = strtoul([value UTF8String],0,16);
-
-
- DefaultTableHeaderView* myView = [[DefaultTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
- // myView.backgroundColor = UIColorFromRGB(0x996633);;
-
-
- myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath;
- // myView.layer.masksToBounds = false;
- //添加四个边阴影
-
- myView.layer.shadowColor = [UIColor blackColor].CGColor;
- myView.layer.shadowOffset = CGSizeMake(0, 0);
- myView.layer.shadowOpacity = 0.5;
- myView.layer.shadowRadius = 2.0;
- myView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
-
- NSString*labeltitle = nil;
-
- #ifdef BUILD_NPD
- NSDictionary *section_item = [self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",section]];
- NSString *title = [section_item objectForKey:@"title"];
- labeltitle = title;
- if ([title isEqualToString:@"More Info"]) {
-
- NSString* btntitle=nil ;
- if(self.showMore)
- {
- btntitle=@"Hide";
- }
- else{
- btntitle=@"Show";
- }
-
-
- UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
- btn.tag=section;
- [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
- [btn setTitle:btntitle forState:UIControlStateNormal];
- btn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
- [myView addSubview:btn];
-
- } else if ([title containsString:@"Models"] || [title containsString:@"Invoice#"]) {
-
- BOOL item_switch = [[section_item objectForKey:@"switch"] boolValue];
- NSString *normalTitle = @"Show";
- NSString *selectedTitle = @"Hide";
- if (item_switch == YES) {
- normalTitle = @"Hide";
- selectedTitle = @"Show";
- }
-
- UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
- btn.tag=section;
- [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
- [btn setTitle:normalTitle forState:UIControlStateNormal];
- [btn setTitle:selectedTitle forState:UIControlStateSelected];
- btn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
- [myView addSubview:btn];
- }
-
- #endif
-
- #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
- NSDictionary *section_item = [self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",section]];
- NSString *title = [section_item objectForKey:@"title"];
- labeltitle = title;
- if ([title isEqualToString:@"More Info"]) {
-
- NSString* btntitle=nil ;
- if(self.showMore)
- {
- btntitle=@"Hide";
- }
- else{
- btntitle=@"Show";
- }
-
-
- UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
- btn.tag=section;
- [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
- [btn setTitle:btntitle forState:UIControlStateNormal];
- btn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
- [myView addSubview:btn];
-
- } else if ([title containsString:@"Models"] || [title containsString:@"Invoice#"]) {
-
- BOOL item_switch = [[section_item objectForKey:@"switch"] boolValue];
- NSString *normalTitle = @"Show";
- NSString *selectedTitle = @"Hide";
- if (item_switch == YES) {
- normalTitle = @"Hide";
- selectedTitle = @"Show";
- }
-
- UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
- btn.tag=section;
- [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
- [btn setTitle:normalTitle forState:UIControlStateNormal];
- [btn setTitle:selectedTitle forState:UIControlStateSelected];
- btn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
- [myView addSubview:btn];
- }
-
- #endif
-
- #ifdef BUILD_HMLG
- switch (section) {
- case 0:
- labeltitle= @"Order Info";
- break;
- case 1:
- {
- labeltitle= @"More Info";
-
- NSString* btntitle=nil ;
- if(self.showMore)
- {
- btntitle=@"Hide";
- // [section setValue:@"false" forKey:@"hide"];
- // [sender setTitle:@"Show" forState:UIControlStateNormal];
- }
- else{
- btntitle=@"Show";
- }
-
-
- UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
- btn.tag=section;
- [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
- [btn setTitle:btntitle forState:UIControlStateNormal];
- btn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
- [myView addSubview:btn];
-
- }
- break;
- case 2:{
- labeltitle= @"Models";
-
- NSString* btntitle=nil ;
- if(self.showModels)
- {
- btntitle=@"Hide";
- }
- else{
- btntitle=@"Show";
- }
-
-
- UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
- btn.tag=section;
-
- [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
-
- [btn setTitle:btntitle forState:UIControlStateNormal];
- btn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
- [myView addSubview:btn];
-
- }
- break;
- case 3:
- labeltitle= @"Price Info";
- default:
- break;
- }
-
- #endif
-
- UILabel *titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 5.5, 200, 20)];
- titlelabel.textColor=UIColorFromRGB(color);;
- titlelabel.backgroundColor = [UIColor clearColor];
- titlelabel.text=NSLocalizedString(labeltitle, nil);
- [titlelabel sizeToFit];
- titlelabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
- [myView addSubview:titlelabel];
-
- //
- return myView;
- }
- #pragma mark - hide section button clicked
- - (void)HideSction:(UIButton *)sender {
- /*
- NSMutableDictionary* section= [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",sender.tag]] mutableCopy];
- bool hide = [[section valueForKey:@"hide"]boolValue];
- if(hide)
- {
- [section setValue:@"false" forKey:@"hide"];
- [sender setTitle:@"Show" forState:UIControlStateNormal];
- }
- else{
- [section setValue:@"true" forKey:@"hide"];
- [sender setTitle:@"Hide" forState:UIControlStateNormal];
- }
-
- [self.content_data_download setObject:section forKey:[NSString stringWithFormat:@"section_%d",sender.tag]];
- self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
-
- */
- #ifdef BUILD_NPD
- NSUInteger section = sender.tag;
- NSMutableDictionary *section_item = [[self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",section]] mutableCopy];
- NSString *title = [section_item objectForKey:@"title"];
- if ([title isEqualToString:@"More Info"]) {
-
- self.showMore = !self.showMore;
- NSRange range = NSMakeRange(section, 1);
- NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
- [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
-
- } else if ([title containsString:@"Models"] || [title containsString:@"Invoice#"]) {
-
- BOOL item_switch = [[section_item objectForKey:@"switch"] boolValue];
- if (item_switch == YES) {
- [section_item setObject:@(NO) forKey:@"switch"];
- } else {
- [section_item setObject:@(YES) forKey:@"switch"];
- }
- [self.content_data setObject:section_item forKey:[NSString stringWithFormat:@"section_%ld",section]];
-
- sender.selected = !sender.selected;
- NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndex:section];
- [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
- }
-
- #endif
-
- #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
- NSUInteger section = sender.tag;
- NSMutableDictionary *section_item = [[self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",section]] mutableCopy];
- NSString *title = [section_item objectForKey:@"title"];
-
- if ([title isEqualToString:@"More Info"]) {
-
- self.showMore = !self.showMore;
- NSRange range = NSMakeRange(section, 1);
- NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
- [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
-
- } else if ([title containsString:@"Models"] || [title containsString:@"Invoice#"]) {
-
- BOOL item_switch = [[section_item objectForKey:@"switch"] boolValue];
- if (item_switch == YES) {
- [section_item setObject:@(NO) forKey:@"switch"];
- } else {
- [section_item setObject:@(YES) forKey:@"switch"];
- }
- [self.content_data setObject:section_item forKey:[NSString stringWithFormat:@"section_%ld",section]];
-
- sender.selected = !sender.selected;
- NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndex:section];
- [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
- }
-
- #endif
-
- #ifdef BUILD_HMLG
-
- switch (sender.tag) {
- case 0:{
-
- }
- break;
- case 1:{
- self.showMore=!self.showMore;
- NSRange range = NSMakeRange(1, 1);
- NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
- [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
- }
- break;
- case 2:{
- self.showModels = !self.showModels;
-
- NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndex:2];
- [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
- }
- break;
-
- default:
- break;
- }
- #endif
-
-
- }
- - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
- switch (section) {
- case 0:
- return @"Order Info";
- break;
- case 1:
- return @"More Info";
- break;
- case 2:
- return @"Models";
- case 3:
- return @"Price Info";
- default:
- break;
- }
- return nil;
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
-
- if(self.content_data==nil)
- return 0;
- #ifdef BUILD_NPD
- return [[self.content_data objectForKey:@"count"] integerValue];
- #endif
-
- #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
- return [[self.content_data objectForKey:@"count"] integerValue];
- #endif
-
- #ifdef BUILD_HMLG
- return 4;
- #endif
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 33;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- #ifdef BUILD_NPD
-
- NSDictionary *section_item = [self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",section]];
- NSDictionary *data = [section_item objectForKey:@"data"];
- NSString *section_type = [section_item objectForKey:@"type"];
- if ([section_type isEqualToString:@"sub_order"]) {
- BOOL item_switch = [[section_item objectForKey:@"switch"] boolValue];
- if (item_switch == YES) {
- return [[data objectForKey:@"count"] integerValue];
- } else {
- return 0;
- }
-
- } else if ([section_type isEqualToString:@"order_info"]){
- if (self.showModels) {
- return 1;
- } else {
- return 0;
- }
- } else if ([section_type isEqualToString:@"sign_url"]){
- return 1;
- } else if ([section_type isEqualToString:@"more_order_info"]){
- if(self.showMore)
- return 1;
- else
- return 0;
- }else if ([section_type isEqualToString:@"price_info"]){
- return [[data objectForKey:@"count"] integerValue];
- }
-
- return 0;
-
- #endif
-
- #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
-
- NSDictionary *section_item = [self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",section]];
- NSDictionary *data = [section_item objectForKey:@"data"];
- NSString *section_type = [section_item objectForKey:@"type"];
- if ([section_type isEqualToString:@"sub_order"]) {
-
- BOOL item_switch = [[section_item objectForKey:@"switch"] boolValue];
- if (item_switch == YES) {
- return [[data objectForKey:@"count"] integerValue];
- } else {
- return 0;
- }
-
-
- } else if ([section_type isEqualToString:@"order_info"]){
- if (self.showModels) {
- return 1;
- } else {
- return 0;
- }
- } else if ([section_type isEqualToString:@"sign_url"]){
- return 1;
- } else if ([section_type isEqualToString:@"more_order_info"]){
- if(self.showMore)
- return 1;
- else
- return 0;
- }else if ([section_type isEqualToString:@"price_info"]){
- return [[data objectForKey:@"count"] integerValue];
- }
-
- return 0;
-
- #endif
-
- #ifdef BUILD_HMLG
-
- // NSDictionary * item_json = [self.content_data objectForKey:@"items"];
- if(section==0)
- return 2;
- if(section==1)
- {
- if(self.showMore)
- return 1;
- else
- return 0;
- }
-
- if(section==2)
- {
- if (self.showModels) {
- int count =[[self.content_data valueForKey:@"model_count"] intValue];
- return count;
- } else {
- return 0;
- }
- }
- if(section==3) {
- #ifdef BUILD_NPD
- return 6;
- #endif
-
- #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
- return 6;
- #endif
-
- #ifdef BUILD_HMLG
- return 4;
- #endif
- }
-
- #endif
- return 0;
-
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- #ifdef BUILD_NPD
- /**
- * ver1.90
- */
- NSDictionary *section = [self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",indexPath.section]];
- NSString *type = [section objectForKey:@"type"];
-
- if ([type isEqualToString:@"order_info"]) {/** Order Info */
-
- NSString *CellIdentifier = @"OrderDetailHtmlCell";
- OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
-
-
-
-
- cell.webview.tag = indexPath.section;
-
- cell.webview.delegate = self;
- // cell.webView.scrollView.contentSize.height = 0;
- cell.webview.scrollView.bounces=NO;
- cell.webview.scrollView.directionalLockEnabled = true;
- CGSize size= cell.webview.scrollView.contentSize;
- size.height=10;
- cell.webview.scrollView.contentSize=size;
-
- [cell.webview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
- } else if ([type isEqualToString:@"sign_url"]) { /** Sign */
-
-
- NSString *CellIdentifier = @"OrderDetailSignatureCell";
- OrderDetailSignatureCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- NSString* img_url = [section valueForKey:@"data"];
-
- cell.sign_img.userInteractionEnabled = NO;
-
- __block BOOL hasTapGesture = NO;
- [cell.sign_img.gestureRecognizers enumerateObjectsUsingBlock:^(__kindof UIGestureRecognizer * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-
- if ([obj isKindOfClass:[UITapGestureRecognizer class]]) {
- hasTapGesture = YES;
- *stop = YES;
- }
-
- }];
-
- if (!hasTapGesture) {
- UITapGestureRecognizer *signatureTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onSignOrderClick:)];
- [cell.sign_img addGestureRecognizer:signatureTap];
- }
-
- int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
- bool offline_edit =[[self.content_data valueForKey:@"offline_edit"] boolValue];
- if(status_code==1) {
-
- BOOL condition = offline_edit;
- #ifdef OFFLINE_MODE
- condition = condition || appDelegate.offline_mode==false;
- #else
- condition = YES;
- #endif
- if (condition)
- {
- cell.sign_img.userInteractionEnabled = YES;
- }
-
- }
- else if(status_code==0) {
- BOOL condition = offline_edit;
- #ifdef OFFLINE_MODE
- condition = condition || appDelegate.offline_mode==false;
- #else
- condition = YES;
- #endif
- if (condition)
- {
- cell.sign_img.userInteractionEnabled = YES;
- }
- }
-
-
-
- NSString* file_name=[img_url lastPathComponent];
- NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
- if(img_data!=nil)
- {
-
- UIImage * img =[UIImage imageWithData:img_data];
- cell.sign_img.image=img ;
- }
- else
- {
-
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
-
-
- if(downloadimg_data!=nil)
- {
-
- [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
-
- UIImage * img =[UIImage imageWithData:downloadimg_data];
- cell.sign_img.image=img ;
- }
- else {
- if (cell.sign_img.userInteractionEnabled) {
- cell.sign_img.image=[UIImage imageNamed:@"taptosign_s"];
- } else {
- cell.sign_img.image = nil;
- }
- }
-
-
- });
- });
-
-
- }
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
- } else if ([type isEqualToString:@"more_order_info"]) { /** More Info */
-
- NSString *CellIdentifier = @"OrderDetailHtmlCell";
- OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
-
-
-
- cell.webview.tag = indexPath.section;
- cell.webview.delegate = self;
- // cell.webView.scrollView.contentSize.height = 0;
- cell.webview.scrollView.bounces=NO;
- cell.webview.scrollView.directionalLockEnabled = true;
- CGSize size= cell.webview.scrollView.contentSize;
- size.height=10;
- cell.webview.scrollView.contentSize=size;
-
-
-
- [cell.webview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
-
- } else if ([type isEqualToString:@"sub_order"]) { /** Sub Order */
-
- NSDictionary *data = [section objectForKey:@"data"];
- NSDictionary *item = [data objectForKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]];
- NSString *item_type = [item objectForKey:@"type"];
-
- if ([item_type isEqualToString:@"pick_info"]) { /** Pick Info */
-
- NSString *CellIdentifier = @"OrderDetailPickInfoCell";
- OrderDetailPickInfoCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
- NSString *carrier = [item objectForKey:@"delivery_carrier"];
- NSString *web_url = [item objectForKey:@"delivery_web_url"];
- NSString *track_number = [item objectForKey:@"tracking_number"];
- NSString *status = [item objectForKey:@"status"];
-
- cell.track_number_lb.text = track_number;
- cell.status_lb.text = status;
- cell.carrier_lb.text = carrier;
- cell.url_lb.text = web_url;
-
- return cell;
-
- } else if ([item_type isEqualToString:@"order_item"]) { /** Item Info */
-
- NSString *CellIdentifier = @"OrderDetailModelCell";
- OrderDetailModelCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- NSDictionary * item_json = item;
-
- // int count = [[item_json valueForKey:@"count"] intValue];
- NSDictionary * combine_json =[item_json objectForKey:@"combine"];
- cell.bundle_item=combine_json;
- NSDictionary * master_json = [item_json objectForKey:@"combine_master"];
- if (cell.masterBtn != nil) {
- if (master_json == nil) {
- cell.masterBtn.hidden = YES;
- } else{
- cell.masterBtn.hidden = NO;
- cell.master_items = master_json;
- }
- }
-
- double dprice=0.0;
-
- if(cell.bundle_item!=nil)
- {
- int citem=0;
-
- int bcount=[[cell.bundle_item valueForKey:@"count"] intValue];
- for(int bc=0;bc<bcount;bc++)
- {
- NSDictionary * bitem = [cell.bundle_item objectForKey:[NSString stringWithFormat:@"item_%d",bc]];
- int modulus= [[bitem valueForKey:@"modulus"] intValue];
- citem+= modulus;
- double uprice= [[bitem valueForKey:@"unit_price"]doubleValue];
- dprice+= uprice*modulus;
-
- }
- if(citem==1)
- [ cell.buttonBundle setTitle:[NSString stringWithFormat: @"%d bundle item with price of $ %.2f",citem,dprice ]forState:UIControlStateNormal];
- else
- [ cell.buttonBundle setTitle:[NSString stringWithFormat: @"%d bundle items with price of $ %.2f",citem,dprice ]forState:UIControlStateNormal];
-
- cell.buttonBundle.hidden = NO;
- }
- else
- {
- cell.buttonBundle.hidden = YES;
-
- }
-
-
-
- NSString* img_url = [item_json valueForKey:@"img"];
- NSString* description = [item_json valueForKey:@"Item Number"];
- NSString* unitprice = [item_json valueForKey:@"The unit price"];
- NSString* origin_price = [item_json valueForKey:@"origin_price"];
- NSString* subtotal = [item_json valueForKey:@"Subtotal"];
- NSString* qty = [item_json valueForKey:@"QTY"];
- NSString* status = [item_json valueForKey:@"order_item_status"];
- NSString* notes = [item_json valueForKey:@"note"];
-
- if(notes.length>0)
- {
- cell.noteLabel.text = [@"Note: " stringByAppendingString:[notes stringByReplacingOccurrencesOfString:@"\n" withString:@" "]];
- }
- else
- cell.noteLabel.text = nil;
- if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
- {
-
- }
- else
- {
- unitprice=nil;
- origin_price=nil;
- subtotal=nil;
- }
-
- float duprice = [unitprice floatValue];
- float dsubtotal = (duprice+dprice)*[qty intValue];
-
- cell.descriptionLabel.text=description;
- if(dprice>0)
- cell.unitpriceLabel.text = [NSString stringWithFormat:@"%.2f+%.2f",duprice,dprice];//unitprice;
- else
- cell.unitpriceLabel.text = [NSString stringWithFormat:@"%.2f",duprice];//unitprice;
- cell.subtotalLabel.text = [NSString stringWithFormat:@"%.2f",dsubtotal];//subtotal;
- cell.qtyLabel.text = qty;
- cell.statusLabel.text = status;
-
-
- cell.labelOldPrice.text = origin_price;
-
- double discount =[[item_json valueForKey:@"discount"] doubleValue];
- NSString* discountstr=[NSString stringWithFormat:@"%@%% off", [RAUtils FloatFormat:discount]];
- cell.labelDiscount.text = discountstr;
- bool isfree = [[item_json valueForKey:@"is_free"]boolValue];
- if(isfree)
- {
- cell.labelOldPrice.hidden = false;
- cell.labelOldPrice.textColor = [UIColor redColor];
- cell.labelOldPrice.text=@"Free";
- cell.labelOldPrice.hideline = true;
-
- cell.labelDiscount.hidden = true;
- }
- else
- {
- cell.labelOldPrice.textColor = [UIColor blackColor];
- cell.labelOldPrice.hideline = false;
- if(discount==0)
- {
- cell.labelOldPrice.hidden = true;
- cell.labelDiscount.hidden = true;
-
- }
- else
- {
- cell.labelOldPrice.hidden = false;
- cell.labelDiscount.hidden = false;
- }
- }
-
- // Button 设置了大小约束,Size就不会随内容变化
- [cell.imgbtn setContentMode:UIViewContentModeScaleAspectFit];
- [cell.imgbtn setContentEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
- [cell.imgbtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentFill];
- [cell.imgbtn setContentVerticalAlignment:UIControlContentVerticalAlignmentFill];
- cell.imgbtn.imageView.contentMode = UIViewContentModeScaleAspectFit;
-
- if (![cell.imageName isEqualToString:img_url]) {
- cell.imageName = img_url;
- // [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
- [cell.imgbtn setImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
-
- NSString* file_name=[img_url lastPathComponent];
- NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
- if(img_data!=nil)
- {
-
- UIImage * img =[UIImage imageWithData:img_data];
- // [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
- [cell.imgbtn setImage:img forState:UIControlStateNormal];
- }
- else
- {
-
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
-
-
- if(downloadimg_data!=nil)
- {
-
- [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
-
- UIImage * img =[UIImage imageWithData:downloadimg_data];
- // [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
- [cell.imgbtn setImage:img forState:UIControlStateNormal];
- }
- else
- // [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
- [cell.imgbtn setImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
-
-
- });
- });
-
-
- }
- }
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
-
- }
-
-
- } else if ([type isEqualToString:@"price_info"]) { /** Price */
-
- NSString *CellIdentifier = @"OrderDetailPriceCell";
- OrderDetailPriceCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
- NSDictionary *data = [section objectForKey:@"data"];
- NSDictionary *item = [data objectForKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]];
- NSString *title = [item objectForKey:@"title"];
- NSString *value = [item objectForKey:@"value"];
- if ([title isEqualToString:@"Sub-Total"] || [title isEqualToString:@"Total"]) {
- if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
- {
-
- }
- else
- {
- value=nil;
- }
- }
- cell.chargeLabel.text = [title stringByAppendingString:@":"];
- cell.priceLabel.text = value;
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
- }
-
-
- #endif
-
- #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
- /**
- * ver1.90
- */
- NSDictionary *section = [self.content_data objectForKey:[NSString stringWithFormat:@"section_%ld",indexPath.section]];
- NSString *type = [section objectForKey:@"type"];
-
- if ([type isEqualToString:@"order_info"]) {/** Order Info */
-
- NSString *CellIdentifier = @"OrderDetailHtmlCell";
- OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
-
-
-
-
- cell.webview.tag = indexPath.section;
-
- cell.webview.delegate = self;
- // cell.webView.scrollView.contentSize.height = 0;
- cell.webview.scrollView.bounces=NO;
- cell.webview.scrollView.directionalLockEnabled = true;
- CGSize size= cell.webview.scrollView.contentSize;
- size.height=10;
- cell.webview.scrollView.contentSize=size;
-
- [cell.webview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
- } else if ([type isEqualToString:@"sign_url"]) { /** Sign */
-
-
- NSString *CellIdentifier = @"OrderDetailSignatureCell";
- OrderDetailSignatureCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- NSString* img_url = [section valueForKey:@"data"];
-
- cell.sign_img.userInteractionEnabled = NO;
- __block BOOL hasTapGesture = NO;
- [cell.sign_img.gestureRecognizers enumerateObjectsUsingBlock:^(__kindof UIGestureRecognizer * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-
- if ([obj isKindOfClass:[UITapGestureRecognizer class]]) {
- hasTapGesture = YES;
- *stop = YES;
- }
-
- }];
-
- if (!hasTapGesture) {
- UITapGestureRecognizer *signatureTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onSignOrderClick:)];
- [cell.sign_img addGestureRecognizer:signatureTap];
- }
-
- int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
- bool offline_edit =[[self.content_data valueForKey:@"offline_edit"] boolValue];
- if(status_code==1) {
-
- BOOL condition = offline_edit;
- #ifdef OFFLINE_MODE
- condition = condition || appDelegate.offline_mode==false;
- #else
- condition = YES;
- #endif
- if (condition)
- {
- cell.sign_img.userInteractionEnabled = YES;
- }
-
- }
- else if(status_code==0) {
- BOOL condition = offline_edit;
- #ifdef OFFLINE_MODE
- condition = condition || appDelegate.offline_mode==false;
- #else
- condition = YES;
- #endif
- if (condition)
- {
- cell.sign_img.userInteractionEnabled = YES;
- }
- }
-
-
-
- NSString* file_name=[img_url lastPathComponent];
- NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
- if(img_data!=nil)
- {
-
- UIImage * img =[UIImage imageWithData:img_data];
- cell.sign_img.image=img ;
- }
- else
- {
-
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
-
-
- if(downloadimg_data!=nil)
- {
-
- [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
-
- UIImage * img =[UIImage imageWithData:downloadimg_data];
- cell.sign_img.image=img ;
- }
- else {
- if (cell.sign_img.userInteractionEnabled) {
- cell.sign_img.image=[UIImage imageNamed:@"taptosign_s"];
- } else {
- cell.sign_img.image = nil;
- }
- }
-
-
- });
- });
-
-
- }
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
- } else if ([type isEqualToString:@"more_order_info"]) { /** More Info */
-
- NSString *CellIdentifier = @"OrderDetailHtmlCell";
- OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
-
-
-
- cell.webview.tag = indexPath.section;
- cell.webview.delegate = self;
- // cell.webView.scrollView.contentSize.height = 0;
- cell.webview.scrollView.bounces=NO;
- cell.webview.scrollView.directionalLockEnabled = true;
- CGSize size= cell.webview.scrollView.contentSize;
- size.height=10;
- cell.webview.scrollView.contentSize=size;
-
-
-
- [cell.webview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
-
- } else if ([type isEqualToString:@"sub_order"]) { /** Sub Order */
-
- NSDictionary *data = [section objectForKey:@"data"];
- NSDictionary *item = [data objectForKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]];
- NSString *item_type = [item objectForKey:@"type"];
-
- if ([item_type isEqualToString:@"pick_info"]) { /** Pick Info */
-
- NSString *CellIdentifier = @"OrderDetailPickInfoCell";
- OrderDetailPickInfoCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
- NSString *carrier = [item objectForKey:@"delivery_carrier"];
- NSString *web_url = [item objectForKey:@"delivery_web_url"];
- NSString *track_number = [item objectForKey:@"tracking_number"];
- NSString *status = [item objectForKey:@"status"];
-
- cell.track_number_lb.text = track_number;
- cell.status_lb.text = status;
- cell.carrier_lb.text = carrier;
- cell.url_lb.text = web_url;
-
- return cell;
-
- } else if ([item_type isEqualToString:@"order_item"]) { /** Item Info */
-
- NSString *CellIdentifier = @"OrderDetailModelCell";
- OrderDetailModelCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- NSDictionary * item_json = item;
-
- // int count = [[item_json valueForKey:@"count"] intValue];
- NSDictionary * combine_json =[item_json objectForKey:@"combine"];
- cell.bundle_item=combine_json;
- NSDictionary * master_json = [item_json objectForKey:@"combine_master"];
- if (cell.masterBtn != nil) {
- if (master_json == nil) {
- cell.masterBtn.hidden = YES;
- } else{
- cell.masterBtn.hidden = NO;
- cell.master_items = master_json;
- }
- }
-
- double dprice=0.0;
-
- if(cell.bundle_item!=nil)
- {
- int citem=0;
-
- int bcount=[[cell.bundle_item valueForKey:@"count"] intValue];
- for(int bc=0;bc<bcount;bc++)
- {
- NSDictionary * bitem = [cell.bundle_item objectForKey:[NSString stringWithFormat:@"item_%d",bc]];
- int modulus= [[bitem valueForKey:@"modulus"] intValue];
- citem+= modulus;
- double uprice= [[bitem valueForKey:@"unit_price"]doubleValue];
- dprice+= uprice*modulus;
-
- }
- if(citem==1)
- [ cell.buttonBundle setTitle:[NSString stringWithFormat: @"%d bundle item with price of $ %.2f",citem,dprice ]forState:UIControlStateNormal];
- else
- [ cell.buttonBundle setTitle:[NSString stringWithFormat: @"%d bundle items with price of $ %.2f",citem,dprice ]forState:UIControlStateNormal];
-
- cell.buttonBundle.hidden = NO;
- }
- else
- {
- cell.buttonBundle.hidden = YES;
-
- }
-
-
-
- NSString* img_url = [item_json valueForKey:@"img"];
- NSString* description = [item_json valueForKey:@"Item Number"];
-
- NSString* unitprice = [item_json valueForKey:@"The unit price"];
- NSString* origin_price = [item_json valueForKey:@"origin_price"];
- NSString* subtotal = [item_json valueForKey:@"Subtotal"];
- NSString* qty = [item_json valueForKey:@"QTY"];
- NSString* status = [item_json valueForKey:@"order_item_status"];
- NSString* notes = [item_json valueForKey:@"note"];
-
- if(notes.length>0)
- {
- cell.noteLabel.text = [@"Note: " stringByAppendingString:[notes stringByReplacingOccurrencesOfString:@"\n" withString:@" "]];
- }
- else
- cell.noteLabel.text = nil;
- if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
- {
-
- }
- else
- {
- unitprice=nil;
- origin_price=nil;
- subtotal=nil;
- }
-
- float duprice = [unitprice floatValue];
- float dsubtotal = (duprice+dprice)*[qty intValue];
-
- cell.descriptionLabel.text=description;
- if(dprice>0)
- cell.unitpriceLabel.text = [NSString stringWithFormat:@"%.2f+%.2f",duprice,dprice];//unitprice;
- else
- cell.unitpriceLabel.text = [NSString stringWithFormat:@"%.2f",duprice];//unitprice;
- cell.subtotalLabel.text = [NSString stringWithFormat:@"%.2f",dsubtotal];//subtotal;
- cell.qtyLabel.text = qty;
- cell.statusLabel.text = status;
-
-
- cell.labelOldPrice.text = origin_price;
-
- double discount =[[item_json valueForKey:@"discount"] doubleValue];
- NSString* discountstr=[NSString stringWithFormat:@"%@%% off", [RAUtils FloatFormat:discount]];
- cell.labelDiscount.text = discountstr;
- bool isfree = [[item_json valueForKey:@"is_free"]boolValue];
- if(isfree)
- {
- cell.labelOldPrice.hidden = false;
- cell.labelOldPrice.textColor = [UIColor redColor];
- cell.labelOldPrice.text=@"Free";
- cell.labelOldPrice.hideline = true;
-
- cell.labelDiscount.hidden = true;
- }
- else
- {
- cell.labelOldPrice.textColor = [UIColor blackColor];
- cell.labelOldPrice.hideline = false;
- if(discount==0)
- {
- cell.labelOldPrice.hidden = true;
- cell.labelDiscount.hidden = true;
-
- }
- else
- {
- cell.labelOldPrice.hidden = false;
- cell.labelDiscount.hidden = false;
- }
- }
-
- // Button 设置了大小约束,Size就不会随内容变化
- [cell.imgbtn setContentMode:UIViewContentModeScaleAspectFit];
- [cell.imgbtn setContentEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
- [cell.imgbtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentFill];
- [cell.imgbtn setContentVerticalAlignment:UIControlContentVerticalAlignmentFill];
- cell.imgbtn.imageView.contentMode = UIViewContentModeScaleAspectFit;
-
- if (![cell.imageName isEqualToString:img_url]) {
- cell.imageName = img_url;
- // [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
- [cell.imgbtn setImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
-
- NSString* file_name=[img_url lastPathComponent];
- NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
- if(img_data!=nil)
- {
-
- UIImage * img =[UIImage imageWithData:img_data];
- // [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
- [cell.imgbtn setImage:img forState:UIControlStateNormal];
- }
- else
- {
-
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
-
-
- if(downloadimg_data!=nil)
- {
-
- [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
-
- UIImage * img =[UIImage imageWithData:downloadimg_data];
- // [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
- [cell.imgbtn setImage:img forState:UIControlStateNormal];
- }
- else
- // [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
- [cell.imgbtn setImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
-
-
- });
- });
-
-
- }
- }
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
-
-
- }
-
-
- } else if ([type isEqualToString:@"price_info"]) { /** Price */
-
- NSString *CellIdentifier = @"OrderDetailPriceCell";
- OrderDetailPriceCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
- NSDictionary *data = [section objectForKey:@"data"];
- NSDictionary *item = [data objectForKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]];
- NSString *title = [item objectForKey:@"title"];
- NSString *value = [item objectForKey:@"value"];
- if ([title isEqualToString:@"Sub-Total"] || [title isEqualToString:@"Total"]) {
- if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
- {
-
- }
- else
- {
- value=nil;
- }
- }
- cell.chargeLabel.text = [title stringByAppendingString:@":"];
- cell.priceLabel.text = value;
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
-
- }
-
-
- #endif
-
- #ifdef BUILD_HMLG
-
- switch(indexPath.section)
- {
- case 0:
- {
-
- if(indexPath.row==0)
- {
- NSString *CellIdentifier = @"OrderDetailHtmlCell";
- OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
-
-
-
-
- cell.webview.tag = indexPath.section;
-
- cell.webview.delegate = self;
- // cell.webView.scrollView.contentSize.height = 0;
- cell.webview.scrollView.bounces=NO;
- cell.webview.scrollView.directionalLockEnabled = true;
- CGSize size= cell.webview.scrollView.contentSize;
- size.height=10;
- cell.webview.scrollView.contentSize=size;
-
- [cell.webview loadHTMLString:[self.content_data valueForKey:@"order_info"] baseURL:nil];
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
- }
- else
- {
-
- NSString *CellIdentifier = @"OrderDetailSignatureCell";
- OrderDetailSignatureCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- NSString* img_url = [self.content_data valueForKey:@"sign_url"];
-
- cell.sign_img.userInteractionEnabled = NO;
- __block BOOL hasTapGesture = NO;
- [cell.sign_img.gestureRecognizers enumerateObjectsUsingBlock:^(__kindof UIGestureRecognizer * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-
- if ([obj isKindOfClass:[UITapGestureRecognizer class]]) {
- hasTapGesture = YES;
- *stop = YES;
- }
-
- }];
-
- if (!hasTapGesture) {
- UITapGestureRecognizer *signatureTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onSignOrderClick:)];
- [cell.sign_img addGestureRecognizer:signatureTap];
- }
-
- int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
- bool offline_edit =[[self.content_data valueForKey:@"offline_edit"] boolValue];
- if(status_code==1) {
- BOOL condition = offline_edit;
- #ifdef OFFLINE_MODE
- condition = condition || appDelegate.offline_mode==false;
- #else
- condition = YES;
- #endif
- if (condition)
- {
- cell.sign_img.userInteractionEnabled = YES;
- }
- }
- else if(status_code==0) {
- BOOL condition = offline_edit;
- #ifdef OFFLINE_MODE
- condition = condition || appDelegate.offline_mode==false;
- #else
- condition = YES;
- #endif
- if (condition)
- {
- cell.sign_img.userInteractionEnabled = YES;
- }
- }
-
-
- NSString* file_name=[img_url lastPathComponent];
- NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
- if(img_data!=nil)
- {
-
- UIImage * img =[UIImage imageWithData:img_data];
- cell.sign_img.image=img ;
- }
- else
- {
-
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
-
-
- if(downloadimg_data!=nil)
- {
-
- [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
-
- UIImage * img =[UIImage imageWithData:downloadimg_data];
- cell.sign_img.image=img ;
- }
- else {
- if (cell.sign_img.userInteractionEnabled) {
- cell.sign_img.image=[UIImage imageNamed:@"taptosign_s"];
- } else {
- cell.sign_img.image = nil;
- }
- }
-
-
- });
- });
-
-
- }
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
-
-
- }
- }
- break;
- case 1:
- {
- NSString *CellIdentifier = @"OrderDetailHtmlCell";
- OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
-
-
-
- cell.webview.tag = indexPath.section;
- cell.webview.delegate = self;
- // cell.webView.scrollView.contentSize.height = 0;
- cell.webview.scrollView.bounces=NO;
- cell.webview.scrollView.directionalLockEnabled = true;
- CGSize size= cell.webview.scrollView.contentSize;
- size.height=10;
- cell.webview.scrollView.contentSize=size;
-
-
-
- [cell.webview loadHTMLString:[self.content_data valueForKey:@"more_order_info"] baseURL:nil];
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
-
-
- // NSString *CellIdentifier = @"OrderDetailInfoCell";
- // OrderDetailInfoCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- //
- // cell.infoLabel.text =[self.content_data valueForKey:@"more_order_info"];
- //
- //
- //
- //// float width = tableView.frame.size.width;
- //// width-=CELL_MARGIN*2;
- //// CGSize constraintkey = CGSizeMake(width-2*LABEL_MARGIN, 10.0f);//key label width is 40% cell width;
- ////
- //// NSString* key =[self.content_data valueForKey:@"order_info"];
- ////
- ////
- ////
- //// CGRect frame;
- //// frame.size = constraintkey;
- //// frame.origin.x=0;
- //// frame.origin.y=0;
- ////
- //// RTLabel* rtlabel = [[RTLabel alloc] initWithFrame:frame];
- ////
- //// [rtlabel setText: key];
- //// CGSize optimumSize = [rtlabel optimumSize];
- ////
- //// float height = optimumSize.height;
- //// height = MAX(height+LINE_WIDTH+2*LABEL_MARGIN, DEF_CELL_HEIGHT);
- ////
- ////
- //// frame.origin.x=LABEL_MARGIN;
- //// frame.size=CGSizeMake(width, height);
- ////
- //// cell.infoLabel.frame = frame;
- //
- //
- //
- //
- // cell.backgroundColor = [UIColor whiteColor];
- // return cell;
- }
- break;
- case 2:
- {
- NSString *CellIdentifier = @"OrderDetailModelCell";
- OrderDetailModelCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
-
- int count = [[item_json valueForKey:@"count"] intValue];
- NSDictionary * combine_json =[item_json objectForKey:@"combine"];
- cell.bundle_item=combine_json;
-
- NSDictionary * master_json = [item_json objectForKey:@"combine_master"];
- if (cell.masterBtn != nil) {
- if (master_json == nil) {
- cell.masterBtn.hidden = YES;
- } else{
- cell.masterBtn.hidden = NO;
- cell.master_items = master_json;
- }
- }
-
- double dprice=0.0;
-
- if(cell.bundle_item!=nil)
- {
- int citem=0;
-
- int bcount=[[cell.bundle_item valueForKey:@"count"] intValue];
- for(int bc=0;bc<bcount;bc++)
- {
- NSDictionary * bitem = [cell.bundle_item objectForKey:[NSString stringWithFormat:@"item_%d",bc]];
- int modulus= [[bitem valueForKey:@"modulus"] intValue];
- citem+= modulus;
- double uprice= [[bitem valueForKey:@"unit_price"]doubleValue];
- dprice+= uprice*modulus;
-
- }
- if(citem==1)
- [ cell.buttonBundle setTitle:[NSString stringWithFormat: @"%d bundle item with price of $ %.2f",citem,dprice ]forState:UIControlStateNormal];
- else
- [ cell.buttonBundle setTitle:[NSString stringWithFormat: @"%d bundle items with price of $ %.2f",citem,dprice ]forState:UIControlStateNormal];
-
- cell.buttonBundle.hidden = NO;
- }
- else
- {
- cell.buttonBundle.hidden = YES;
-
- }
-
-
-
- NSString* img_url = [item_json valueForKey:@"img"];
- NSString* description = [item_json valueForKey:@"Item Number"];
- // NSString* description = [item_json valueForKey:@"Item Number"];
- NSString* unitprice = [item_json valueForKey:@"The unit price"];
- NSString* origin_price = [item_json valueForKey:@"origin_price"];
- NSString* subtotal = [item_json valueForKey:@"Subtotal"];
- NSString* qty = [item_json valueForKey:@"QTY"];
- NSString* status = [item_json valueForKey:@"order_item_status"];
- NSString* notes = [item_json valueForKey:@"note"];
-
- if(notes.length>0)
- {
- cell.noteLabel.text = [@"Note: " stringByAppendingString:[notes stringByReplacingOccurrencesOfString:@"\n" withString:@" "]];
- }
- else
- cell.noteLabel.text = nil;
- if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
- {
-
- }
- else
- {
- unitprice=nil;
- origin_price=nil;
- subtotal=nil;
- }
-
- float duprice = [unitprice floatValue];
- float dsubtotal = (duprice+dprice)*[qty intValue];
-
- cell.descriptionLabel.text=description;
- if(dprice>0)
- cell.unitpriceLabel.text = [NSString stringWithFormat:@"%.2f+%.2f",duprice,dprice];//unitprice;
- else
- cell.unitpriceLabel.text = [NSString stringWithFormat:@"%.2f",duprice];//unitprice;
- cell.subtotalLabel.text = [NSString stringWithFormat:@"%.2f",dsubtotal];//subtotal;
- cell.qtyLabel.text = qty;
- cell.statusLabel.text = status;
-
-
- cell.labelOldPrice.text = origin_price;
-
- double discount =[[item_json valueForKey:@"discount"] doubleValue];
- NSString* discountstr=[NSString stringWithFormat:@"%@%% off", [RAUtils FloatFormat:discount]];
- cell.labelDiscount.text = discountstr;
- bool isfree = [[item_json valueForKey:@"is_free"]boolValue];
- if(isfree)
- {
- cell.labelOldPrice.hidden = false;
- cell.labelOldPrice.textColor = [UIColor redColor];
- cell.labelOldPrice.text=@"Free";
- cell.labelOldPrice.hideline = true;
-
- cell.labelDiscount.hidden = true;
- }
- else
- {
- cell.labelOldPrice.textColor = [UIColor blackColor];
- cell.labelOldPrice.hideline = false;
- if(discount==0)
- {
- cell.labelOldPrice.hidden = true;
- cell.labelDiscount.hidden = true;
-
- }
- else
- {
- cell.labelOldPrice.hidden = false;
- cell.labelDiscount.hidden = false;
- }
- }
-
- // Button 设置了大小约束,Size就不会随内容变化
- [cell.imgbtn setContentMode:UIViewContentModeScaleAspectFit];
- [cell.imgbtn setContentEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
- [cell.imgbtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentFill];
- [cell.imgbtn setContentVerticalAlignment:UIControlContentVerticalAlignmentFill];
- cell.imgbtn.imageView.contentMode = UIViewContentModeScaleAspectFit;
-
- if (![cell.imageName isEqualToString:img_url]) {
- cell.imageName = img_url;
- // [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
- [cell.imgbtn setImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
-
- NSString* file_name=[img_url lastPathComponent];
- NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
- if(img_data!=nil)
- {
-
- UIImage * img =[UIImage imageWithData:img_data];
- // [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
- [cell.imgbtn setImage:img forState:UIControlStateNormal];
- }
- else
- {
-
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
-
-
- if(downloadimg_data!=nil)
- {
-
- [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
-
- UIImage * img =[UIImage imageWithData:downloadimg_data];
- // [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
- [cell.imgbtn setImage:img forState:UIControlStateNormal];
- }
- else
- // [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
- [cell.imgbtn setImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
-
-
- });
- });
-
-
- }
- }
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
-
- }
- break;
-
- case 3:
- {
- NSString *CellIdentifier = @"OrderDetailPriceCell";
- OrderDetailPriceCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
- switch (indexPath.row) {
- case 0:
- {
- cell.chargeLabel.text =@"Sub-Total:";
- NSString* price=[self.content_data valueForKey:@"Sub-Total"];
- if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
- {
-
- }
- else
- {
- price=nil;
- }
- cell.priceLabel.text =price;
- break;
- }
- case 1:
- cell.chargeLabel.text = @"Shipping:";
- cell.priceLabel.text =[self.content_data valueForKey:@"Shipping"];
- break;
- case 2: {
- #ifdef BUILD_NPD
- cell.chargeLabel.text = @"Liftgate Fee(No loading dock):";
- cell.priceLabel.text =[self.content_data valueForKey:@"Liftgate Fee(No loading dock)"];
- #endif
-
- #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
- cell.chargeLabel.text = @"Liftgate Fee(No loading dock):";
- cell.priceLabel.text =[self.content_data valueForKey:@"Liftgate Fee(No loading dock)"];
- #endif
-
- #ifdef BUILD_HMLG
- cell.chargeLabel.text = @"Tax:";
- NSString *tax = [self.content_data valueForKey:@"Tax"] ? [self.content_data valueForKey:@"Tax"] : @"$0.00";
- cell.priceLabel.text = tax;
- #endif
- }
- break;
- case 3: {
- #ifdef BUILD_NPD
- cell.chargeLabel.text = @"Handling Fee:";
- cell.priceLabel.text =[self.content_data valueForKey:@"Handling Fee"];
- #endif
- #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
- cell.chargeLabel.text = @"Handling Fee:";
- cell.priceLabel.text =[self.content_data valueForKey:@"Handling Fee"];
- #endif
- #ifdef BUILD_HMLG
- NSString* price=[self.content_data valueForKey:@"Total"];
- if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
- {
-
- }
- else
- {
- price=nil;
- }
- cell.chargeLabel.text = @"Total:";
- cell.priceLabel.text =price;
- #endif
-
- }
- break;
- case 4: {
- cell.chargeLabel.text = @"Tax:";
- NSString *tax = [self.content_data valueForKey:@"Tax"] ? [self.content_data valueForKey:@"Tax"] : @"$0.00";
- cell.priceLabel.text = tax;
- }
- break;
- case 5:
- {
- NSString* price=[self.content_data valueForKey:@"Total"];
- if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
- {
-
- }
- else
- {
- price=nil;
- }
- cell.chargeLabel.text = @"Total:";
- cell.priceLabel.text =price;
- break;
- }
- default:
- break;
- }
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
- }
- }
- #endif
- return nil;
- // if(tableView==self.itemListTable)
- // {
- // NSString *CellIdentifier = @"CartItemCell";
- // ModelItemCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
- // NSDictionary * combine_json =[item_json objectForKey:@"combine"];
- //
- // cell.bundle_item=combine_json;
- // NSString* img_url = [item_json valueForKey:@"img_url"];
- // NSString* description = [item_json valueForKey:@"description"];
- // // NSString* identifier = [item_json valueForKey:@"identifier"];
- // // NSString* attribute = [item_json valueForKey:@"attribute"];
- // NSString* currency = [item_json valueForKey:@"currency"];
- // int count =[[item_json valueForKey:@"count"] intValue];
- //
- // int stockUom =[[item_json valueForKey:@"stockUom"] intValue];
- //
- // double totalprice =[[item_json valueForKey:@"subtotal_price"] doubleValue];
- //
- // double unitprice=[[item_json valueForKey:@"unit_price"] doubleValue];
- // cell.unit_price = unitprice;
- // // cell.labelAttribute.text = attribute;
- // // cell.labelCurrency.text = currency;
- // cell.labelDescription.text = description;
- // // cell.labelIdentifier.text = identifier;
- // cell.labelPrice.text = [NSString stringWithFormat:@"%.2f",totalprice];
- //
- // cell.labelUnitPrice.text = [NSString stringWithFormat:@"%.2f",unitprice];
- //
- //
- //
- // NSString* cart_item_id= [item_json valueForKey:@"cart_item_id"];
- // cell.cart_id = cart_item_id;
- // [cell init_Stepper:stockUom max:9999 min:stockUom value:count];
- //
- //
- //
- // [cell set_Count:count];
- //
- // NSString* file_name=[img_url lastPathComponent];
- // NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
- // if(img_data!=nil)
- // {
- //
- // UIImage * img =[UIImage imageWithData:img_data];
- // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
- // }
- // else
- // {
- //
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- //
- //
- // if(downloadimg_data!=nil)
- // {
- // [iSalesDB cache_img:downloadimg_data :file_name ];
- //
- // UIImage * img =[UIImage imageWithData:downloadimg_data];
- // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
- // }
- //
- // });
- // });
- //
- //
- // }
- // return cell;
- // }
- // else
- // {
- // NSString *CellIdentifier = @"OrderInfoListItem";
- // UITableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- // return cell;
- // }
- }
- #pragma mark - UIAlertViewDelegate
- // Called when a button is clicked. The view will be automatically dismissed after this call returns
- - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- {
-
- if(buttonIndex!=alertView.cancelButtonIndex)
- {
- [self copyOrder];
- }
- }
- - (void)copyOrder {
-
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Copy Order"];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* order_json = [RANetwork copy_Order:self.order_code];
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- if([[order_json valueForKey:@"result"] intValue]==2)
- {
- // NSString* orderCode = [order_json valueForKey:@"orderCode"];
-
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // if([appDelegate.order_code isEqualToString: self.order_code])
- // {
- // [appDelegate closeOrder];
- //// appDelegate.order_code= nil;
- // [appDelegate SetSo:nil];
- //
- //
- // }
- 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];
-
- [alert show];
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- [self.navigationController popViewControllerAnimated:false];
-
- }
- else
- {
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Cpoy Order" controller:self] ;
- }
-
-
-
- });
- });
- }
- #pragma mark - web view delegate
- //- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
- //{
- // if(navigationType != UIWebViewNavigationTypeLinkClicked)
- // return true;
- // // NSString *currentURL =[webView.request.URL lastPathComponent];// [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
- //
- // NSString* str = request.URL.absoluteString;
- // if([str isEqualToString:@"about:blank"])
- // return true;
- // WebViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"WebViewController"];
- // ViewController.url = str;
- // // ViewController. = self.function_name;
- // // ViewController.behavior =BEHAVIOR_SEARCH;
- //
- // [self.navigationController pushViewController:ViewController animated:YES];
- // DebugLog(@"shouldStartLoadWithRequest");
- // return false;
- //}
- - (void)webViewDidFinishLoad:(UIWebView *)webView
- {
-
-
- DebugLog(@"webViewDidFinishLoad @@@@@@@@@@@@@@@@@ entry");
-
-
-
- UITableViewCell *cell = (UITableViewCell *)[[webView superview] superview];
-
-
- NSIndexPath *indexPath = [self.detailTable indexPathForCell:cell];
- if(indexPath==nil)
- {//for ios7
- cell = (UITableViewCell *) webView.superview.superview.superview;
- indexPath = [self.detailTable indexPathForCell:cell];
- }
- if(indexPath==nil)
- return;
- float height= 0;
- if(indexPath.section==0)
- height=self.web_info_height;
- else
- height = self.web_moreinfo_height;
-
- // if(height>0)
- // return;
-
-
- // UIScrollView *scrollerView = [webView.subviews objectAtIndex:0];
- // CGSize size= webView.scrollView.contentSize;
- // CGSize fittingSize = [webView sizeThatFits:CGSizeZero];
-
- CGRect frame = webView.frame;
- NSString *fitHeight = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight;"];
- //
- if(height==[fitHeight floatValue])
- return;
- frame.size.height = [fitHeight floatValue];
- //webView.frame = frame;
-
-
- // DebugLog(@"webViewDidFinishLoad ^^^^^^^^^^^^^^^^^Saveheight height=%f section=%ld",webView.scrollView.contentSize.height,indexPath.section);
-
- if(indexPath.section==0)
- self.web_info_height=frame.size.height;
- else
- self.web_moreinfo_height = frame.size.height;
- // [self.content.webviewHeight setObject:[NSString stringWithFormat:@"%f",frame.size.height/*webView.scrollView.contentSize.height*/] forKey:[NSString stringWithFormat:@"%ld",(long)indexPath.section]];
-
- DebugLog(@"webViewDidFinishLoad ^^^^^^^^^^^^^^^^^reloadRowsAtIndexPaths");
-
-
- dispatch_async(dispatch_get_main_queue(), ^{
- // UI更新代码
- // [self.detailTable reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
- [self.detailTable reloadData];
- //[self.editorTable reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
- });
-
- // [self.table beginUpdates];
- // [self.table endUpdates];
-
- // [self.webviewoprationQueue addOperationWithBlock:^{
- // }];
-
-
- // [self.table endUpdates];
- // }
-
-
- }
- @end
|