| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612 |
- //
- // ViewController.m
- // RedAnt ERP Suite
- //
- // Created by Ray on 14-5-19.
- // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
- //
- #import "MainViewController.h"
- //#import "SideMenuViewController.h"
- //#import "RootContainerViewController.h"
- #import <Accelerate/Accelerate.h>
- #import "PopupNavigationController.h"
- //#import "CommonGridViewController.h"
- #import "CacheViewController.h"
- #import "ScannerViewController.h"
- #import "ContactListViewController.h"
- #import "RAUtils.h"
- #import "AboutViewController.h"
- #import "ScannerSettingViewController.h"
- #import "ActiveViewController.h"
- #import "WebViewController.h"
- #import "FunctionTestViewController.h"
- #import "SimplifiedBuyingProgramViewController.h"
- #import "UserListViewController.h"
- #import "OfflineSettingViewController.h"
- #import "DefaultAppearance.h"
- #import "PriceSettingViewController.h"
- #import "JKLockController.h"
- #import "RASingleton.h"
- #import "NotificationNameCenter.h"
- //#import "OLOSettingViewController.h"
- //#import "ScanHistoryViewController.h"
- #import "CustomerEditViewController.h"
- #import "ScanOrderScanModelViewController.h"
- #import "ScanOrderModelListViewController.h"
- #import "SetupServerViewController.h"
- #import "ScanUserListViewController.h"
- @interface MainViewController ()
- // scan order main frame
- @end
- @implementation MainViewController
- -(void) logoutDocuments
- {
- // [self.pdfListViewController logout];
- }
- -(void) logoutCart
- {
- [self.cartViewController logout];
- RASingleton.sharedInstance.scan_cart = nil;
- RASingleton.sharedInstance.price_type = 1;
- }
- -(void) logoutWish
- {
- // [self.watchListViewController logout];
- }
- -(void) logoutPortfolio
- {
- // [self.portfolioViewController logout];
- }
- -(void) logoutOrder
- {
- [self.scanorderViewController logout];
- }
- -(void) logoutContact
- {
- [self.contactListViewController logout];
- }
- -(void) logoutCategory
- {
- // [self.categoryViewController logout];
- }
- - (IBAction)onScanOrderSetting:(id)sender {
-
- [self clearSelected];
- self.btnsetting.selected = true;
-
- if([self.current_VC isKindOfClass:[ServerSettingViewController class]])
- return;
- [self flipFromViewController:self.current_VC toViewController:self.settingViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
-
-
- }
- //- (IBAction)onSelectSales:(id)sender {
- //
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- //
- //
- //
- // ScanUserListViewController * userVC =[ [UIStoryboard storyboardWithName:@"OLM" bundle:nil] instantiateViewControllerWithIdentifier:@"ScanUserListViewController"];
- // userVC.returnValue=^(NSString* user)
- // {
- //// self.btnContact.hidden = false;
- // appDelegate.user = user;
- // [self.buttonUser setTitle:user forState:UIControlStateNormal];
- //
- // [self refreshContactDisplay];
- ////
- // };
- // // loginvc.delegate = self;
- // // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- //// appDelegate.active_controller = gunVC;
- //// gunVC.onDismissVC = ^(){
- //// appDelegate.active_controller = active_vc;
- //// };
- // UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:userVC] ;
- //
- //
- //
- //
- //
- // // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
- //
- // navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- // [self presentViewController:navi animated:YES completion:^{
- //
- // // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
- //
- // DebugLog(@"about present.........");
- //
- // // self.btop = false;
- // // <#code#>
- // }];
- //
- //
- //
- //
- // [appDelegate update_count_mark];
- //// appDelegate.bLogin = true;
- //}
- #ifndef RA_NOTIFICATION
- -(void) reloadCategory:(BOOL) update_data immediately:(bool)immediately
- {
- if(immediately)
- [ self.categoryViewController reload_container_getdata:update_data];
- else
- {
- if(update_data&&self.categoryViewController.refresh_type<=REFRESH_DATA)
- self.categoryViewController.refresh_type = REFRESH_DATA;
- else if(self.categoryViewController.refresh_type<=REFRESH_VIEW)
- self.categoryViewController.refresh_type = REFRESH_VIEW;
- }
- }
- -(void) reloadDocuments:(BOOL) update_data immediately:(bool)immediately
- {
-
- if(immediately)
- [ self.pdfListViewController reload_container_getdata:update_data];
- else
- {
- if(update_data&&self.pdfListViewController.refresh_type<=REFRESH_DATA)
- self.pdfListViewController.refresh_type = REFRESH_DATA;
- else if(self.pdfListViewController.refresh_type<=REFRESH_VIEW)
- self.pdfListViewController.refresh_type = REFRESH_VIEW;
- }
-
- //[self.pdfListViewController reload_container_getdata:update_data];
- }
- -(void) reloadCart:(BOOL) update_data immediately:(bool)immediately
- {
-
- if(immediately)
- [ self.cartViewController reload_container_getdata:update_data];
- else
- {
- if(update_data&&self.cartViewController.refresh_type<=REFRESH_DATA)
- self.cartViewController.refresh_type = REFRESH_DATA;
- else if(self.cartViewController.refresh_type<=REFRESH_VIEW)
- self.cartViewController.refresh_type = REFRESH_VIEW;
- }
- // [self.cartViewController reload_container_getdata:update_data];
- }
- -(void) reloadWish:(BOOL) update_data immediately:(bool)immediately
- {
- if(immediately)
- [ self.watchListViewController reload_container_getdata:update_data];
- else
- {
- if(update_data&&self.watchListViewController.refresh_type<=REFRESH_DATA)
- self.watchListViewController.refresh_type = REFRESH_DATA;
- else if(self.watchListViewController.refresh_type<=REFRESH_VIEW)
- self.watchListViewController.refresh_type = REFRESH_VIEW;
- }
-
-
- // [self.watchListViewController reload_container_getdata:update_data];
- }
- -(void) reloadPortfolio:(BOOL) update_data immediately:(bool)immediately
- {
- // NSMutableDictionary* dict = [NSMutableDictionary new];
- // dict[@"receiver"]=@[@"PortfolioViewController"];
- // NSString* notificationname = nil;
- // if(update_data)
- // notificationname = RA_NOTIFICATION_RELOAD_DATA;
- // else
- // notificationname = RA_NOTIFICATION_REFRESH_UI;
- // NSNotification *notification =[NSNotification notificationWithName:notificationname object:nil userInfo:dict];
- //
- // //通过通知中心发送通知
- //
- // [[NSNotificationCenter defaultCenter] postNotification:notification];
- // return;
-
-
- if(immediately)
- [ self.portfolioViewController reload_container_getdata:update_data];
- else
- {
- if(update_data&&self.portfolioViewController.refresh_type<=REFRESH_DATA)
- self.portfolioViewController.refresh_type = REFRESH_DATA;
- else if(self.portfolioViewController.refresh_type<=REFRESH_VIEW)
- self.portfolioViewController.refresh_type = REFRESH_VIEW;
- }
- // [self.portfolioViewController reload_container_getdata:update_data];
- }
- -(void) reloadOrder:(BOOL) update_data immediately:(bool)immediately
- {
-
- if(immediately)
- [ self.orderViewController reload_container_getdata:update_data];
- else
- {
- if(update_data&&self.orderViewController.refresh_type<=REFRESH_DATA)
- self.orderViewController.refresh_type = REFRESH_DATA;
- else if(self.orderViewController.refresh_type<=REFRESH_VIEW)
- self.orderViewController.refresh_type = REFRESH_VIEW;
- }
-
- // [self.orderViewController reload_container_getdata:update_data];
- }
- -(void) reloadContact:(BOOL) update_data immediately:(bool)immediately
- {
- //[self.con reload_container];
-
- if(immediately)
- [ self.contactListViewController reload_container_getdata:update_data];
- else
- {
- if(update_data&&self.contactListViewController.refresh_type<=REFRESH_DATA)
- self.contactListViewController.refresh_type = REFRESH_DATA;
- else if(self.contactListViewController.refresh_type<=REFRESH_VIEW)
- self.contactListViewController.refresh_type = REFRESH_VIEW;
- }
- }
- #endif
- -(void)viewWillLayoutSubviews
- {
- self.headerView.layer.shadowPath =[UIBezierPath bezierPathWithRect:self.headerView.bounds].CGPath;
- }
- -(void) viewWillAppear:(BOOL)animated
- {
-
- [super viewWillAppear:animated];
- // [self.label_ccount.layer setMasksToBounds:YES];
-
- [self refreshContactDisplay];
-
- [[self navigationController] setNavigationBarHidden:YES animated:NO];
- }
- -(void) refreshContactDisplay
- {
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // self.labelContact.text=appDelegate.contact_name;
-
- NSString * contact =[appDelegate.customerInfo valueForKey:@"customer_contact"];
- NSString * customer=[appDelegate.customerInfo valueForKey:@"customer_name"];
-
-
-
- NSDictionary * customerinfo=appDelegate.customerInfo;
-
-
- if(customerinfo==nil)
- {
- contact=@"Select Contact";
- [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
- }
- // if(contact==nil||contact.length==0)
- // {
- // contact=@"No Name";
- // [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
- // }
- else
- {
-
- if(contact==nil||contact.length==0)
- {
- contact=@"No Name";
- [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
- }
- else
- {
- [self.btnContact setTitleColor:UIColorFromRGB(0x009900) forState:UIControlStateNormal];
- }
- }
-
- NSMutableArray* arr_contact = [[NSMutableArray alloc] init];
- if(contact.length>0)
- [arr_contact addObject:contact];
- if(customer.length>0)
- [arr_contact addObject:customer];
-
- NSString *contact_string = [arr_contact componentsJoinedByString:@" @"];
-
-
- [self.btnContact setTitle:contact_string forState:UIControlStateNormal];
- }
- - (void) checklogin:(bool) reloadCurrentVC
- {
-
- [self initMenuItems];
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- self.sideMenu_UserName.text =appDelegate.user;
-
- [self.btn_sideMenu_UserName setTitle:appDelegate.user forState:UIControlStateNormal];
-
- if(appDelegate.bLogin)
- [self.btnLogin setTitle:@"Sign out" forState:UIControlStateNormal];
- else
- [self.btnLogin setTitle:@"Sign in" forState:UIControlStateNormal];
-
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [RANetwork LoadImage:appDelegate.user_icon into:self.user_head ];
- });
-
-
- // if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/true)
- // self.btnContact.hidden = NO;
- // else
- // self.btnContact.hidden = YES;
-
- NSDictionary * customerinfo=appDelegate.customerInfo;
- NSString * contact=nil;
- NSString * customer=nil;
- if(customerinfo==nil)
- {
- contact=@"Select Contact";
- [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
- }
- else
- {
- contact=[customerinfo valueForKey:@"customer_contact"];
- customer=[customerinfo valueForKey:@"customer_name"];
- if(contact==nil||contact.length==0)
- {
- contact=@"No Name";
- [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
- }
- else
- {
- [self.btnContact setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
- }
- }
-
- // self.btnContact.hidden = !appDelegate.bLogin;// 修复登出后仍旧显示select contact
-
-
- NSMutableArray* arr_contact = [[NSMutableArray alloc] init];
- if(contact.length>0)
- [arr_contact addObject:contact];
- if(customer.length>0)
- [arr_contact addObject:customer];
-
- NSString *contact_string = [arr_contact componentsJoinedByString:@" @"];
-
-
- [self.btnContact setTitle:contact_string forState:UIControlStateNormal];
-
- // if(appDelegate.bLogin)
- // [self.buttonUser setTitle:appDelegate.user forState:UIControlStateNormal];
- // else
- // [self.buttonUser setTitle:@"Sign in" forState:UIControlStateNormal];
-
-
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"DetailViewController,PDFListViewController,CartViewController,PortfolioViewController,WatchListViewController,OrderListViewController,OrderListViewController,ContactListViewController,CategoryViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- #else
- [self reloadDocuments:true immediately:false];
- [self reloadCart:true immediately:false];
- [self reloadPortfolio:true immediately:false];
- [self reloadWish:true immediately:false];
-
- [self reloadOrder:true immediately:false];
- [self reloadContact:true immediately:false];
- [self reloadCategory:true immediately:false];
-
-
-
- ActiveViewController* lrvc = (ActiveViewController*)appDelegate.active_controller;
- if(reloadCurrentVC)
- {
-
-
- if(lrvc!=nil)
- [ lrvc refresh_on_login];
- }
- else
- {
- if(lrvc.refresh_type<=REFRESH_DATA)
- lrvc.refresh_type = REFRESH_DATA;
- else if(lrvc.refresh_type<=REFRESH_VIEW)
- lrvc.refresh_type = REFRESH_VIEW;
- }
- #endif
- // [self reload];
-
-
- }
- - (IBAction)onContactClick:(id)sender {
-
-
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- NSString* contactid=appDelegate.contact_id ;
-
- if(contactid==nil)
- {
-
- NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
-
- CustomerEditViewController * cuseditVC = [[CustomerEditViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
- cuseditVC.bnewcustomer=true;
- cuseditVC.bolocustomer = true;
- cuseditVC.url_type = URL_FILE;
- cuseditVC.request_url=[OLDataProvider scanTemplatePath:@"scan_contact.json"];;
-
- cuseditVC.params = params;
-
- cuseditVC.returnValue=^(NSMutableDictionary* value)
- {
-
- if(value == nil)
- {
- return; //canceled
- }
- NSString* contact_id=[[NSUUID new] UUIDString];
-
- value[@"business_card"] = value[@"customer_cid"];
-
- NSArray*arr =[RAConvertor string2arr:value[@"business_card"] separator:@","];
- for(int l=0;l<arr.count;l++)
- {
- value[[NSString stringWithFormat:@"business_card_%d",l]]=arr[l];
- }
-
-
- //---------------- construct customer_contact----------------------
- NSString* customer_first_name = [value valueForKey:@"customer_first_name"];
- if(customer_first_name==nil)
- customer_first_name=@"";
-
- NSString* customer_last_name= [value valueForKey:@"customer_last_name"];
- if(customer_last_name==nil)
- customer_last_name=@"";
- NSString* customer_contact = [NSString stringWithFormat:@"%@ %@",customer_first_name,customer_last_name];
- customer_contact=[customer_contact stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
- [value setValue:customer_contact forKey:@"customer_contact"];
-
-
-
- value [@"customer_cid"] = contact_id;
- appDelegate.contact_id=contact_id;
- appDelegate.customerInfo = value;
- };
-
- [[self navigationController] setNavigationBarHidden:NO animated:NO];
- [self.navigationController pushViewController:cuseditVC animated:false];
-
- }
- else
- {
- CustomerInfoViewController * vc = [[CustomerInfoViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
-
- vc.url_type = URL_FILE;
-
- // if(appDelegate.order_code.length>0)
- {
- vc.edit_icon = false;
- vc.assig_icon = true;
- vc.reset_icon = true;
- vc.request_url=[OLDataProvider scanTemplatePath:@"scan_contact.json"];
- }
- // else
- // {
- // vc.edit_icon = false;
- // vc.assig_icon = false;
- // vc.reset_icon = true;
- // vc.request_url=LOCAL_URL_CUSTOMER_INFO_EDITOR;
- // }
-
- // NSDictionary* dd=appDelegate.customerInfo;;
- vc.data_init = appDelegate.customerInfo;
-
- vc.update_order = true;
-
- vc.contactId=contactid;
- // vc.delegate = self;
-
- vc.returnValue = ^(NSMutableDictionary* value){
-
-
- if(value==nil)
- {
- //reset
- // if(RASingleton.sharedInstance.enable_OfflineOrder)
- {
-
- [OLDataProvider deleteScanOrder:appDelegate.order_code];
- [appDelegate closeOrder];
-
-
- //
-
- // [self prepareReturn:nil];
-
-
-
- [self.navigationController popViewControllerAnimated:true];
- [((MainViewController*)appDelegate.main_vc) switchToOrder];
-
-
- return;
- }
-
- }
- else
- {
- value[@"business_card"] = value[@"business_card"];
-
- NSArray*arr =[RAConvertor string2arr:value[@"business_card"] separator:@","];
- for(int l=0;l<arr.count;l++)
- {
- value[[NSString stringWithFormat:@"business_card_%d",l]]=arr[l];
- }
- //---------------- construct customer_contact----------------------
- NSString* customer_first_name = [value valueForKey:@"customer_first_name"];
- if(customer_first_name==nil)
- customer_first_name=@"";
-
- NSString* customer_last_name= [value valueForKey:@"customer_last_name"];
- if(customer_last_name==nil)
- customer_last_name=@"";
- NSString* customer_contact = [NSString stringWithFormat:@"%@ %@",customer_first_name,customer_last_name];
- customer_contact=[customer_contact stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
- [value setValue:customer_contact forKey:@"customer_contact"];
-
-
-
- value [@"customer_cid"] = appDelegate.customerInfo[@"customer_cid"];
- // appDelegate.contact_id=contact_id;
- appDelegate.customerInfo = value;
- }
-
-
-
-
- // appDelegate.contact_id=[value valueForKey:@"customer_cid"];
- // appDelegate.customerInfo = value;
- };
-
-
- [self.navigationController pushViewController:vc animated:true];
- }
-
-
-
-
- }
- -(void) clearSelected
- {
- self.btncart.selected = false;
- self.btnorder.selected = false;
- self.btnlist.selected = false;
- self.btnsearch.selected = false;
- self.btnsetting.selected = false;
- }
- - (void)of_test
- {
- // NSString* str =@"[\"5688\",\"5808-68\",\"DINING TBL, ACACIA VNER\",\"1\",\"123.45\",\"123.45\",\"123.45\",\"123.45\",\"123.45\",\"1\",\"10.96\",\"viet\",\"vcsf\",\"42 X 68 x 30.5H\",\"234.56\"]";
- // NSDictionary* item = [RAConvertor string2dict:str];
- // NSMutableDictionary* of = [NSMutableDictionary new];
- // for(int i=0;i<4000;i++)
- // {
- // of[[NSString stringWithFormat:@"model_%d",i]]=item;
- // }
- //
- // NSString* strof=[RAConvertor dict2string:of];
- //
- //
- //// NSString* str2 = [AESCrypt encrypt:strof password:@"usai2010"];
- //// NSString * str3 = [AESCrypt decrypt:@"x6P5P+DUN+s4mYoSoipdmvaPtU1mGvGGHtoqQF3GlMg=" password:@"usai2010"];
- ////
- //// NSString * str123 = [AESCrypt decrypt:@"706dZ9zTqNPauH3j2S7MQg==" password:@"usai"];
- //// NSString * str333 = [AESCrypt decrypt:@"RQtrNBCGKxNq6Bk5QGkPiw==" password:@"usai2010\0\0\0\0\0\0\0\0"];
- //// NSString * str33 = [AESCrypt decrypt:@"0s0+JiC2ZzoDiBGQaCnT1g==" password:@"usai2010"];
- //
- //
- // [self sortedDictionary:of];
- //
- //// NSDictionary* test1 = of[@"model_1234"];
- //// NSDictionary* test2 = of[@"model_9876"];
- //// NSDictionary* test3 = of[@"model_4567"];
- //// NSDictionary* test4 = of[@"model_7654"];
- //
- // [self of_search:of keyword:@"12"];
- //
- //
- }
- /**
- 对字典(Key-Value)排序 区分大小写
- @param dict 要排序的字典
- */
- - (void)sortedDictionary:(NSDictionary *)dict{
-
- //将所有的key放进数组
- NSArray *allKeyArray = [dict allKeys];
-
- //序列化器对数组进行排序的block 返回值为排序后的数组
- NSArray *afterSortKeyArray = [allKeyArray sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id
- _Nonnull obj2) {
- /**
- In the compare: methods, the range argument specifies the
- subrange, rather than the whole, of the receiver to use in the
- comparison. The range is not applied to the search string. For
- example, [@"AB" compare:@"ABC" options:0 range:NSMakeRange(0,1)]
- compares "A" to "ABC", not "A" to "A", and will return
- NSOrderedAscending. It is an error to specify a range that is
- outside of the receiver's bounds, and an exception may be raised.
-
- - (NSComparisonResult)compare:(NSString *)string;
-
- compare方法的比较原理为,依次比较当前字符串的第一个字母:
- 如果不同,按照输出排序结果
- 如果相同,依次比较当前字符串的下一个字母(这里是第二个)
- 以此类推
-
- 排序结果
- NSComparisonResult resuest = [obj1 compare:obj2];为从小到大,即升序;
- NSComparisonResult resuest = [obj2 compare:obj1];为从大到小,即降序;
-
- 注意:compare方法是区分大小写的,即按照ASCII排序
- */
- //排序操作
- NSComparisonResult resuest = [obj1 compare:obj2];
- return resuest;
- }];
- DebugLog(@"afterSortKeyArray:%@",afterSortKeyArray);
-
- //通过排列的key值获取value
- NSMutableArray *valueArray = [NSMutableArray array];
- for (NSString *sortsing in afterSortKeyArray) {
- NSString *valueString = [dict objectForKey:sortsing];
- [valueArray addObject:valueString];
- }
- DebugLog(@"valueArray:%@",valueArray);
- }
- -(void)of_search:(NSMutableDictionary*) dict keyword:(NSString*)keyword
- {
- NSMutableArray* arr = [NSMutableArray new];
-
- NSArray* keys=[dict allKeys];
-
- for(int i=0;i<keys.count;i++)
- {
- NSString* key = keys[i];
- if([key containsString:keyword])
- {
- [arr addObject:dict[key]];
- }
-
-
- }
-
-
-
- }
- - (void)viewDidLoad
- {
-
- [super viewDidLoad];
-
- // NSString * str3 = [AESCrypt AES128Decrypt:@"" key:@"usai2010"];
- // NSString * str4 = [AESCrypt AES128Decrypt:@"" key:@"usai2010"];
-
- // NSString * str5 = [AESCrypt AES128Decrypt:@"" key:@"usai2010"];
-
- // DebugLog(@"decrypt:%@",[AESCrypt fastdecrypt:@"vafHUwfRPIUbPNVnKhLc5aAVK7sOFRztlfJVRHW7QVa/qGgm11E5UwfYWZEBTQpH"]);
-
-
- // [self of_test];
-
-
- [RADataProvider load_scan_models];
-
- [self.btncart setBackgroundImage:[UIImage imageNamed:@"btn_bg"] forState:UIControlStateSelected];
- [self.btnorder setBackgroundImage:[UIImage imageNamed:@"btn_bg"] forState:UIControlStateSelected];
- [self.btnlist setBackgroundImage:[UIImage imageNamed:@"btn_bg"] forState:UIControlStateSelected];
- [self.btnsearch setBackgroundImage:[UIImage imageNamed:@"btn_bg"] forState:UIControlStateSelected];
- [self.btnsetting setBackgroundImage:[UIImage imageNamed:@"btn_bg"] forState:UIControlStateSelected];
- // [self.btncart setTintColor:UIColor.whiteColor];
- // self.btncart.configuration.baseForegroundColor = UIColor.redColor;
- // [self.btncart updateConfiguration];
- // [self.btncart setBackgroundImage:[UIImage imageNamed:@"btn_bg"] forState:UIControlStateHighlighted];
- NSDictionary *addressDic = [[NSUserDefaults standardUserDefaults] valueForKey:@"ScanAddress"];
- if (addressDic) {
-
- self.labelServer.text = [addressDic objectForKey:@"show_name"];
- // NSUInteger selectedIndex = [[addressDic objectForKey:@"selectedIndex"] integerValue];
- // switch (selectedIndex) {
- // case 0:
- // case 1: {
- // [self internalCheckBtnClick:self.internalCheckBtn];
- // }
- // break;
- // case 2: {
- // [self externalCheckBtnClick:self.externalCheckBtn];
- // }
- // break;
- //
- // default:
- // break;
- // }
- }
-
-
- // self.btnContact.hidden = NO;
-
- // self.automaticallyAdjustsScrollViewInsets = NO;
- NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultColor" valuename:@"labelcolor"];
-
- if(value==nil)
- value=@"";
- unsigned long frontcolor = strtoul([value UTF8String],0,16);
- [self.labelSo setTextColor:UIColorFromRGB(frontcolor)];
-
-
-
-
-
- float vx =[[DefaultAppearance get_noneappearance_value:@"MainLogo" valuename:@"x"] floatValue];
- float vy =[[DefaultAppearance get_noneappearance_value:@"MainLogo" valuename:@"y"] floatValue];
- float vwidth =[[DefaultAppearance get_noneappearance_value:@"MainLogo" valuename:@"width"] floatValue];
- float vheight =[[DefaultAppearance get_noneappearance_value:@"MainLogo" valuename:@"height"] floatValue];
-
- self.btn_LogoHome.frame = CGRectMake(vx, vy, vwidth, vheight);
-
-
- float mvx =[[DefaultAppearance get_noneappearance_value:@"ModePos" valuename:@"x"] floatValue];
- float mvy =[[DefaultAppearance get_noneappearance_value:@"ModePos" valuename:@"y"] floatValue];
- float mvwidth =[[DefaultAppearance get_noneappearance_value:@"ModePos" valuename:@"width"] floatValue];
- float mvheight =[[DefaultAppearance get_noneappearance_value:@"ModePos" valuename:@"height"] floatValue];
-
- self.labelMode.frame = CGRectMake(mvx, mvy, mvwidth, mvheight);
-
-
-
- self.label_ccount.layer.cornerRadius=10.5;
- self.label_ccount.layer.masksToBounds=true;
-
- self.label_wcount.layer.cornerRadius=10.5;
- self.label_wcount.layer.masksToBounds=true;
-
- self.label_cccount.layer.cornerRadius=10.5;
- self.label_cccount.layer.masksToBounds=true;
-
- self.label_cwcount.layer.cornerRadius=10.5;
- self.label_cwcount.layer.masksToBounds=true;
-
-
- self.employee_bp.hidden = false;
- // self.customer_bp.hidden = true;
-
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
-
- appDelegate.main_vc = self;
-
- [appDelegate update_count_mark];
-
- NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
- NSString* build =[infoDict objectForKey:@"CFBundleVersion"];
- NSString* version =[infoDict objectForKey:@"CFBundleShortVersionString"];
- //#ifdef BUILD_HMLG
- // NSString* versionNum = [NSString stringWithFormat:@"HMLG %@ Build %@",version,build];
- //#endif
- //#if defined(BUILD_NPD) || defined(BUILD_USAI)
- // NSString* versionNum = [NSString stringWithFormat:@"npd %@ Build %@",version,build];
- //#endif
- //#ifdef BUILD_HOMER
- NSString* versionNum = [NSString stringWithFormat:@"%@ %@ Build %@",COMPANY_SHORT_NAME,version,build];
- //#endif
- [self initAppDelegate]; // 初始化scan order 参数
- [self initMenuItems];
- self.homeViewController =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ScanHomeViewController"];
- // self.categoryViewController =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Search" bundle:nil] instantiateViewControllerWithIdentifier:@"CategoryViewController"];
-
- self.settingViewController=[ [UIStoryboard storyboardWithName:@"OLM" bundle:nil] instantiateViewControllerWithIdentifier:@"ServerSettingViewController"];
-
-
-
-
- self.cartViewController =[[UIStoryboard storyboardWithName:@"SO" bundle:nil] instantiateViewControllerWithIdentifier:@"CartViewController"];
- __block MainViewController *brself= self;
-
-
-
- self.scanorderViewController =[[UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"ScanOrderListViewController"];
-
- self.contactListViewController = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- self.contactListViewController.contact_type = @"Sales_Order_Customer";
-
- self.contactListViewController.edit_icon = true;
- self.contactListViewController.assig_icon = true;
- self.contactListViewController.reset_icon = false;
- self.contactListViewController.ui_type = CONTACT_LIST;
- self.contactListViewController.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- appDelegate.contact_id=[value valueForKey:@"customer_cid"];
- appDelegate.customerInfo = value;
- [brself refreshContactDisplay];
- [brself switchToCart:nil];
-
- // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
- //Capturing strongly warring;
-
-
-
- self.scanHistoryViewController =[[UIStoryboard storyboardWithName:@"SO" bundle:nil] instantiateViewControllerWithIdentifier:@"ScanHistoryViewController"];
- // self.portfolioViewController = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Portfolio" bundle:nil] instantiateViewControllerWithIdentifier:@"PortfolioViewController" ];
-
- // [self addChildViewController:self.scanHistoryViewController];
- // self.pdfListViewController = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Portfolio" bundle:nil] instantiateViewControllerWithIdentifier:@"PortfolioListViewController" ];
-
- // self.itemSearchViewController=[[UIStoryboard storyboardWithName:@"ERP_Mobile_Search" bundle:nil] instantiateViewControllerWithIdentifier:@"ItemSearchViewController"];
- self.scansearchViewController=[ [UIStoryboard storyboardWithName:@"SO" bundle:nil] instantiateViewControllerWithIdentifier:@"ScanSearchViewController"];
-
- [self addChildViewController:self.homeViewController]; //1
-
- self.homeViewController.view.frame = self.container.bounds;
- [self.container addSubview:self.homeViewController.view]; //2
- [self.homeViewController didMoveToParentViewController:self];
- self.current_VC = self.homeViewController;
-
-
- // [self addChildViewController:self.scanorderViewController]; //1
- //
- // self.scanorderViewController.view.frame = self.container.bounds;
- // [self.container addSubview:self.scanorderViewController.view]; //2
- // [self.scanorderViewController didMoveToParentViewController:self];
- // self.current_VC = self.scanorderViewController;
- // // self.is_home = true;
-
- // [UIBezierPath bezierPathWithRect:self.headerView.bounds].CGPath;
-
- self.headerView.layer.shadowPath =[UIBezierPath bezierPathWithRect:self.headerView.bounds].CGPath;
- self.headerView.layer.masksToBounds = false;
- //添加四个边阴影
-
- self.headerView.layer.shadowColor = [UIColor blackColor].CGColor;
- self.headerView.layer.shadowOffset = CGSizeMake(0, 0);
- self.headerView.layer.shadowOpacity = 0.5;
- self.headerView.layer.shadowRadius = 2.0;
-
-
- self.labelVer.text=versionNum;
-
-
-
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- // Do any additional setup after loading the view, typically from a nib.
- // SetupServerViewController * servervc =[[UIStoryboard storyboardWithName:@"SO" bundle:nil] instantiateViewControllerWithIdentifier:@"SetupServerViewController"];
- // [self.navigationController pushViewController:servervc animated:true];
- }
- - (IBAction)onmenuButtonClicked:(id)sender {
- self.openMenuButton.hidden = true;
- self.sideMenu.hidden = false;
- [self showMenu];
- }
- - (IBAction)switchMenu:(UIButton *)sender {
- // if(self.menuShown==true)
-
- [self hideMenu];
- self.openMenuButton.hidden = false;
- self.sideMenu.hidden = true;
- // else
- // [self showMenu];
-
- }
- -(void) Loginout:(bool)showlogin
- {
- return;
- // 此接口 scan order 不会调用,但为了保证公共模块变异不会报错,保留空接口。
-
- }
- - (IBAction)onUserListClick:(id)sender {
-
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- if(!appDelegate.bLogin)
- return;
-
- UserListViewController * vc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"UserListViewController"];
- vc.returnValue = ^(bool blogin){
-
- if(blogin==false)
- {
- LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
- loginvc.returnValue = ^(bool blogin){
-
- [self checklogin :true];
-
- };
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-
-
-
-
-
-
- navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
- DebugLog(@"login present.........");
-
- }];
- }
-
- };
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:vc] ;
-
-
-
-
-
-
- navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
- DebugLog(@"login present.........");
-
- }];
-
-
- }
- - (IBAction)OnLoginClick:(UIButton *)sender {
-
-
- [self Loginout:true];
-
-
-
- }
- - (IBAction)onScanClick:(id)sender {
- ScannerViewController * scannerVC =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ScannerViewController"];
-
-
- // LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"SO" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
- // ScanOrderScanModelViewController *scanresult = [[UIStoryboard storyboardWithName:@"SO" bundle:nil] instantiateViewControllerWithIdentifier:@"ScanOrderScanModelViewController"];
-
-
- ScanOrderModelListViewController* scanresult = [[UIStoryboard storyboardWithName:@"SO" bundle:nil] instantiateViewControllerWithIdentifier:@"ScanOrderModelListViewController"];
- scannerVC.resultvc = scanresult;
- [self.navigationController pushViewController:scannerVC animated:true];
-
-
-
- }
- - (IBAction)switchToSearch:(UIButton *)sender {
- [self clearSelected];
- self.btnsearch.selected = true;
- if([self.current_VC isKindOfClass:[ScanSearchViewController class]])
- return;
- [self flipFromViewController:self.current_VC toViewController:self.scansearchViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- }
- //- (IBAction)switchToList:(UIButton *)sender {
- // [self switchtowishlist];
- //}
- - (IBAction)switchToList:(UIButton *)sender {
- [self clearSelected];
- self.btnlist.selected = true;
- [self switchtowishlist];
- }
- -(void)switchtowishlist
- {
- if([self.current_VC isKindOfClass:[ScanHistoryViewController class]])
- return;
- // if([self.current_VC isKindOfClass:[OrderListViewController class]])
- // return;
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // if(appDelegate.bLogin==false)
- // {
- // LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
- // // loginvc.delegate = self;
- // // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- //
- // loginvc.returnValue = ^(bool blogin){
- //
- //
- // if(blogin)
- // {
- // [self checklogin:true];
- //
- //
- // [self flipFromViewController:self.current_VC toViewController:self.watchListViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- // }
- //
- //
- // };
- //
- // UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
- //
- //
- //
- //
- //
- // // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
- //
- // navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- // [self presentViewController:navi animated:YES completion:^{
- //
- // // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
- //
- // DebugLog(@"LoginViewController present.........");
- //
- // // self.btop = false;
- // // <#code#>
- // }];
- // }
- // else
- [self flipFromViewController:self.current_VC toViewController:self.scanHistoryViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- }
- - (IBAction)switchToContact:(UIButton *)sender {
- [self switchtocontact];
- }
- -(void)switchtocontact
- {
-
-
-
- if([self.current_VC isKindOfClass:[ContactListViewController class]])
- return;
-
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- if(appDelegate.bLogin==false)
- {
- LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
- // loginvc.delegate = self;
- // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
-
- loginvc.returnValue = ^(bool blogin){
-
-
- if(blogin)
- {
- [self checklogin:true];
-
-
- if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
- {
- [self flipFromViewController:self.current_VC toViewController:self.contactListViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- }
- else
- {
- [RAUtils message_box:@"Contact List" message:@"Customer Login does not support this feature." completion:nil] ;
- }
-
- }
-
-
- };
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-
-
-
-
-
- // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-
- navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
- // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
-
- DebugLog(@"LoginViewController present.........");
-
- // self.btop = false;
- // <#code#>
- }];
- }
- else
- [self flipFromViewController:self.current_VC toViewController:self.contactListViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
-
-
- }
- - (void) reload
- {
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- return;
-
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- //
- // NSDictionary* category=[RANetwork request_Cagegory];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // if([[category valueForKey:@"result"] intValue]==2)
- // {
- // appDelegate.categoryMenu = category;
- // }
- // else
- // {
- // // [RAUtils error_alert:[category valueForKey:@"err_msg"]] ;
- // }
- //
- // });
- // });
-
- }
- -(void) scanTempsave
- {
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- // RASingleton.sharedInstance.scan_temp_code
-
- NSString *orderdir =[OLDataProvider getScanPath];
- // appDelegate.order_code = RASingleton.sharedInstance.scan_temp_code;
- // [OLDataProvider moveScanTemp2Order];
-
- // NSString *orderdir = [OLDataProvider getScanPath];
- // NSString* userdir = [OLDataProvider getUserPath];
- // NSString *orderPath = [orderdir stringByAppendingPathComponent:@"order.json"];
-
-
-
- // [RAUtils dicttofile:orderPath dict:self.content_data_download];
-
-
-
- // NSString* order_code = RASingleton.sharedInstance.scan_temp_code;
- //
- // int section_count = [self.content_data_download[@"section_count"] intValue];
- //
- // for(int i=0;i<section_count;i++)
- // {
- // NSMutableDictionary* section = [self.content_data_download[[NSString stringWithFormat:@"section_%d",i]] mutableCopy];
- // NSString* title = section[@"title"];
- //
- // if([title isEqualToString:@"Customer"])
- // {
- // // 订单信息会写customer info
- //
- // int scount = [section[@"count"] intValue];
- // for(int j=0;j<scount;j++)
- // {
- // NSMutableDictionary * item = [section[[NSString stringWithFormat:@"item_%d",j]] mutableCopy];
- // NSString * name = item[@"name"];
- //
- //
- // if(item[@"value"]!=nil )
- // appDelegate.customerInfo[name]=item[@"value"];
- //
- //
- // }
- //
- //
- //
- // }
-
-
- //
- // NSString *contactpath = [orderdir stringByAppendingPathComponent:@"contact.json"];
- //
- //
- //
- // [RAUtils dicttofile:contactpath dict:appDelegate.customerInfo];
-
- // orderdir = [OLDataProvider getScanOrderPath];
- NSString *cartpath = [orderdir stringByAppendingPathComponent:@"cart.json"];
-
- RASingleton.sharedInstance.scan_cart[@"price_type"] = @(RASingleton.sharedInstance.price_type);
-
- [RAUtils dicttofile:cartpath dict:RASingleton.sharedInstance.scan_cart];
-
-
-
-
- NSMutableDictionary* orderlist = [OLDataProvider getScanOrderList];
-
-
- // NSString *orderlistPath = [userdir stringByAppendingPathComponent:@"orderlist.json"];
- //
- //
- // if (![[NSFileManager defaultManager] fileExistsAtPath:orderlistPath]) {
- //
- //
- // orderlist = [NSMutableDictionary new];
- //
- //// [orderlist addObject:appDelegate.order_code];
- //// [RAUtils dicttofile:orderlistPath dict:orderlist];
- //
- // }
- // else
- // {
- // orderlist=[[RAUtils dictfromfile:orderlistPath] mutableCopy];
- //
- //// [orderlist insertObject:appDelegate.order_code atIndex:0];
- //
- //// [RAUtils dicttofile:orderlistPath dict:orderlist];
- // }
- float p =0;
- float s =0;
- // NSDictionary* price_group = [RADataProvider get_price_group:appDelegate.price_group];
- int order_qty=0;
- for(int j=0;j<[RASingleton.sharedInstance.scan_cart[@"section_0"][@"count"] intValue];j++)
- {
- NSDictionary* cartitem =RASingleton.sharedInstance.scan_cart[@"section_0"][[NSString stringWithFormat:@"item_%d",j]];
- p+=[cartitem[@"unit_price"] doubleValue]*[cartitem[@"count"]intValue] * (1-[cartitem[@"discount"]doubleValue]/100.0);
- int mcount = [cartitem[@"count"] intValue];
- order_qty+=mcount;
- double msurcharge =0;
-
- // remove net price
- // if(RASingleton.sharedInstance.price_type==1)
- // {
- // if([cartitem[@"special_price"] boolValue])
- // {
- // msurcharge=([cartitem[price_group[@"price_3"][@"name"]] doubleValue]-[cartitem[price_group[@"price_2"][@"name"]] doubleValue])*mcount*(1-[cartitem[@"discount"]doubleValue]/100.0);
- // }
- // else
- // {
- // msurcharge=([cartitem[price_group[@"price_3"][@"name"]] doubleValue]-[cartitem[price_group[@"price_1"][@"name"]] doubleValue])*mcount*(1-[cartitem[@"discount"]doubleValue]/100.0);
- // }
- // }
- s+=msurcharge;
- }
-
- NSMutableDictionary* orderitem = [NSMutableDictionary new];
- orderitem[@"create_by"] = appDelegate.user;
-
- orderitem[@"price"] = [RAConvertor currencyNumber:p+s];//[NSString stringWithFormat:@"%.2f",p+s];
- orderitem[@"model_count"] =[ NSString stringWithFormat:@"%d",order_qty];
-
- // orderitem[@"price"] = upparams[@"totalPrice"];
- // NSString*
- orderitem[@"customer_name"] = appDelegate.customerInfo[@"customer_contact"];
- orderitem[@"purchase_time"] = [RAUtils current_date_time];
- orderitem[@"order_status"] = @"Saved Order";
- orderitem[@"order_code"] = appDelegate.order_code;
- // NSMutableDictionary* section =RASingleton.sharedInstance.scan_cart[@"section_0"];
- // orderitem[@"model_count"] =[ NSString stringWithFormat:@"%d",order_qty];//RASingleton.sharedInstance.scan_cart[@"section_0"][@"count"] ];
-
-
- int count = [orderlist[@"count"] intValue];
-
- NSMutableDictionary* newlist = [NSMutableDictionary new];
-
- newlist[@"item_0"]=orderitem;
- int newcount = 1;
- for(int i=0;i<count;i++)
- {
- NSMutableDictionary* item = orderlist[[NSString stringWithFormat:@"item_%d",i]];
- if([item[@"order_code"] isEqualToString: appDelegate.order_code ])
- continue;
- else
- {
- newlist[[NSString stringWithFormat:@"item_%d",newcount]] = item;
- newcount++;
- }
- }
- newlist[@"count"] = @(newcount);
-
- [OLDataProvider saveScanOrderList:newlist];
- // [RAUtils dicttofile:orderlistPath dict:newlist];
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"CartViewController,ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-
- #else
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- #endif
- }
- - (IBAction)onUserButtonClick:(id)sender {
-
- DebugLog(@"header view login");
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- if( appDelegate.user ==nil /*|| [appDelegate.user isEqualToString:@"GUEST"]*/)
- {
- // appDelegate.user = nil;
- // appDelegate.password = nil;
- LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
- // loginvc.delegate = self;
- // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- loginvc.returnValue = ^(bool blogin){
- [self checklogin:true];
- };
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
- // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
- navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
- // <#code#>
- }];
- }
- else
- {
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Sign Out" message:@"" preferredStyle:UIAlertControllerStyleAlert];
-
- UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Sign Out" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
-
-
- //open exist
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- // int cc=[RASingleton.sharedInstance.scan_cart[@"section_0"][@"count"] intValue];
- bool issaved = [OLDataProvider isSavedScanOrder:appDelegate.order_code];
- if(/*appDelegate.order_code == nil*/!issaved && [RASingleton.sharedInstance.scan_cart[@"section_0"][@"count"] intValue]>0)
- {
- UIAlertController *alertController1 = [UIAlertController alertControllerWithTitle:@"Save Cart?" message:@"" preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- [self scanTempsave];
-
- [OLDataProvider scanCloseOrder];
- [appDelegate Logout];
- // appDelegate.cart_count = 0;//[[jsobj :@"cart_count"] intValue];
- // appDelegate.wish_count =0;//[[jsobj valueForKey:@"wish_count"] intValue];
- // appDelegate.port_count =0;//[[jsobj valueForKey:@"portfolio_count"] intValue];
- //
- // [appDelegate update_count_mark];
- //
- //
- // appDelegate.can_show_price =false;
- // appDelegate.can_see_price =false;
- // appDelegate.can_create_portfolio =false;
- // appDelegate.can_create_order =false;
- //
- //
- // appDelegate.can_cancel_order =false;
- // appDelegate.can_set_cart_price =false;
- // appDelegate.can_delete_order =false;
- // appDelegate.can_submit_order =false;
- // appDelegate.can_set_tearsheet_price =false;
- // appDelegate.can_update_contact_info = false;
- //
- // appDelegate.save_order_logout = false;
- // appDelegate.submit_order_logout = false;
- // appDelegate.alert_sold_in_quantities = false;
- //
- // appDelegate.ipad_perm =nil ;
- // appDelegate.user_type = USER_ROLE_UNKNOWN;
- // appDelegate.OrderFilter= nil;
- // [appDelegate SetSo:nil];
- // [appDelegate set_main_button_panel];
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"ScanSearchViewController" Message:RA_NOTIFICATION_REFRESH_UI];
- [ActiveViewController Notify:@"ScanHistoryViewController" Message:RA_NOTIFICATION_REFRESH_UI];
- #endif
- // [appDelegate Logout];
- }];
- UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- //create new;
- [OLDataProvider scanCloseOrder];
- [appDelegate Logout];
- // appDelegate.cart_count = 0;//[[jsobj :@"cart_count"] intValue];
- // appDelegate.wish_count =0;//[[jsobj valueForKey:@"wish_count"] intValue];
- // appDelegate.port_count =0;//[[jsobj valueForKey:@"portfolio_count"] intValue];
- //
- // [appDelegate update_count_mark];
- //
- //
- // appDelegate.can_show_price =false;
- // appDelegate.can_see_price =false;
- // appDelegate.can_create_portfolio =false;
- // appDelegate.can_create_order =false;
- //
- //
- // appDelegate.can_cancel_order =false;
- // appDelegate.can_set_cart_price =false;
- // appDelegate.can_delete_order =false;
- // appDelegate.can_submit_order =false;
- // appDelegate.can_set_tearsheet_price =false;
- // appDelegate.can_update_contact_info = false;
- //
- // appDelegate.save_order_logout = false;
- // appDelegate.submit_order_logout = false;
- // appDelegate.alert_sold_in_quantities = false;
- //
- // appDelegate.ipad_perm =nil ;
- // appDelegate.user_type = USER_ROLE_UNKNOWN;
- // appDelegate.OrderFilter= nil;
- // [appDelegate SetSo:nil];
- // [appDelegate set_main_button_panel];
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"ScanSearchViewController" Message:RA_NOTIFICATION_REFRESH_UI];
- [ActiveViewController Notify:@"ScanHIstoryViewController" Message:RA_NOTIFICATION_REFRESH_UI];
- #endif
- // [appDelegate Logout];
-
- }];
- [alertController1 addAction:action_1];
- [alertController1 addAction:action_2];
-
-
- [self presentViewController:alertController1 animated:YES completion:nil];
-
- return;
- }
- [OLDataProvider scanCloseOrder];
- [appDelegate Logout];
-
- // appDelegate.cart_count = 0;//[[jsobj :@"cart_count"] intValue];
- // appDelegate.wish_count =0;//[[jsobj valueForKey:@"wish_count"] intValue];
- // appDelegate.port_count =0;//[[jsobj valueForKey:@"portfolio_count"] intValue];
- //
- // [appDelegate update_count_mark];
- //
- //
- // appDelegate.can_show_price =false;
- // appDelegate.can_see_price =false;
- // appDelegate.can_create_portfolio =false;
- // appDelegate.can_create_order =false;
- //
- //
- // appDelegate.can_cancel_order =false;
- // appDelegate.can_set_cart_price =false;
- // appDelegate.can_delete_order =false;
- // appDelegate.can_submit_order =false;
- // appDelegate.can_set_tearsheet_price =false;
- // appDelegate.can_update_contact_info = false;
- //
- // appDelegate.save_order_logout = false;
- // appDelegate.submit_order_logout = false;
- // appDelegate.alert_sold_in_quantities = false;
- //
- // appDelegate.ipad_perm =nil ;
- // appDelegate.user_type = USER_ROLE_UNKNOWN;
- // appDelegate.OrderFilter= nil;
- // [appDelegate SetSo:nil];
- //
-
-
-
- // [appDelegate set_main_button_panel];
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"ScanSearchViewController" Message:RA_NOTIFICATION_REFRESH_UI];
- [ActiveViewController Notify:@"ScanHistoryViewController" Message:RA_NOTIFICATION_REFRESH_UI];
- #endif
- // [appDelegate Logout];
- }];
- UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- //create new;
-
-
-
- }];
-
- [alertController addAction:action_1];
- [alertController addAction:action_2];
-
-
- [self presentViewController:alertController animated:YES completion:nil];
-
- }
- }
- #pragma mark - LoginViewControllerDelegate
- -(void)LoginViewControllerDidLogin:(LoginViewController *)viewController
- {
- [viewController dismissViewControllerAnimated:YES completion:^{
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- self.sideMenu_UserName.text =appDelegate.user;
- [self.btn_sideMenu_UserName setTitle:appDelegate.user forState:UIControlStateNormal];
-
- [self.btnLogin setTitle:@"Sign out" forState:UIControlStateNormal];
-
- [RANetwork LoadImage:appDelegate.user_icon into:self.user_head ];
-
- // if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/true)
- // self.btnContact.hidden = NO;
- // else
- // self.btnContact.hidden = YES;
-
- NSDictionary * customerinfo=appDelegate.customerInfo;
- NSString * contact=nil;
- NSString * customer=nil;
- if(customerinfo==nil)
- {
- contact=@"Select Contact";
- [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
- }
- else
- {
- contact=[customerinfo valueForKey:@"customer_contact"];
- customer=[customerinfo valueForKey:@"customer_name"];
- if(contact==nil||contact.length==0)
- {
- contact=@"No Name";
- [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
- }
- else
- {
- [self.btnContact setTitleColor:UIColorFromRGB(0x009900) forState:UIControlStateNormal];
- }
- }
-
-
- NSMutableArray* arr_contact = [[NSMutableArray alloc] init];
- if(contact.length>0)
- [arr_contact addObject:contact];
- if(customer.length>0)
- [arr_contact addObject:customer];
-
- NSString *contact_string = [arr_contact componentsJoinedByString:@" @"];
-
-
- [self.btnContact setTitle:contact_string forState:UIControlStateNormal];
-
- // [self.buttonUser setTitle:appDelegate.user forState:UIControlStateNormal];
-
-
-
- [self reload];
-
- }];
-
-
-
- }
- - (void) flipFromViewController:(UIViewController*) fromController
- toViewController:(UIViewController*) toController
- withDirection:(UIViewAnimationOptions) direction
- {
- toController.view.frame = self.container.bounds; // 1
-
- // UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
- // UIViewAutoresizingFlexibleWidth = 1 << 1,
- // UIViewAutoresizingFlexibleRightMargin = 1 << 2,
- // UIViewAutoresizingFlexibleTopMargin = 1 << 3,
- // UIViewAutoresizingFlexibleHeight = 1 << 4,
- // UIViewAutoresizingFlexibleBottomMargin = 1 << 5
-
-
- toController.view.autoresizingMask = UIViewAutoresizingFlexibleHeight |UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin;
- DebugLog(@"MAIN VIEWCONTROLLER CHILD COUNT %lu",(unsigned long)self.childViewControllers.count);
- [self addChildViewController:toController]; //
- [fromController willMoveToParentViewController:nil]; //
-
- [self transitionFromViewController:fromController
- toViewController:toController
- duration:0.0
- options:direction | UIViewAnimationOptionCurveEaseIn
- animations:nil
- completion:^(BOOL finished) {
-
- [toController didMoveToParentViewController:self]; // 2
- [fromController removeFromParentViewController]; // 3
-
- self.current_VC = toController;
-
-
- // if([fromController isKindOfClass:[HomeViewController class]])
- // {
- // // [[NSNotificationCenter defaultCenter] postNotificationName:CYCLESCROLL_STOPTIMMER object:nil];
- // // self.homeViewController = nil;
- //
- // }
-
-
-
- }];
-
-
- }
- -(void)topicViewSelected:(int) type _id: (int) _id
- {
- // [self switchToCagegory:nil];
- // if(type==0)
- // {
- // // [self.categoryViewController showDetailat:_id];
- // }
- // else
- // {
- // [self.categoryViewController showCategory];
- //
- // }
- }
- -(void)categoryMenuSelected:(NSString*)_id
- {
- // [self switchToCagegory:_id];
-
- // [self.categoryViewController showCategory];
-
- }
- //- (void)switchToItemSearch:(NSString* )coverttype {
- //
- //
- // self.itemSearchViewController.default_filter = nil;
- // self.itemSearchViewController.covertype = coverttype;
- // self.itemSearchViewController.saved_covertype = coverttype;
- //
- //
- //
- // self.itemSearchViewController.p_available = nil;
- // self.itemSearchViewController.p_price = nil;
- // self.itemSearchViewController.p_QTY = nil;
- // self.itemSearchViewController.p_bestseller = nil;
- //#ifdef RA_NOTIFICATION
- // [ActiveViewController Notify:@"ItemSearchViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- //#else
- // [self.itemSearchViewController reload_container_getdata:true];
- //#endif
- //
- // if([self.current_VC isKindOfClass:[ItemSearchViewController class]])
- //
- // return;
- // [self flipFromViewController:self.current_VC toViewController:self.itemSearchViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- //
- // [[self navigationController] setNavigationBarHidden:YES animated:NO];
- //
- //
- // // self.is_home = false;
- // // self.current_vc = VC_CATEGORY;
- // // [self.homeViewController willMoveToParentViewController:nil]; //1
- // // [self.homeViewController.view removeFromSuperview]; //2
- // // [self.homeViewController removeFromParentViewController]; //3
- // //
- // // [self.container addSubview:self.cagegoryViewController.view]; //2
- // // [self.cagegoryViewController didMoveToParentViewController:self];
- //}
- //- (void)switchToCagegory:(NSString* )categoryid {
- // // NSString* ttt =[@"Category" stringByAppendingString:[self categoryString:categoryid node:self.categoryMenu level:0]];
- //
- //
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // #if defined(BUILD_UWAVER)
- // self.categoryViewController.categoryString = [@"Collections" stringByAppendingString:[self categoryString:categoryid node:appDelegate.categoryMenu level:0]];
- //#else
- // self.categoryViewController.categoryString = [@"Category" stringByAppendingString:[self categoryString:categoryid node:appDelegate.categoryMenu level:0]];
- //#endif
- //
- // self.categoryViewController.cagegoryLabel.text =self.categoryViewController.categoryString;
- // self.categoryViewController.categoryid = categoryid ;
- // self.categoryViewController.loadall=false;
- //// self.categoryViewController.collectionview
- // self.categoryViewController.p_alert = nil;
- // self.categoryViewController.p_available = nil;
- // self.categoryViewController.p_price = nil;
- // self.categoryViewController.p_QTY = nil;
- // self.categoryViewController.p_bestseller = nil;
- //
- // self.categoryViewController.modelname = nil;
- // self.categoryViewController.modeldescrip = nil;
- //#ifdef RA_NOTIFICATION
- // [ActiveViewController Notify:@"CategoryViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- //#else
- // [self.categoryViewController reload_container_getdata:true];
- //#endif
- //
- // [self.categoryViewController showCategory];
- // if([self.current_VC isKindOfClass:[CategoryViewController class]])
- //
- // return;
- // [self flipFromViewController:self.current_VC toViewController:self.categoryViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- //
- // [[self navigationController] setNavigationBarHidden:YES animated:NO];
- //
- //
- // // self.is_home = false;
- // // self.current_vc = VC_CATEGORY;
- // // [self.homeViewController willMoveToParentViewController:nil]; //1
- // // [self.homeViewController.view removeFromSuperview]; //2
- // // [self.homeViewController removeFromParentViewController]; //3
- // //
- // // [self.container addSubview:self.cagegoryViewController.view]; //2
- // // [self.cagegoryViewController didMoveToParentViewController:self];
- //}
- - (IBAction)switchToHome:(UIButton *)sender {
- [self clearSelected];
- [self switchToHome];
- // self.current_vc = VC_HOME;
- // self.is_home = true;
- //
- // [self.cagegoryViewController willMoveToParentViewController:nil]; //1
- // [self.cagegoryViewController.view removeFromSuperview]; //2
- // [self.cagegoryViewController removeFromParentViewController]; //3
- //
- // [self.container addSubview:self.homeViewController.view]; //2
- // [self.homeViewController didMoveToParentViewController:self];
- }
- -(void)switchToHome
- {
- [self clearSelected];
- if([self.current_VC isKindOfClass:[ScanHomeViewController class]])
- return;
-
- if(self.homeViewController == nil)
- {
- self.homeViewController =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ScanHomeViewController"];
- self.homeViewController.view.frame = self.container.bounds;
- }
- [self flipFromViewController:self.current_VC toViewController:self.homeViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
-
- }
- -(void) switchToPreviousVC
- {
-
- if(self.previous_VC==nil)
- return;
- if([self.current_VC isKindOfClass:[self.previous_VC class]])
- return;
-
-
- [self flipFromViewController:self.current_VC toViewController:self.previous_VC withDirection:UIViewAnimationOptionTransitionCrossDissolve];
-
- }
- - (IBAction)switchToCart:(UIButton *)sender {
- // [self.btncart setBackgroundColor:UIColor.whiteColor];
- // [self.btncart setTintColor:UIColor.clearColor];
- // UIColor *color0=[self.btncart titleColorForState:UIControlStateNormal];
- // UIColor *color1=[self.btncart titleColorForState:UIControlStateSelected];
- [self switchToCart];
-
- // self.current_vc = VC_HOME;
- }
- -(void) switchToCart
- {
-
- if([self.current_VC isKindOfClass:[CartViewController class]])
- return;
- [self clearSelected];
- self.btncart.selected = true;
- //
- //
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- // if(appDelegate.bLogin==false&& !RASingleton.sharedInstance.enable_OfflineOrder)
- // {
- //
- // LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
- // // loginvc.delegate = self;
- // // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- //
- // loginvc.returnValue = ^(bool blogin){
- //
- //
- // // UIApplication * app = [UIApplication sharedApplication];
- // // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- //
- //
- //
- //
- // if(blogin)
- // {
- // if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/true)
- // {
- //
- // [self checklogin:false];
- // if(appDelegate.can_create_order)
- // {
- //
- // NSString* msg =@"";
- // if(appDelegate.contact_id.length>0)
- // {
- // msg = [msg stringByAppendingString:@"\n\nCustomer:"];
- // msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
- //
- // }
- //
- // UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Switch To Cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
- //
- // UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- // //open exist
- //
- // ScanOrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"ScanOrderListViewController"];
- // ovc.showNavibar = true;
- // ovc.selectOrder = ^(NSMutableDictionary* order_detail){
- // if(appDelegate.order_code==nil)
- // {
- // [self neworderforCart];
- // }
- // else
- // {
- // self.previous_VC = self.current_VC;
- // [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- //
- // [self checklogin:true];
- //
- // }
- //
- // };
- //// ovc.init_style = OL_OPEN;
- // ovc.onCancel = ^(){
- //
- // [self checklogin:true];
- //
- // };
- // ovc.title = @"SAVED ORDER";
- // [self.navigationController pushViewController:ovc animated:true];
- // }];
- // UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- // //create new;
- //
- // if(appDelegate.customerInfo==nil)// select contact if current contact not exist
- // {
- //
- // ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- // cvc.showNavibar = true;
- // cvc.contact_type = @"Sales_Order_Customer";
- // cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
- //
- // appDelegate.contact_id=[value valueForKey:@"customer_cid"];
- // appDelegate.customerInfo = value;
- //
- //
- // if(appDelegate.order_code==nil)
- // [self neworderforCart];
- //
- //
- // };
- //
- // cvc.onCancel = ^(){
- //
- // [RAUtils message_box:@"" message:@"Cannot create order without customer infomation." completion:nil];
- //
- //
- //
- // };
- // cvc.onReset = ^(){
- // [self checklogin:true];
- // };
- //
- // [self.navigationController pushViewController:cvc animated:true];
- // }
- // else
- // {
- // [self neworderforCart];
- // }
- //
- // }];
- // UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- //
- //
- //
- // }];
- //
- // [alertController addAction:action_1];
- // [alertController addAction:action_2];
- // [alertController addAction:action_3];
- //
- //
- // [self presentViewController:alertController animated:YES completion:nil];
- //// UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch To Cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil),NSLocalizedString(@"Create new order", nil), nil];
- ////
- ////
- ////
- //// // alert.
- //// [alert show];
- // }
- // else
- // {
- //
- // UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Switch To Cart" message:@"Do you want to switch to a pending order?" preferredStyle:UIAlertControllerStyleAlert];
- //
- //
- // UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- // //open exist
- //
- // ScanOrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"ScanOrderListViewController"];
- // ovc.showNavibar = true;
- // ovc.selectOrder = ^(NSMutableDictionary* order_detail){
- // if(appDelegate.order_code==nil)
- // {
- // [self neworderforCart];
- // }
- // else
- // {
- // self.previous_VC = self.current_VC;
- // [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- //
- // [self checklogin:true];
- //
- // }
- //
- // };
- //// ovc.init_style = OL_OPEN;
- // ovc.onCancel = ^(){
- //
- // [self checklogin:true];
- //
- // };
- // ovc.title = @"SAVED ORDER";
- // [self.navigationController pushViewController:ovc animated:true];
- // }];
- // UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" 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(@"Switch To Cart", nil) message:NSLocalizedString(@"Do you want to switch to a pending order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil), nil];
- ////
- //// // alert.
- //// [alert show];
- // }
- // }
- //// else
- //// {
- //// [self checklogin:true];
- //// self.previous_VC = self.current_VC;
- //// [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- //// }
- // }
- //
- // // self.offset = 0;
- // // [self.content_data removeAllObjects];
- // // [self loadpage];
- // //
- // // [[self navigationController] setNavigationBarHidden:YES animated:NO];
- //
- // };
- //
- // UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
- //
- //
- //
- //
- //
- // // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
- //
- // navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- // [self presentViewController:navi animated:YES completion:^{
- //
- // // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
- //
- // DebugLog(@"LoginViewController present.........");
- //
- // // self.btop = false;
- // // <#code#>
- // }];
- // }
- // else
- // {
- //// if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE&&/*appDelegate.contact_id==nil&&*/appDelegate.order_code==nil)
- // if(appDelegate.order_code==nil)
- // {
- //// [self checklogin:false];
- // if(appDelegate.can_create_order)
- // {
- // NSString* msg =@"";
- // if(appDelegate.contact_id.length>0)
- // {
- // msg = [msg stringByAppendingString:@"\n\nCustomer:"];
- // msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
- //
- // }
- //
- // UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Switch To Cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
- //
- // UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- // //open exist
- //
- // ScanOrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"ScanOrderListViewController"];
- // ovc.showNavibar = true;
- // ovc.selectOrder = ^(NSMutableDictionary* order_detail){
- // if(appDelegate.order_code==nil)
- // {
- // [self neworderforCart];
- // }
- // else
- // {
- // self.previous_VC = self.current_VC;
- // [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- //
- // [self checklogin:true];
- //
- // }
- //
- // };
- //// ovc.init_style = OL_OPEN;
- // ovc.onCancel = ^(){
- //
- // [self checklogin:true];
- //
- // };
- // ovc.title = @"SAVED ORDER";
- // [self.navigationController pushViewController:ovc animated:true];
- // }];
- // UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- // //create new;
- //
- // if(appDelegate.customerInfo==nil)// select contact if current contact not exist
- // {
- //
- // ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- // cvc.showNavibar = true;
- // cvc.contact_type = @"Sales_Order_Customer";
- // cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
- //
- // appDelegate.contact_id=[value valueForKey:@"customer_cid"];
- // appDelegate.customerInfo = value;
- //
- //
- // if(appDelegate.order_code==nil)
- // [self neworderforCart];
- //
- //
- // };
- //
- // cvc.onCancel = ^(){
- //
- // [RAUtils message_box:@"" message:@"Cannot create order without customer infomation." completion:nil];
- //
- //
- //
- // };
- // cvc.onReset = ^(){
- // [self checklogin:true];
- // };
- //
- // [self.navigationController pushViewController:cvc animated:true];
- // }
- // else
- // {
- // [self neworderforCart];
- // }
- //
- // }];
- // UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- //
- //
- //
- // }];
- //
- // [alertController addAction:action_1];
- // [alertController addAction:action_2];
- // [alertController addAction:action_3];
- //
- //
- // [self presentViewController:alertController animated:YES completion:nil];
- //
- //
- //// UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch to cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil),NSLocalizedString(@"Create new order", nil), nil];
- ////
- //// // alert.
- //// [alert show];
- // }
- // else
- // {
- // UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Switch To Cart" message:@"Do you want to switch to a pending order?" preferredStyle:UIAlertControllerStyleAlert];
- //
- //
- // UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Switch to pending order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- // //open exist
- //
- // ScanOrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"ScanOrderListViewController"];
- // ovc.showNavibar = true;
- // ovc.selectOrder = ^(NSMutableDictionary* order_detail){
- // if(appDelegate.order_code==nil)
- // {
- // [self neworderforCart];
- // }
- // else
- // {
- // self.previous_VC = self.current_VC;
- // [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- //
- // [self checklogin:true];
- //
- // }
- //
- // };
- //// ovc.init_style = OL_OPEN;
- // ovc.onCancel = ^(){
- //
- // [self checklogin:true];
- //
- // };
- // ovc.title = @"SAVED ORDER";
- // [self.navigationController pushViewController:ovc animated:true];
- // }];
- // UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" 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(@"Switch to cart", nil) message:NSLocalizedString(@"Do you want to Switch to a pending order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Switch to pending order", nil), nil];
- ////
- //// // alert.
- //// [alert show];
- // }
- // }
- // else
- // {
- //
- // self.previous_VC = self.current_VC;
- // [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- //
- //
- //
- // }
- // }
- //
- self.previous_VC = self.current_VC;
- [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
-
- }
- -(void) switchToOrder
- {
- [self clearSelected];
- self.btnorder.selected = true;
- if([self.current_VC isKindOfClass:[ScanOrderListViewController class]])
- return;
-
- UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- [self flipFromViewController:self.current_VC toViewController:self.scanorderViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
-
- }
- - (IBAction)switchToOrder:(id)sender {
- [self switchToOrder];
-
- }
- #pragma mark - CategoryMenuDelegate
- -(void)SelectCategory:(NSString *)category
- {
- // [self switchToCagegory:category];
-
- }
- -(NSString*) categoryString:(NSString*) categoryid node:(NSDictionary*) json level:(int) level;
- {
-
- if(categoryid.length==0)
- return @">All Products>";
- //NSString* idString = [NSString stringWithFormat:@"%d",categoryid];
- NSString* categoryString =@">";
- int count = [[json valueForKey:@"count"] intValue];
- for(int i=0;i<count;i++)
- {
- NSDictionary * category_json = [json objectForKey:[NSString stringWithFormat:@"category_%d",i]];
- NSString* cid = [category_json valueForKey:@"id"] ;
-
- // NSString* ttt =[categoryid substringToIndex:2+level*2];
- // NSString * qqq =[cid substringToIndex:2+level*2];
-
-
- // NSString *ds1=[categoryid substringToIndex:3+level*3];
- // NSString*ds2 = [cid substringToIndex:3+level*3];
- if(cid.length<3+level*3)
- continue;
-
- if(categoryid.length<3+level*3)
- continue;
- if([[categoryid substringToIndex:3+level*3] isEqualToString: [cid substringToIndex:3+level*3]])
- {
- //categoryString = [categoryString stringByAppendingString:@">"];
- categoryString =[categoryString stringByAppendingString: [category_json valueForKey:@"title" ] ];
- categoryString = [categoryString stringByAppendingString:[ self categoryString:categoryid node:category_json level:level+1]];
- break;
- }
-
- }
- return categoryString;
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (IBAction)openMenu:(UIButton *)sender {
- [self showMenu];
- }
- - (UIImage*)screen_shot
- {
- // CGRect r = self.view.frame;
- // CGRect r1 = self.view.bounds;
- // double width,height;
- //
- // UIInterfaceOrientation orientation =[UIApplication sharedApplication].statusBarOrientation;
- // ;
- // if(orientation == UIDeviceOrientationLandscapeLeft ||orientation == UIDeviceOrientationLandscapeRight)
- // {
- // width = self.view.frame.size.width>self.view.frame.size.height? self.view.frame.size.width:self.view.frame.size.height;
- // height =self.view.frame.size.width<self.view.frame.size.height? self.view.frame.size.width:self.view.frame.size.height;
- // }
- // else
- // {
- // width = self.view.frame.size.width<self.view.frame.size.height? self.view.frame.size.width:self.view.frame.size.height;
- // height =self.view.frame.size.width>self.view.frame.size.height? self.view.frame.size.width:self.view.frame.size.height;
- // }
- UIGraphicsBeginImageContext(CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height));
- [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
- UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return viewImage;
- }
- - (IBAction)onhideMenuClick:(id)sender {
- [self hideMenu];
- self.backgroundButton.hidden=true;
- self.openMenuButton.hidden = false;
- self.sideMenu.hidden = true;
- }
- - (void)hideMenu
- {
- CGRect frame ;
- frame.origin.x = -300;
- frame.origin.y = 0;
- frame.size.height = self.view.bounds.size.height;
- frame.size.width = 364;
- self.sideMenu.frame=frame;
- self.sideMenu.hidden = true;
- self.blurView.alpha = 0;
- [self.menuButton setImage:[UIImage imageNamed:@"menu_open"] forState:UIControlStateNormal];
- self.menuShown = false;
- self.backgroundButton.hidden=true;
- self.openMenuButton.hidden = false;
- }
- - (void)showMenu
- {
- [self.sideMenuTable reloadData];
- UIImage* imgsource = [self screen_shot];
- self.blurView.alpha = 0;
- UIImage* imgBlur =[self applyBlurWithRadius:5 sourceImage:imgsource tintColor:[UIColor colorWithWhite:0.2 alpha:0.73] saturationDeltaFactor:1.8 maskImage:nil];
- self.blurView.image = imgBlur;
- // self.blurView.hidden = imgBlur;
- // [self.sideMenu becomeFirstResponder];
- self.sideMenu.hidden = false;
- self.backgroundButton.hidden=false;
- CGRect frame ;
- frame.origin.x = 0;
- frame.origin.y = 0;
- frame.size.height = self.view.bounds.size.height;
- frame.size.width = 364;
- // [UIView animateWithDuration:1.0 animations:^{ self.sideMenu.frame=frame;
- // self.blurView.alpha = 1;
- // [self.menuButton setImage:[UIImage imageNamed:@"menu"] forState:UIControlStateNormal];
- //
- // }];
- [UIView animateWithDuration:0.5 animations:^{ self.sideMenu.frame=frame;
- self.blurView.alpha = 1;
-
-
- }
- completion:^(BOOL finished) {
- [self.menuButton setImage:[UIImage imageNamed:@"menu"] forState:UIControlStateNormal];
- }];
-
- // UIImage* img= [UIImage imageNamed:@"menu"];
- // self.menuButton.imageView.image = nil;
- self.menuShown = true;
- }
- -(void)initMenuItems
- {
-
-
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- self.sideMenuItems = [[NSMutableArray alloc] init];
-
- NSMutableDictionary* map = [[NSMutableDictionary alloc] init];
-
-
- if(appDelegate.user!=nil)
- {
- [map setValue:@"Wish List" forKey:@"title"];
- [map setValue:@"rect_market_news" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
-
- }
- #if !defined(BUILD_HOMER) && !defined(BUILD_GATIT)
- //#ifndef BUILD_HOMER //homer 要求去掉cam scan 2017/12/20
- // if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
- {
- [map setValue:@"Cam Scan" forKey:@"title"];
- [map setValue:@"rect_contact_list" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- }
- #endif
- if(appDelegate.user_type==USER_ROLE_EMPLOYEE || (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeCustomer))
- {
- // [map setValue:@"Contact" forKey:@"title"];
- // [map setValue:@"rect_contact_list" forKey:@"img"];
- // [self.sideMenuItems addObject:map.copy];
-
- //#ifdef BUILD_UWAVER
- // [map setValue:@"Hang Tag" forKey:@"title"];
- //#else
- [map setValue:@"Portfolio" forKey:@"title"];
- //#endif
-
- [map setValue:@"rect_market_news" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- //#ifdef BUILD_UWAVER
- // [map setValue:@"View Hang Tags" forKey:@"title"];
- //#else
- [map setValue:@"View Portfolios" forKey:@"title"];
- //#endif
-
-
- [map setValue:@"rect_pdf_list" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
- }
-
-
- if(appDelegate.can_show_price)
- {
-
- if(appDelegate.price_hidden)
- [map setValue:@"Show Price" forKey:@"title"];
- else
- [map setValue:@"Hide Price" forKey:@"title"];
- [map setValue:@"rect_announcements" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
- }
-
- // [map setValue:@"Contact" forKey:@"title"];
- // [map setValue:@"rect_market_news" forKey:@"img"];
- // [self.sideMenuItems addObject:map.copy];
-
- // [map setValue:@"Cache" forKey:@"title"];
- // [map setValue:@"rect_announcements" forKey:@"img"];
- //[self.sideMenuItems addObject:map.copy];
-
-
- // NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
-
-
- // [map setValue:@"Message" forKey:@"title"];
- // [map setValue:@"rect_search_history" forKey:@"img"];
- // [self.sideMenuItems addObject:map.copy];
- //
- #if defined(BUILD_NPD)
- [map setValue:@"Scanner Setting" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
- # endif
-
- #if defined(SCANNER_ORDER)
- [map setValue:@"Scanner Order" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
- # endif
-
- #if defined(BUILD_NPD)|| defined (BUILD_CONTRAST)
- if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
- {
- [map setValue:@"Offline Setting" forKey:@"title"];
- [map setValue:@"rect_market_news" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- }
- #endif
-
- if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore ) {
- [map setValue:@"Price Setting" forKey:@"title"];
- // [map setValue:@"rect_market_news" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
- }
- if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore ) {
- if ([RASingleton sharedInstance].global_lock) {
- [map setValue:@"Unlock" forKey:@"title"];
- } else {
- [map setValue:@"Lock" forKey:@"title"];
- }
-
- [self.sideMenuItems addObject:map.copy];
- }
-
-
- #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
- /*
- if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
- {
- [map setValue:@"Offline Setting" forKey:@"title"];
- [map setValue:@"rect_market_news" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- }
- */
- // if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER) {
- // [map setValue:@"Price Setting" forKey:@"title"];
- // // [map setValue:@"rect_market_news" forKey:@"img"];
- // [self.sideMenuItems addObject:map.copy];
- // }
- if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore ) {
- if ([Singleton sharedInstance].global_lock) {
- [map setValue:@"Unlock" forKey:@"title"];
- } else {
- [map setValue:@"Lock" forKey:@"title"];
- }
-
- [self.sideMenuItems addObject:map.copy];
- }
-
- # endif
-
- #ifdef DEBUG
- // if([[appDelegate.user lowercaseString] isEqualToString:@"larryl"]||[[appDelegate.user lowercaseString] isEqualToString:@"arpithat"])
- {
- // [map setValue:@"Contact" forKey:@"title"];
- // [map setValue:@"rect_contact_list" forKey:@"img"];
- // [self.sideMenuItems addObject:map.copy];
-
-
- [map setValue:@"Function Test" forKey:@"title"];
- [map setValue:@"rect_market_news" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- }
-
- #endif
-
- [map setValue:@"Privacy Policy" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
-
- [map setValue:@"About us" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
-
- #ifdef BUILD_HMLG
- [map setValue:@"Homelegance Website" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
- #endif
-
- #if defined(BUILD_NPD)
- [map setValue:@"BLOG" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- [map setValue:[NSString stringWithFormat:@"%@ Website",COMPANY_SHORT_NAME] forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- [map setValue:[NSString stringWithFormat:@"%@ Policy",COMPANY_SHORT_NAME] forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- [map setValue:@"Simplified Buying Program" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
- #endif
-
- #ifdef BUILD_USAI
- // [map setValue:@"BLOG" forKey:@"title"];
- // [map setValue:@"rect_change_password" forKey:@"img"];
- // [self.sideMenuItems addObject:map.copy];
-
- [map setValue:@"USAI Website" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- #endif
-
- #ifdef BUILD_HOMER
- /*
- [map setValue:@"BLOG" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
- */
-
- [map setValue:@"HOMER Website" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- #endif
-
- #ifdef BUILD_GATIT
-
- [map setValue:@"TITAN Website" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- # endif
-
-
- [self.sideMenuTable reloadData];
-
- //
-
- }
- - (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius sourceImage:(UIImage*)sourceImage tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage
- {
- // Check pre-conditions.
- if (sourceImage.size.width < 1 || sourceImage.size.height < 1) {
- DebugLog (@"*** error: invalid size: (%.2f x %.2f). Both dimensions must be >= 1: %@", sourceImage.size.width, sourceImage.size.height, self);
- return nil;
- }
- if (!sourceImage.CGImage) {
- DebugLog (@"*** error: image must be backed by a CGImage: %@", self);
- return nil;
- }
- if (maskImage && !maskImage.CGImage) {
- DebugLog (@"*** error: maskImage must be backed by a CGImage: %@", maskImage);
- return nil;
- }
-
- CGRect imageRect = { CGPointZero, sourceImage.size };
- UIImage *effectImage = sourceImage;
-
- BOOL hasBlur = blurRadius > __FLT_EPSILON__;
- BOOL hasSaturationChange = fabs(saturationDeltaFactor - 1.) > __FLT_EPSILON__;
- if (hasBlur || hasSaturationChange) {
- UIGraphicsBeginImageContextWithOptions(sourceImage.size, NO, [[UIScreen mainScreen] scale]);
- CGContextRef effectInContext = UIGraphicsGetCurrentContext();
- CGContextScaleCTM(effectInContext, 1.0, -1.0);
- CGContextTranslateCTM(effectInContext, 0, -sourceImage.size.height);
- CGContextDrawImage(effectInContext, imageRect, sourceImage.CGImage);
-
- vImage_Buffer effectInBuffer;
- effectInBuffer.data = CGBitmapContextGetData(effectInContext);
- effectInBuffer.width = CGBitmapContextGetWidth(effectInContext);
- effectInBuffer.height = CGBitmapContextGetHeight(effectInContext);
- effectInBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectInContext);
-
- UIGraphicsBeginImageContextWithOptions(sourceImage.size, NO, [[UIScreen mainScreen] scale]);
- CGContextRef effectOutContext = UIGraphicsGetCurrentContext();
- vImage_Buffer effectOutBuffer;
- effectOutBuffer.data = CGBitmapContextGetData(effectOutContext);
- effectOutBuffer.width = CGBitmapContextGetWidth(effectOutContext);
- effectOutBuffer.height = CGBitmapContextGetHeight(effectOutContext);
- effectOutBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectOutContext);
-
- if (hasBlur) {
- // A description of how to compute the box kernel width from the Gaussian
- // radius (aka standard deviation) appears in the SVG spec:
- // http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement
- //
- // For larger values of 's' (s >= 2.0), an approximation can be used: Three
- // successive box-blurs build a piece-wise quadratic convolution kernel, which
- // approximates the Gaussian kernel to within roughly 3%.
- //
- // let d = floor(s * 3*sqrt(2*pi)/4 + 0.5)
- //
- // ... if d is odd, use three box-blurs of size 'd', centered on the output pixel.
- //
- CGFloat inputRadius = blurRadius * [[UIScreen mainScreen] scale];
-
-
- NSUInteger radius = floor(inputRadius * 3. * sqrt(2 * M_PI) / 4 + 0.5);
- if (radius % 2 != 1) {
- radius += 1; // force radius to be odd so that the three box-blur methodology works.
- }
- vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, (unsigned int)radius, (unsigned int)radius, 0, kvImageEdgeExtend);
- vImageBoxConvolve_ARGB8888(&effectOutBuffer, &effectInBuffer, NULL, 0, 0, (unsigned int)radius, (unsigned int)radius, 0, kvImageEdgeExtend);
- vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, (unsigned int)radius, (unsigned int)radius, 0, kvImageEdgeExtend);
- }
- BOOL effectImageBuffersAreSwapped = NO;
- if (hasSaturationChange) {
- CGFloat s = saturationDeltaFactor;
- CGFloat floatingPointSaturationMatrix[] = {
- 0.0722 + 0.9278 * s, 0.0722 - 0.0722 * s, 0.0722 - 0.0722 * s, 0,
- 0.7152 - 0.7152 * s, 0.7152 + 0.2848 * s, 0.7152 - 0.7152 * s, 0,
- 0.2126 - 0.2126 * s, 0.2126 - 0.2126 * s, 0.2126 + 0.7873 * s, 0,
- 0, 0, 0, 1,
- };
- const int32_t divisor = 256;
- NSUInteger matrixSize = sizeof(floatingPointSaturationMatrix)/sizeof(floatingPointSaturationMatrix[0]);
- int16_t saturationMatrix[matrixSize];
- for (NSUInteger i = 0; i < matrixSize; ++i) {
- saturationMatrix[i] = (int16_t)roundf(floatingPointSaturationMatrix[i] * divisor);
- }
- if (hasBlur) {
- vImageMatrixMultiply_ARGB8888(&effectOutBuffer, &effectInBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags);
- effectImageBuffersAreSwapped = YES;
- }
- else {
- vImageMatrixMultiply_ARGB8888(&effectInBuffer, &effectOutBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags);
- }
- }
- if (!effectImageBuffersAreSwapped)
- effectImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
-
- if (effectImageBuffersAreSwapped)
- effectImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- }
-
- // Set up output context.
- UIGraphicsBeginImageContextWithOptions(sourceImage.size, NO, [[UIScreen mainScreen] scale]);
- CGContextRef outputContext = UIGraphicsGetCurrentContext();
- CGContextScaleCTM(outputContext, 1.0, -1.0);
- CGContextTranslateCTM(outputContext, 0, -sourceImage.size.height);
-
- // Draw base image.
- CGContextDrawImage(outputContext, imageRect, sourceImage.CGImage);
-
- // Draw effect image.
- if (hasBlur) {
- CGContextSaveGState(outputContext);
- if (maskImage) {
- CGContextClipToMask(outputContext, imageRect, maskImage.CGImage);
- }
- CGContextDrawImage(outputContext, imageRect, effectImage.CGImage);
- CGContextRestoreGState(outputContext);
- }
-
- // Add in color tint.
- if (tintColor) {
- CGContextSaveGState(outputContext);
- CGContextSetFillColorWithColor(outputContext, tintColor.CGColor);
- CGContextFillRect(outputContext, imageRect);
- CGContextRestoreGState(outputContext);
- }
-
- // Output image is ready.
- UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
-
- return outputImage;
- }
- //- (IBAction)openMenu:(UIButton *)sender {
- //}
- #pragma mark - Table view data source
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
-
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
-
- return self.sideMenuItems.count;
-
-
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- NSString *CellIdentifier = @"SideMenuItem";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- NSString* title = [self.sideMenuItems[indexPath.row] valueForKey:@"title"];
- cell.backgroundColor = [UIColor clearColor];
- // [cell.backgroundColor:[UIColor clearColor]];
- // UIImageView* iv= [[UIImageView alloc] initWithImage:];
- cell.textLabel.text = title;
- cell.detailTextLabel.textColor =[UIColor redColor];
- if([title isEqualToString:@"Wish List"]&&appDelegate.wish_count>0)
- cell.detailTextLabel.text = [NSString stringWithFormat:@"%ld",appDelegate.wish_count];
- else if(([title isEqualToString:@"Portfolio"] || [title isEqualToString:@"Hang Tag"])&&appDelegate.port_count>0)
- cell.detailTextLabel.text = [NSString stringWithFormat:@"%ld",appDelegate.port_count];
- else
- {
- cell.detailTextLabel.text =nil;
- }
- // cell.imageView.image = [UIImage imageNamed:[self.toolsinfo[indexPath.row] valueForKey:@"img"]];
-
- return cell;
-
-
- }
- #ifdef SCANNER_ORDER
- -(void) scanLogin
- {
- [self onUserButtonClick:nil];
- }
- -(void) initAppDelegate
- {
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // appDelegate.user_type = USER_ROLE_EMPLOYEE;
- // appDelegate.can_set_cart_price = true;
- // appDelegate.can_see_price = true;
- // appDelegate.can_set_cart_price = true;
- // appDelegate.can_show_price = true;
- // appDelegate.can_cancel_order = true;
- // appDelegate.can_create_order=true;
- // appDelegate.can_delete_order = true;
- // appDelegate.can_submit_order = true;
- // appDelegate.bLogin = true;
-
- // RASingleton.sharedInstance.permissions_edit_order = true;
-
- RASingleton.sharedInstance.price_type = 1;
- // [OLDataProvider createScanTempFolder];
-
- NSDictionary *addressDic = [[NSUserDefaults standardUserDefaults] valueForKey:@"ScanAddress"] ;
- if (addressDic) {
- // NSUInteger selectedIndex = [[addressDic objectForKey:@"selectedIndex"] integerValue];
- // if (selectedIndex == 1) {
- // self.address = [addressDic objectForKey:@"serverAddress"];
- // }
- // if (selectedIndex == 2) {
- // self.address = [addressDic objectForKey:@"serverAddress"];
- // }
- appDelegate.address = [addressDic objectForKey:@"serverAddress"];
- // [OLDataProvider guestLogin];
-
- NSMutableDictionary* guestjson=[OLDataProvider loadScanTemplate:@"guest.json"];
- if(!guestjson)
- {
- dispatch_async(dispatch_get_main_queue(), ^{
- [RADataProvider updateTemplate:self];
-
- });
-
-
- }
- else
- dispatch_async(dispatch_get_main_queue(), ^{
- [self onUserButtonClick:nil];
-
- });
-
- }
- else
- {
- // return;
- SetupServerViewController * servervc =[[UIStoryboard storyboardWithName:@"SO" bundle:nil] instantiateViewControllerWithIdentifier:@"SetupServerViewController"];
-
- servervc.returnValue = ^{
- NSDictionary *addressDic = [[NSUserDefaults standardUserDefaults] valueForKey:@"ScanAddress"];
- if (addressDic) {
-
- self.labelServer.text = [addressDic objectForKey:@"show_name"];
- }
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [RADataProvider updateTemplate:self];
-
- });
- };
- [self.navigationController pushViewController:servervc animated:true];
- }
-
- [RADataProvider default_price_group];
- }
- #endif
- #pragma mark - Table view delegate
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NSString* title = [self.sideMenuItems[indexPath.row] valueForKey:@"title"];
- if([title isEqualToString:@"Cache"])
- {
- CacheViewController * settingvc=[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CacheViewController"];
-
-
- PopupNavigationController * navi=[[PopupNavigationController alloc] initWithRootViewController:settingvc];
- navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
- //DebugLog(@"login.........");
- // <#code#>
- }];
-
-
-
-
- }
- #ifdef SCANNER_ORDER
- #endif
- else if([title isEqualToString:@"Scanner Setting"])
- {
-
-
-
- //
- #ifndef RA_NOTIFICATION
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- UIViewController* active_vc = appDelegate.active_controller;
- ScannerSettingViewController * gunVC =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ScannerSettingViewController"];
- appDelegate.active_controller = gunVC;
- gunVC.onDismissVC = ^(){
- appDelegate.active_controller = active_vc;
- };
- #else
- ScannerSettingViewController * gunVC =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ScannerSettingViewController"];
- #endif
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:gunVC] ;
-
-
-
-
-
- // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-
- navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
- // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
-
- DebugLog(@"about present.........");
-
- // self.btop = false;
- // <#code#>
- }];
- }
- else if([title isEqualToString:@"Offline Setting"])
- {
-
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- //UIViewController* active_vc = appDelegate.active_controller;
- OfflineSettingViewController * offlineVC =[ [UIStoryboard storyboardWithName:@"OLM" bundle:nil] instantiateViewControllerWithIdentifier:@"OfflineSettingViewController"];
- // loginvc.delegate = self;
- // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- // appDelegate.active_controller = gunVC;
- // gunVC.onDismissVC = ^(){
- // appDelegate.active_controller = active_vc;
- // };
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:offlineVC] ;
-
-
-
-
-
- // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-
- navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
- // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
-
- DebugLog(@"about present.........");
-
- // self.btop = false;
- // <#code#>
- }];
-
- // [iSalesDB testdata];
-
- }
- else if([title isEqualToString:@"Function Test"])
- {
-
- // NSString* url = @"https://shopla.homelegance.com/";
- //
- //
- // NSString* title = @"NPD";
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- //
- //
-
- FunctionTestViewController *ViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"FunctionTestViewController"];
- // ViewController.url = url;
- // ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if ([title isEqualToString:@"BLOG"]) {
-
- NSString* url = URL_BLOG;
-
- #ifdef BUILD_HOMER
- NSString* title = @"HOMER BLOG";
-
- #endif
-
- #ifdef BUILD_GATIT
- NSString* title = @"TITAN BLOG";
-
- #endif
-
- #ifdef BUILD_NPD
- NSString* title = @"NPD BLOG";
- #endif
-
- #ifdef BUILD_USAI
- NSString* title = @"USAI BLOG";
- #endif
- #ifdef BUILD_CONTRAST
- NSString* title = @"CONTRAST BLOG";
- #endif
-
-
- title = [NSString stringWithFormat:@"%@ BLOG",COMPANY_SHORT_NAME];
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"NPD Website"])
- {
-
- NSString* url = @"https://www.newpacificdirect.com";//@"https://shopla.homelegance.com/general.htm?websiteId=1";//
-
-
- NSString* title = @"NPD";
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- //
- //
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"USAI Website"])
- {
-
- NSString* url = @"http://www.united-us.net/";//@"https://shopla.homelegance.com/general.htm?websiteId=1";//
-
-
- NSString* title = @"USAI";
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- //
- //
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"Homelegance Website"])
- {
-
- NSString* url = @"http://207.140.24.83";//@"https://shopla.homelegance.com/general.htm?websiteId=1";//
-
-
- NSString* title = @"Homelegance";
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- //
- //
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"HOMER Website"])
- {
-
- NSString* url = COMPANY_WEB;
-
- NSString* title = @"HOMER";
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"TITAN Website"])
- {
-
- NSString* url = COMPANY_WEB;
-
- NSString* title = @"TITAN";
-
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"NPD Policy"])
- {
-
- NSString* url = URL_NPD_POLICY;//@"https://shopla.homelegance.com/general.htm?websiteId=1";//
-
-
- NSString* title = @"NPD Policy";
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- //
- //
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"USAI Policy"])
- {
-
- NSString* url = URL_NPD_POLICY;
-
-
- NSString* title = @"USAI Policy";
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"HOMER Policy"])
- {
-
- NSString* url = URL_NPD_POLICY;
-
- NSString* title = @"HOMER Policy";
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"Simplified Buying Program"])
- {
-
- SimplifiedBuyingProgramViewController *ViewController = [[UIStoryboard storyboardWithName:@"NPD_Mobile" bundle:nil] instantiateViewControllerWithIdentifier:@"SimplifiedBuyingProgramViewController"];
-
-
-
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:ViewController] ;
-
-
-
-
-
- // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-
- navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
- // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
-
- DebugLog(@"about present.........");
-
- // self.btop = false;
- // <#code#>
- }];
-
- }
- else if ([title isEqualToString:@"Privacy Policy"]) {
-
- NSString* url = URL_PRIVACY;
-
- NSString* title = @"Privacy Policy";
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
- [self.navigationController pushViewController:ViewController animated:YES];
- }
- else if([title isEqualToString:@"About us"])
- {
-
-
-
-
- AboutViewController * aboutVC =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"AboutViewController"];
- // loginvc.delegate = self;
- // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
-
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:aboutVC] ;
-
-
-
-
- // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-
- navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
- // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
-
- DebugLog(@"about present.........");
-
- // self.btop = false;
- // <#code#>
- }];
-
- }
- // else if([title isEqualToString:@"Wish List"])
- // {
- // [self hideMenu];
- // [self switchtowishlist];
- // }
- else if([title isEqualToString:@"Show Price"])
- {
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore && [RASingleton sharedInstance].global_lock) {
-
- JKLockController *lockVC = [[JKLockController alloc] init];
- [lockVC setPasswordKey:[NSString stringWithFormat:@"%@_password",appDelegate.user]];
- __weak typeof(self) weakself = self;
- lockVC.authoReturn = ^(BOOL failure) {
-
- if (weakself) {
- __strong typeof(weakself) strongself = weakself;
- [appDelegate set_priceHidden:false];
-
- [strongself initMenuItems];
- [strongself hideMenu];
- }
- };
- [self.navigationController pushViewController:lockVC animated:YES];
-
- } else {
-
- [appDelegate set_priceHidden:false];
-
- [self initMenuItems];
- [self hideMenu];
- }
-
-
-
- }
- else if([title isEqualToString:@"Hide Price"])
- {
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore && [RASingleton sharedInstance].global_lock) {
-
- JKLockController *lockVC = [[JKLockController alloc] init];
- [lockVC setPasswordKey:[NSString stringWithFormat:@"%@_password",appDelegate.user]];
- __weak typeof(self) weakself = self;
- lockVC.authoReturn = ^(BOOL failure) {
-
- if (weakself) {
- __strong typeof(weakself) strongself = weakself;
- [appDelegate set_priceHidden:true];
-
- [strongself initMenuItems];
- [strongself hideMenu];
- }
- };
- [self.navigationController pushViewController:lockVC animated:YES];
-
- } else {
-
- [appDelegate set_priceHidden:true];
-
- [self initMenuItems];
- [self hideMenu];
-
- }
-
- }
-
-
-
- // else if([title isEqualToString:@"Portfolio"] || [title isEqualToString:@"Hang Tag"])
- // {
- // [self hideMenu];
- // if([self.current_VC isKindOfClass:[PortfolioViewController class]])
- // return;
- // [self flipFromViewController:self.current_VC toViewController:self.portfolioViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- // }
- // else if([title isEqualToString:@"View Portfolios"] || [title isEqualToString:@"View Hang Tags"])
- // {
- // [self hideMenu];
- // if([self.current_VC isKindOfClass:[PortfolioListViewController class]])
- // return;
- // [self flipFromViewController:self.current_VC toViewController:self.pdfListViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- // }
- else if([title isEqualToString:@"Contact"])
- {
- // UITableViewCell* cell =(UITableViewCell*) sender.superview.superview;
- //
- // NSIndexPath * indexPath = [self.detailTable indexPathForCell:cell];
- //
- // if(indexPath.section!=1)
- // return ;
- // // DebugLog(@"shouldchangeedit %d_%d",indexPath.section,indexPath.row);
- // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
- //
- // NSString* product_id = [item_json valueForKey:@"product_id"];
- [self hideMenu];
-
- [self switchtocontact];
- }
- else if([title isEqualToString:@"Cam Scan"])
- {
-
-
-
- // UITableViewCell* cell =(UITableViewCell*) sender.superview.superview;
- //
- // NSIndexPath * indexPath = [self.detailTable indexPathForCell:cell];
- //
- // if(indexPath.section!=1)
- // return ;
- // // DebugLog(@"shouldchangeedit %d_%d",indexPath.section,indexPath.row);
- // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
- //
- // NSString* product_id = [item_json valueForKey:@"product_id"];
- [self hideMenu];
- //
- // [self switchtocontact];
-
-
- ScannerViewController * scannerVC =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ScannerViewController"];
-
- [self.navigationController pushViewController:scannerVC animated:true];
- } else if ([title isEqualToString:@"Price Setting"]) {
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- if ([RASingleton sharedInstance].global_lock) {
-
- JKLockController *lockVC = [[JKLockController alloc] init];
- [lockVC setPasswordKey:[NSString stringWithFormat:@"%@_password",appDelegate.user]];
- __weak typeof(self) weakself = self;
- lockVC.authoReturn = ^(BOOL failure) {
-
- if (weakself) {
- __strong typeof(weakself) strongself = weakself;
-
- PriceSettingViewController *priceSettingVC =[ [UIStoryboard storyboardWithName:@"CUL" bundle:nil] instantiateViewControllerWithIdentifier:@"PriceSettingViewController"];
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:priceSettingVC] ;
-
- navi.navigationBar.translucent = NO;
- navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- [strongself presentViewController:navi animated:YES completion:^{
-
- }];
-
- }
- };
- [self.navigationController pushViewController:lockVC animated:YES];
-
- } else {
-
- PriceSettingViewController *priceSettingVC =[ [UIStoryboard storyboardWithName:@"CUL" bundle:nil] instantiateViewControllerWithIdentifier:@"PriceSettingViewController"];
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:priceSettingVC] ;
-
- navi.navigationBar.translucent = NO;
- navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
- }];
- }
-
-
- } else if ([title isEqualToString:@"Lock"] || [title isEqualToString:@"Unlock"]) {
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- JKLockController *lockVC = [[JKLockController alloc] init];
- [lockVC setPasswordKey:[NSString stringWithFormat:@"%@_password",appDelegate.user]];
- __weak typeof(self) weakself = self;
- lockVC.authoReturn = ^(BOOL failure) {
-
- if (weakself) {
- __strong typeof(weakself) strongself = weakself;
-
- [RASingleton sharedInstance].global_lock = ![RASingleton sharedInstance].global_lock;
- [strongself initMenuItems];
- [strongself hideMenu];
- }
- };
- [self.navigationController pushViewController:lockVC animated:YES];
-
- }
- }
- //#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
- //{
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- //
- //
- //
- // // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- // if(buttonIndex==alertView.cancelButtonIndex)
- // {
- //
- //
- //
- // }
- // else if(buttonIndex==1)
- // {
- // //open exist
- //
- // OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
- // ovc.showNavibar = true;
- // ovc.selectOrder = ^(NSMutableDictionary* order_detail){
- // if(appDelegate.order_code==nil)
- // {
- // [self neworderforCart];
- // }
- // else
- // {
- // self.previous_VC = self.current_VC;
- // [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- //
- // [self checklogin:true];
- //
- // }
- //
- // };
- // ovc.init_style = OL_OPEN;
- // ovc.onCancel = ^(){
- //
- // [self checklogin:true];
- //
- // };
- // ovc.title = @"SAVED ORDER";
- // [self.navigationController pushViewController:ovc animated:true];
- // }
- // else
- // {
- // //create new;
- //
- // if(appDelegate.customerInfo==nil)// select contact if current contact not exist
- // {
- //
- // ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- // cvc.showNavibar = true;
- // cvc.contact_type = @"Sales_Order_Customer";
- // cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
- //
- // appDelegate.contact_id=[value valueForKey:@"customer_cid"];
- // appDelegate.customerInfo = value;
- //
- //
- // if(appDelegate.order_code==nil)
- // [self neworderforCart];
- //
- //
- // };
- //
- // cvc.onCancel = ^(){
- //
- // [RAUtils message_box:@"" message:@"Cannot create order without customer infomation." completion:nil];
- //
- //
- //
- // };
- // cvc.onReset = ^(){
- // [self checklogin:true];
- // };
- //
- // [self.navigationController pushViewController:cvc animated:true];
- // }
- // else
- // {
- // [self neworderforCart];
- // }
- //
- // }
- //}
- -(void) neworderforCart
- {
-
- // __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Create Order" completion:^{
- PopWaitAlert* pop = [RAUtils waiting_pop:@"Create Order" completion:nil];
- [RANetwork request_create_order:^(NSMutableDictionary *result) {
- NSMutableDictionary* return_json = result;
-
- // [waitalert dismissViewControllerAnimated:YES completion:^{
- [pop hide];
- if([[return_json valueForKey:@"result"] intValue]==2)
- {
- int result=[[return_json valueForKey:@"result"] intValue];
- if(result==2)
- {
- //successed.
-
- NSString* order_code = [return_json valueForKey:@"orderCode"];
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- appDelegate.order_code = order_code;
- appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
-
- self.previous_VC = self.current_VC;
- [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
-
-
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- #else
- [self reloadCart:true immediately:false];
- [self reloadOrder:true immediately:false];
- #endif
-
-
- }
- }
- else
- {
- [RAUtils message_box:@"Add To Cart" message:[return_json valueForKey:@"err_msg"] completion:nil] ;
- }
- // }];
-
-
-
-
-
-
-
-
- }];
- // }];
-
- }
- - (void)showPriceAuth:(NSInteger)from {
-
- }
- @end
|