| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822 |
- //
- // 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 "Singleton.h"
- #import "NotificationNameCenter.h"
- @interface MainViewController ()
- @end
- @implementation MainViewController
- -(void) logoutDocuments
- {
- [self.pdfListViewController logout];
- }
- -(void) logoutCart
- {
- [self.cartViewController logout];
- }
- -(void) logoutWish
- {
- [self.watchListViewController logout];
- }
- -(void) logoutPortfolio
- {
- [self.portfolioViewController logout];
- }
- -(void) logoutOrder
- {
- [self.orderViewController logout];
- }
- -(void) logoutContact
- {
- [self.contactListViewController logout];
- }
- -(void) logoutCategory
- {
- [self.categoryViewController logout];
- }
- #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];
- [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,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)
- {
-
-
- ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- cvc.update_order = true;
- cvc.edit_icon = true;
- cvc.assig_icon = true;
- cvc.reset_icon = false;
-
- cvc.showNavibar = true;
- cvc.contact_type = @"Sales_Order_Customer";
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
-
- [self.navigationController popViewControllerAnimated:false];
- appDelegate.contact_id=[value valueForKey:@"customer_cid"];
- appDelegate.customerInfo = value;
-
- // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
- [self.navigationController pushViewController:cvc animated:true];
-
- }
- else
- {
- CustomerInfoViewController * vc = [[CustomerInfoViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
-
- vc.url_type = URL_LOCAL;
-
- // if(appDelegate.order_code.length>0)
- {
- vc.edit_icon = false;
- vc.assig_icon = true;
- vc.reset_icon = true;
- vc.request_url=LOCAL_URL_CUSTOMER_INFO_EDIT;
- }
- // 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){
-
-
- appDelegate.contact_id=[value valueForKey:@"customer_cid"];
- appDelegate.customerInfo = value;
- };
-
-
- [self.navigationController pushViewController:vc animated:true];
- }
-
-
-
-
- }
- - (void)viewDidLoad
- {
-
- [super viewDidLoad];
- // NSLog(@"decrypt:%@",[AESCrypt fastdecrypt:@"vafHUwfRPIUbPNVnKhLc5aAVK7sOFRztlfJVRHW7QVa/qGgm11E5UwfYWZEBTQpH"]);
-
- 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 initMenuItems];
- self.homeViewController =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"HomeViewController"];
- self.categoryViewController =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Search" bundle:nil] instantiateViewControllerWithIdentifier:@"CategoryViewController"];
- self.cartViewController =[[UIStoryboard storyboardWithName:@"ERP_Mobile_Cart" bundle:nil] instantiateViewControllerWithIdentifier:@"CartViewController"];
- self.orderViewController =[[UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
-
- 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;
- __block MainViewController *brself= self;
- 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.orderViewController.selectOrder=^(NSMutableDictionary* order_detail){
- //main view 下打开order
-
- //Capturing strongly warring;
- __block MainViewController *brbrself= brself;
- brself.cartViewController.onFinishLoad=^()
- {
- [brbrself.cartViewController placeOrder];
- brbrself.cartViewController.onFinishLoad=nil;
- };
- [brself refreshContactDisplay];
- [brself switchToCart:nil];
-
- };
- self.watchListViewController =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"WatchListViewController"];
- self.portfolioViewController = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Portfolio" bundle:nil] instantiateViewControllerWithIdentifier:@"PortfolioViewController" ];
-
-
- self.pdfListViewController = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Portfolio" bundle:nil] instantiateViewControllerWithIdentifier:@"PortfolioListViewController" ];
-
- self.itemSearchViewController=[[UIStoryboard storyboardWithName:@"ERP_Mobile_Search" bundle:nil] instantiateViewControllerWithIdentifier:@"ItemSearchViewController"];
- self.searchViewController=[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Search" bundle:nil] instantiateViewControllerWithIdentifier:@"SearchViewController"];
-
- [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.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];
- if(appDelegate.categoryMenu==nil)
- {
-
- [RANetwork request_category:^(NSMutableDictionary *result) {
- NSDictionary* category=result;
- if([[category valueForKey:@"result"] intValue]==2)
- {
- appDelegate.categoryMenu = category;
- }
- }];
- 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"] title:@"Failed to load category."] ;
- }
-
-
-
- // self.categoryViewController.categoryMenu = category;
-
-
-
- });
- });
-
- }
- // Do any additional setup after loading the view, typically from a nib.
- }
- - (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
- {
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- if(appDelegate.bLogin)
- {
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Sign out"];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* return_json = [RANetwork logout];
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-
-
- if([[return_json valueForKey:@"result"] intValue]==2)
- {
- // [self hideMenu];
- // [self switchToHome:nil];
- [appDelegate Logout];
- [self checklogin :false];
- if(showlogin)
- {
- LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
- loginvc.returnValue = ^(bool blogin){
-
- [self checklogin :true];
-
- };
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-
-
-
-
-
-
- navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
- DebugLog(@"login present.........");
-
- }];
- }
- }
- else
- {
- [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Sign Out" controller:self] ;
- }
-
-
-
-
- });
- });
- }
- else
- {
- LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
- loginvc.returnValue = ^(bool blogin){
-
- [self checklogin :true];
-
- };
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-
-
-
-
-
-
- navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
- DebugLog(@"login present.........");
-
- }];
- }
-
- }
- - (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 = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
- DebugLog(@"login present.........");
-
- }];
- }
-
- };
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:vc] ;
-
-
-
-
-
-
- navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [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"];
-
- [self.navigationController pushViewController:scannerVC animated:true];
-
-
-
- }
- - (IBAction)switchToSearch:(UIButton *)sender {
- if([self.current_VC isKindOfClass:[SearchViewController class]])
- return;
- [self flipFromViewController:self.current_VC toViewController:self.searchViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
-
-
- }
- - (IBAction)switchToWishlist:(UIButton *)sender {
- [self switchtowishlist];
- }
- -(void)switchtowishlist
- {
- if([self.current_VC isKindOfClass:[WatchListViewController 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 = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [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.watchListViewController 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_alert:@"Customer Login does not support this feature." title:@"Contact List" controller:self] ;
- }
-
- }
-
-
- };
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-
-
-
-
-
- // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-
- navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [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];
-
- [RANetwork request_category:^(NSMutableDictionary *result) {
- NSDictionary* category=result;
- if([[category valueForKey:@"result"] intValue]==2)
- {
- appDelegate.categoryMenu = category;
- }
- }];
- 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"]] ;
- }
-
- });
- });
-
- }
- - (IBAction)onUserButtonClick:(id)sender {
-
- DebugLog(@"header view login");
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- if( appDelegate.user ==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 = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
-
- // <#code#>
- }];
-
- }
- }
- #pragma mark - LoginViewControllerDelegate
- -(void)LoginViewControllerDidLogin:(LoginViewController *)viewController
- {
- [viewController dismissViewControllerAnimated:YES completion:nil];
- 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;
- NSLog(@"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 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
- {
- if([self.current_VC isKindOfClass:[HomeViewController class]])
- return;
-
- if(self.homeViewController == nil)
- {
- self.homeViewController =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"HomeViewController"];
- 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 switchToCart];
-
- // self.current_vc = VC_HOME;
- }
- -(void) switchToCart
- {
- if([self.current_VC isKindOfClass:[CartViewController class]])
- return;
-
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- if(appDelegate.bLogin==false)
- {
-
- 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"]];
-
- }
- 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
- {
- 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 = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [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"]];
-
- }
-
- 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
- {
- 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];
-
-
-
- }
- }
-
-
-
- }
- -(void) switchToOrder
- {
- 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.orderViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- }
-
-
- };
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-
-
-
-
-
- // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-
- navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [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.orderViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
-
- }
- - (IBAction)switchToOrder:(id)sender {
-
- [self switchToOrder];
-
- }
- #pragma mark - CategoryMenuDelegate
- -(void)SelectCategory:(NSString *)category
- {
- [self switchToCagegory:category];
-
- }
- - (IBAction)showCategoryMenu:(id)sender {
- RAViewController * categorymenuVC =[[UIStoryboard storyboardWithName:@"ERP_Mobile_Search" bundle:nil] instantiateViewControllerWithIdentifier:@"RAViewController"];
-
- // categorymenuVC.rootViewController = self;
- categorymenuVC.CateMenu_delegate = self;
-
-
- // categorymenuVC.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- // [self presentViewController:categorymenuVC animated:YES completion:^{
- //
- // DebugLog(@"login.........");
- // // <#code#>
- // }];
-
-
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:categorymenuVC] ;
-
-
-
-
-
-
- navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
- // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
-
- DebugLog(@"bundle present.........");
-
- // self.btop = false;
- // <#code#>
- }];
-
- // if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
- // categorymenuVC.providesPresentationContextTransitionStyle = YES;
- // categorymenuVC.definesPresentationContext = YES;
- // categorymenuVC.modalPresentationStyle = UIModalPresentationFormSheet;
- // [self presentViewController:categorymenuVC animated:YES completion:nil];
- // } else {
- // categorymenuVC.modalPresentationStyle = UIModalPresentationFormSheet;
- // [self presentViewController:categorymenuVC animated:NO completion:nil];
- //// self.view.window.rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;
- // }
-
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- if(appDelegate.categoryMenu == nil)
- {
- [RANetwork request_category:^(NSMutableDictionary *result) {
- NSDictionary* category=result;
- if([[category valueForKey:@"result"] intValue]==2)
- {
- appDelegate.categoryMenu = category;
- [categorymenuVC SetMenu:appDelegate.categoryMenu ];
- }
- else
- if([[category valueForKey:@"result"] intValue]==RESULT_NET_ERROR)
- {
- [categorymenuVC SetMenu:nil ];
- }
- else
- {
- [RAUtils message_alert:[category valueForKey:@"err_msg"] title:@"Load Category Menu" controller:self] ;
- }
- }];
- 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;
- [categorymenuVC SetMenu:appDelegate.categoryMenu ];
- }
- else
- if([[category valueForKey:@"result"] intValue]==RESULT_NET_ERROR)
- {
- [categorymenuVC SetMenu:nil ];
- }
- else
- {
- [RAUtils message_alert:[category valueForKey:@"err_msg"] title:@"Load Category Menu" controller:self] ;
- }
-
-
-
- });
- });
- }
-
- else
- [categorymenuVC SetMenu:appDelegate.categoryMenu];
- }
- -(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) || defined(BUILD_USAI)
- [map setValue:@"Scanner Setting" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
- #ifdef BUILD_NPD
- 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 ([Singleton sharedInstance].global_lock) {
- [map setValue:@"Unlock" forKey:@"title"];
- } else {
- [map setValue:@"Lock" forKey:@"title"];
- }
-
- [self.sideMenuItems addObject:map.copy];
- }
-
- # endif
-
- #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
-
- #ifdef 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;
-
-
- }
- #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#>
- }];
-
-
-
-
- }
- else if([title isEqualToString:@"Scanner Setting"])
- {
-
-
- UIApplication * app = [UIApplication sharedApplication];
- //
- #ifndef RA_NOTIFICATION
- 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 = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [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 = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [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
-
- 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 = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [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 = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [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 && [Singleton 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 && [Singleton 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 ([Singleton 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 = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [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 = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
- [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;
-
- [Singleton sharedInstance].global_lock = ![Singleton 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_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
-
-
-
- };
- cvc.onReset = ^(){
- [self checklogin:true];
- };
-
- [self.navigationController pushViewController:cvc animated:true];
- }
- else
- {
- [self neworderforCart];
- }
-
- }
- }
- -(void) neworderforCart
- {
-
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* return_json = [RANetwork new_Order];
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-
-
- 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_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
- }
-
-
-
-
- });
- });
- }
- - (void)showPriceAuth:(NSInteger)from {
-
- }
- @end
|