| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336 |
- //
- // 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 = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] 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];
-
- }
- #ifndef RA_NOTIFICATION
- -(void) reload_container_getdata:(bool) update_data
- {
-
- [super reload_container_getdata:update_data];
- if(update_data)
- [self reload_data];
- else
- {
- [self.detailTable reloadData];
-
- }
- }
- #endif
- - (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)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);
-
- #if defined(BUILD_NPD) || defined(BUILD_USAI)|| defined (BUILD_CONTRAST)
- self.btnCopy =[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"order_copy"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(onCopyOrderClick:)];
- #else
- 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);
- #endif
- // 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 && appDelegate.customer_type == CustomerTypeCustomer) || appDelegate.user_type == USER_ROLE_EMPLOYEE) {
- [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) {
- __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order" completion:^{
- [RANetwork request_release_order:self.order_code withScreen:ScreenCodeOrderInfo completionHandler:^(NSMutableDictionary *result) {
- NSDictionary* order_json =result;
- [waitalert dismissViewControllerAnimated:YES completion:^{
- 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] ;
- }
- }];
-
-
-
- }];
- }];
-
- // 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 dismissViewControllerAnimated:YES completion:nil];
- // 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 {
- //
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- RAPDFViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] 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;
-
- #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)|| defined (BUILD_CONTRAST)
- 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
-
- #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)
- {
- __weak typeof(self) weakself = self;
- NSMutableDictionary* params = [@{
- @"thumb" : @"1",
- @"order_code" : self.order_code != nil ? self.order_code : @"",
- @"user":appDelegate.user
- } 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)
- {
- __weak typeof(self) weakself = self;
- NSMutableDictionary* params = [@{
- @"thumb" : @"0",
- @"order_code" : self.order_code != nil ? self.order_code : @"",
- @"user":appDelegate.user
- } 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) {
-
- __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Release Order" completion:^{
- [RANetwork request_release_order:appDelegate.order_code withScreen:ScreenCodeOrderInfo completionHandler:^(NSMutableDictionary *result) {
- NSDictionary* order_json = result;
- [waitalert dismissViewControllerAnimated:YES completion:^{
- 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] ;
- }
- }];
- }];
- }];
-
-
- // 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 dismissViewControllerAnimated:YES completion:nil];
- // 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 {
-
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Copy confirm" message:@"Are you sure to copy order?" preferredStyle:UIAlertControllerStyleAlert];
-
-
- UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"YES" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- [self copyOrder];
-
- }];
- UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"NO" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
-
-
- }];
-
- [alertController addAction:action_2];
- [alertController addAction:action_3];
-
-
- [self presentViewController:alertController animated:YES completion:nil];
-
- // 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
- {
-
-
- #ifdef OFFLINE_MODE
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- 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"];
-
- {
- __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Signature" completion:^{
- [RANetwork request_update_order_signature:self.order_code path:img_url_up completionHandler:^(NSMutableDictionary *result) {
- NSDictionary* order_json = result;
- [waitalert dismissViewControllerAnimated:YES completion:^{
- 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);
- #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)|| defined (BUILD_CONTRAST)
- 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] ;
- }
- }];
-
-
-
-
- }];
- }];
-
- // 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 dismissViewControllerAnimated:YES completion:nil];
- // 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);
- //#if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
- // 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;
- __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Signature" completion:^{
- [RANetwork request_fastupload:params filename:@"test.jpg" data:imageData url:URL_UPLOAD_IMG completionHandler:^(NSMutableDictionary *result) {
- NSMutableDictionary *json=result;
- if([[json valueForKey:@"result"] intValue]==2)
- {
- NSString* img_url_down = json[@"img_url_aname"];
- NSString* img_url_up = json[@"img_url"];
- {
- // UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Signature"];
- [RANetwork request_update_order_signature:self.order_code path:img_url_up completionHandler:^(NSMutableDictionary *result) {
- NSDictionary* order_json =result;
- [waitalert dismissViewControllerAnimated:YES completion:^{
- if([[order_json valueForKey:@"result"] intValue]==2)
- {
-
- #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)|| defined (BUILD_CONTRAST)
- 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] ;
- }
- }];
-
-
-
-
- }];
-
- // 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 dismissViewControllerAnimated:YES completion:nil];
- // if([[order_json valueForKey:@"result"] intValue]==2)
- // {
- //
- //#if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
- // 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
- {
- dispatch_async(dispatch_get_main_queue(), ^{
-
- [waitalert dismissViewControllerAnimated:YES completion:^{
- NSString *msg = [json valueForKey:@"err_msg"];
- if (msg.length == 0) {
- msg = [json objectForKey:@"msg"];
- }
-
- [RAUtils message_alert:msg title:@"Upload Image" controller:weakSelf] ;
- }];
- });
- }
-
- }];
- }];
-
-
-
- // [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"];
- // {
- //// UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Signature"];
- // [RANetwork request_update_order_signature:self.order_code path:img_url_up completionHandler:^(NSMutableDictionary *result) {
- // NSDictionary* order_json =result;
- // [waitalert dismissViewControllerAnimated:YES completion:nil];
- // if([[order_json valueForKey:@"result"] intValue]==2)
- // {
- //
- //#if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
- // 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] ;
- // }
- //
- //
- //
- // }];
- //
- //// 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 dismissViewControllerAnimated:YES completion:nil];
- //// if([[order_json valueForKey:@"result"] intValue]==2)
- //// {
- ////
- ////#if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
- //// 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
- // {
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // [waitalert dismissViewControllerAnimated:YES completion:nil];
- // NSString *msg = [json valueForKey:@"err_msg"];
- // if (msg.length == 0) {
- // msg = [json objectForKey:@"msg"];
- // }
- //
- // [RAUtils message_alert: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"];
- //
- // {
- // UIAlertController * waitalert = [RAUtils waiting_alert:self 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 dismissViewControllerAnimated:YES completion:nil];
- // 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);
- //
- //#if defined(BUILD_NPD) || defined(BUILD_USAI)
- // 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 dismissViewControllerAnimated:YES completion:nil];
- // }];
- //
- // [uploadTask resume];
- }
-
- }
- - (IBAction)onSignOrderClick:(id)sender {
-
- AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
- if (appDelegate.order_code.length > 0 && [self.order_code isEqualToString:appDelegate.order_code]) {
-
- [self showSignaturePanel];
-
- } else {
-
- UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:@"you need open the order first" preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- }];
-
- [alertVC addAction:cancelAction];
-
- __weak typeof(self) weakSelf = self;
- UIAlertAction *openAction = [UIAlertAction actionWithTitle:@"Open" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- [self opentOrder:^{
-
- [weakSelf showSignaturePanel];
- }];
-
- }];
-
- [alertVC addAction:openAction];
-
- [self presentViewController:alertVC animated:YES completion:nil];
-
- }
-
-
- }
- - (void)showSignaturePanel {
-
- __block UIImage* signimg=nil;
- SignatureViewController * vc =[ [UIStoryboard storyboardWithName:@"signature" bundle:nil] instantiateViewControllerWithIdentifier:@"SignatureViewController"];
-
- vc.onReturnImg = ^(UIImage* img)
- {
- signimg = img;
-
- if(signimg!=nil)
- [self upload_img:signimg];
-
-
- };
-
- [self.navigationController pushViewController:vc animated:NO];
- }
- - (void)opentOrder:(void(^)(void))completionBlk {
-
- __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Open Order" completion:^{
- [RANetwork request_open_order:self.order_code completionHandler:^(NSMutableDictionary *result) {
- NSDictionary* order_json = result;
-
- [waitalert dismissViewControllerAnimated:YES completion:^{
- 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];
-
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"CartViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- #else
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
- #endif
-
- if (completionBlk) {
- completionBlk();
- }
-
- // if(self.selectOrder)
- // self.selectOrder(self.content_data);
- }
- else
- {
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
- }
- }];
-
-
-
-
-
- }];
- }];
- // 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 dismissViewControllerAnimated:YES completion:nil];
- // 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];
- //
- //#ifdef RA_NOTIFICATION
- // [ActiveViewController Notify:@"CartViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- //#else
- //// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- // [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
- //#endif
- //
- // if (completionBlk) {
- // completionBlk();
- // }
- //
- //// if(self.selectOrder)
- //// self.selectOrder(self.content_data);
- // }
- // else
- // {
- // [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:self] ;
- // }
- //
- //
- //
- // });
- // });
-
- }
- - (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) {
- [self opentOrder:^{
-
- [self.navigationController popViewControllerAnimated:false];
-
- if(self.selectOrder)
- self.selectOrder(self.content_data);
- }];
-
-
- }];
-
- 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
- {
- // UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Loading"];
-
-
- __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Loading" completion:^{
- // 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;
-
- NSMutableDictionary *params = [NSMutableDictionary dictionary];
-
- [params setValue:self.orderid forKey:@"orderId"];
- if (self.erpSerialNo) {
- [params setValue:self.erpSerialNo forKey:@"erp_order_serial_no"];
- }
- [RANetwork request_orderdetail:params completionHandler:^(NSMutableDictionary *result) {
- NSDictionary* order_json = result;
-
-
- [waitalert dismissViewControllerAnimated:YES completion:^{
- [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 || (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeCustomer))
- 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;
-
- if (self.order_code == nil) {
- self.btnCopy.enabled = false;
- } else {
- self.btnCopy.enabled = true;
- }
- }];
-
-
-
- }];
-
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- //
- // NSDictionary* order_json = [RANetwork request_OrderDetail:params];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // [waitalert dismissViewControllerAnimated:YES completion:nil];
- // [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 || (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeCustomer))
- // 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;
- //
- // if (self.order_code == nil) {
- // self.btnCopy.enabled = false;
- // } else {
- // self.btnCopy.enabled = true;
- // }
- //
- // });
- //
- // });
- // });
- }];
-
- }
- - (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 {
-
- // 这里有问题,npd 里order 提交后,product id 为空,暂时屏蔽掉
- return;
- // 以下为屏蔽前的代码
- //
- // 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[[NSString stringWithFormat:@"section_%ld",(long)indexPath.section]][@"data"][[NSString stringWithFormat:@"item_%ld",(long)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 = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Model" bundle:nil] 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;
-
-
- #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)|| defined (BUILD_CONTRAST)
- 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;
-
- #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)|| defined (BUILD_CONTRAST)
- 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];
-
- */
- #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)|| defined (BUILD_CONTRAST)
- 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;
- #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)|| defined (BUILD_CONTRAST)
- return [[self.content_data objectForKey:@"count"] integerValue];
- #endif
-
- //#ifdef BUILD_USAI
- // 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
- return 4;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 33;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)|| defined (BUILD_CONTRAST)
-
- 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) {
- #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)|| defined (BUILD_CONTRAST)
- 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];
-
- #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)|| defined (BUILD_CONTRAST)
- /**
- * 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.html = nil;
-
-
-
- cell.wkwebview.tag = indexPath.section;
-
- cell.wkwebview.navigationDelegate = self;
- // cell.webView.scrollView.contentSize.height = 0;
- cell.wkwebview.scrollView.bounces=NO;
- cell.wkwebview.scrollView.directionalLockEnabled = true;
- CGSize size= cell.wkwebview.scrollView.contentSize;
- size.height=10;
- cell.wkwebview.scrollView.contentSize=size;
- cell.backgroundColor = [UIColor whiteColor];
-
- cell.wkwebview.userInteractionEnabled = YES;
-
- cell.html =[section valueForKey:@"data"];
- NSLog(@"webview loadHTMLString 0");
- [cell.wkwebview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
- NSLog(@"webview loadHTMLString 1");
- 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.wkwebview.tag = indexPath.section;
- cell.wkwebview.navigationDelegate = self;
- // cell.webView.scrollView.contentSize.height = 0;
- cell.wkwebview.scrollView.bounces=NO;
- cell.wkwebview.scrollView.directionalLockEnabled = true;
- CGSize size= cell.wkwebview.scrollView.contentSize;
- size.height=10;
- cell.wkwebview.scrollView.contentSize=size;
-
-
-
- NSLog(@"webview loadHTMLString 3");
- [cell.wkwebview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
- NSLog(@"webview loadHTMLString 4");
-
- 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;
- //
- //
- //
-
- NSString *CellIdentifier = @"OrderDetailHtmlCell";
- OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
- cell.html = nil;
-
-
-
- cell.wkwebview.tag = indexPath.section;
-
- cell.wkwebview.navigationDelegate = self;
- // cell.webView.scrollView.contentSize.height = 0;
- cell.wkwebview.scrollView.bounces=NO;
- cell.wkwebview.scrollView.directionalLockEnabled = true;
- CGSize size= cell.wkwebview.scrollView.contentSize;
- size.height=10;
- cell.wkwebview.scrollView.contentSize=size;
- cell.backgroundColor = [UIColor whiteColor];
-
- cell.wkwebview.userInteractionEnabled = YES;
-
- cell.html =[section valueForKey:@"data"];
- NSLog(@"webview loadHTMLString 0");
- [cell.wkwebview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
- NSLog(@"webview loadHTMLString 1");
- 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;
-
-
- NSString *CellIdentifier = @"OrderDetailHtmlCell";
- OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
-
-
-
- cell.wkwebview.tag = indexPath.section;
- cell.wkwebview.navigationDelegate = self;
- // cell.webView.scrollView.contentSize.height = 0;
- cell.wkwebview.scrollView.bounces=NO;
- cell.wkwebview.scrollView.directionalLockEnabled = true;
- CGSize size= cell.wkwebview.scrollView.contentSize;
- size.height=10;
- cell.wkwebview.scrollView.contentSize=size;
-
-
-
- NSLog(@"webview loadHTMLString 3");
- [cell.wkwebview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
- NSLog(@"webview loadHTMLString 4");
-
- 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.html = nil;
-
- cell.wkwebview.tag = indexPath.section;
-
- cell.wkwebview.navigationDelegate = self;
- // cell.webView.scrollView.contentSize.height = 0;
- cell.wkwebview.scrollView.bounces=NO;
- cell.wkwebview.scrollView.directionalLockEnabled = true;
- CGSize size= cell.wkwebview.scrollView.contentSize;
- size.height=10;
- cell.wkwebview.scrollView.contentSize=size;
-
- cell.backgroundColor = [UIColor whiteColor];
-
- cell.wkwebview.userInteractionEnabled = YES;
-
- cell.html =[self.content_data valueForKey:@"order_info"];
- [cell.wkwebview loadHTMLString:[self.content_data valueForKey:@"order_info"] baseURL:nil];
-
- // [cell.wkwebview loadHTMLString:[self.content_data valueForKey:@"order_info"] baseURL:nil];
-
- // cell.backgroundColor = [UIColor whiteColor];
- return cell;
-
-
- //
- // NSString *CellIdentifier = @"OrderDetailHtmlCell";
- // OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- //
- // cell.html = nil;
- //
- //
- //
- // cell.wkwebview.tag = indexPath.section;
- //
- // cell.wkwebview.navigationDelegate = self;
- // // cell.webView.scrollView.contentSize.height = 0;
- // cell.wkwebview.scrollView.bounces=NO;
- // cell.wkwebview.scrollView.directionalLockEnabled = true;
- // CGSize size= cell.wkwebview.scrollView.contentSize;
- // size.height=10;
- // cell.wkwebview.scrollView.contentSize=size;
- // cell.backgroundColor = [UIColor whiteColor];
- //
- // cell.wkwebview.userInteractionEnabled = YES;
- //
- // cell.html =[section valueForKey:@"data"];
- // NSLog(@"webview loadHTMLString 0");
- // [cell.wkwebview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
- // NSLog(@"webview loadHTMLString 1");
- //
- // 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.wkwebview.tag = indexPath.section;
- cell.wkwebview.navigationDelegate = self;
- // cell.webView.scrollView.contentSize.height = 0;
- cell.wkwebview.scrollView.bounces=NO;
- cell.wkwebview.scrollView.directionalLockEnabled = true;
- CGSize size= cell.wkwebview.scrollView.contentSize;
- size.height=10;
- cell.wkwebview.scrollView.contentSize=size;
-
-
-
- NSLog(@"webview loadHTMLString 3");
- [cell.wkwebview loadHTMLString:[self.content_data valueForKey:@"more_order_info"] baseURL:nil];
- NSLog(@"webview loadHTMLString 4");
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
-
-
- // 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;
-
- // { /** More Info */
- //
- // NSString *CellIdentifier = @"OrderDetailHtmlCell";
- // OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- //
- //
- //
- //
- // cell.wkwebview.tag = indexPath.section;
- // cell.wkwebview.navigationDelegate = self;
- // // cell.webView.scrollView.contentSize.height = 0;
- // cell.wkwebview.scrollView.bounces=NO;
- // cell.wkwebview.scrollView.directionalLockEnabled = true;
- // CGSize size= cell.wkwebview.scrollView.contentSize;
- // size.height=10;
- // cell.wkwebview.scrollView.contentSize=size;
- //
- //
- //
- // NSLog(@"webview loadHTMLString 3");
- // [cell.wkwebview loadHTMLString:[section valueForKey:@"data"] baseURL:nil];
- // NSLog(@"webview loadHTMLString 4");
- //
- // 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: {
- #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)|| defined (BUILD_CONTRAST)
- 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: {
- #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)|| defined (BUILD_CONTRAST)
- 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 {
-
- __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Copy Order" completion:^{
- [RANetwork request_copy_order:self.order_code completionHandler:^(NSMutableDictionary *result) {
- NSDictionary* order_json = result;
- [waitalert dismissViewControllerAnimated:YES completion:^{
- 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];
- //
- //
- // }
-
- [RAUtils message_alert:[NSString stringWithFormat:@"New order SO#: %@",[order_json valueForKey:@"so_id"]] title:@"Copy successful." controller:self];
-
- // 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];
- //
-
-
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- #else
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- #endif
-
- [self.navigationController popViewControllerAnimated:false];
-
- }
- else
- {
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Cpoy Order" controller:self] ;
- }
- }];
-
-
-
-
-
- }];
- }];
- // 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 dismissViewControllerAnimated:YES completion:nil];
- // 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];
- //
- //
- //
- //#ifdef RA_NOTIFICATION
- // [ActiveViewController Notify:@"OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- //#else
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- //#endif
- //
- // [self.navigationController popViewControllerAnimated:false];
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Cpoy Order" controller:self] ;
- // }
- //
- //
- //
- // });
- // });
- }
- - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
- {
- // message.body -- Allowed types are NSNumber, NSString, NSDate, NSArray,NSDictionary, and NSNull.
- NSLog(@"%@",message.name);
- NSLog(@"body:%@",message.body);
- }
- #pragma mark - WKNavigationDelegate
- - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
- {
- NSLog(@"webview didFinishNavigation");
-
- // [webView evaluateJavaScript:@"document.documentElement.outerHTML.toString()" completionHandler:^(id _Nullable html ,NSError * _Nullable error) {
- //
- // NSLog(html);
- // }];
-
- 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];
-
-
- [webView evaluateJavaScript:@"document.body.scrollHeight;" completionHandler:^(id _Nullable fitHeight,NSError * _Nullable error) {
-
- NSLog(@"webview evaluateJavaScript");
- CGRect frame = webView.frame;
- if(height==[fitHeight floatValue])
- {
- NSLog(@"webview return no need reload table");
-
-
- 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]];
-
- NSLog(@"webview need call table reload");
-
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
-
- NSLog(@"reload tableview!!! %f",frame.size.height);
- // UI更新代码
- // [self.detailTable reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
- // [self.detailTable reloadData];
-
- [self.detailTable reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationNone];
- // [self performSelector:@selector(rtable) withObject:nil afterDelay:1];
-
- //[self.editorTable reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
- });
- }];
-
- //
- // NSString *fitHeight = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight;"];
- //
-
-
- // [self.table beginUpdates];
- // [self.table endUpdates];
-
- // [self.webviewoprationQueue addOperationWithBlock:^{
- // }];
-
-
- // [self.table endUpdates];
- // }
-
-
-
- }
- //-(void) rtable
- //{
- // [self.detailTable reloadData];
- //}
- ////禁止链接跳转
- //- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
- //
- // NSLog(@"%s",__func__);
- // NSLog(@"navigationAction = %@, \r!!!!!!!!!!!!!!!!!!!!!!\n request = %@",navigationAction,navigationAction.request.URL);
- //
- //// NSString *url = navigationAction.request.URL.absoluteString;
- //// if (![url containsString:[NSBundle mainBundle].bundleURL.absoluteString]) {
- //// self.url = url;
- //// }
- //
- //
- //
- //
- //
- //
- // if (navigationAction.navigationType != WKNavigationTypeLinkActivated ) {
- // return decisionHandler(WKNavigationActionPolicyAllow);
- // }
- //
- // if ([[UIApplication sharedApplication] canOpenURL:navigationAction.request.URL]) {
- // [[UIApplication sharedApplication] openURL:navigationAction.request.URL];
- // }
- //
- // return decisionHandler(WKNavigationActionPolicyCancel);
- //}
- #pragma mark - web view delegate
- - (void)reRefreshView {
- [self.detailTable reloadData];
- }
- #pragma mark - RA_NOTIFICAITON
- -(void) refresh_ui
- {
- [self.detailTable reloadData];
- }
- -(void) reload_data
- {
-
- UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
-
- [reF endRefreshing];
-
- reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
-
- [self loaddata];
- }
- -(void) refresh_price
- {
- [self refresh_ui];
- }
- @end
|