| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670 |
- //
- // ViewController.m
- // RedAnt ERP Suite
- //
- // Created by Ray on 14-5-19.
- // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
- //
- #import "MainViewController.h"
- //#import "SideMenuViewController.h"
- //#import "RootContainerViewController.h"
- #import <Accelerate/Accelerate.h>
- #import "PopupNavigationController.h"
- //#import "CommonGridViewController.h"
- #import "CacheViewController.h"
- #import "ScannerViewController.h"
- #import "ContactListViewController.h"
- #import "RAUtils.h"
- #import "AboutViewController.h"
- #import "ScannerSettingViewController.h"
- #import "ActiveViewController.h"
- #import "WebViewController.h"
- #import "FunctionTestViewController.h"
- #import "SimplifiedBuyingProgramViewController.h"
- #import "UserListViewController.h"
- #import "OfflineSettingViewController.h"
- #import "DefaultAppearance.h"
- #import "PriceSettingViewController.h"
- #import "JKLockController.h"
- #import "RASingleton.h"
- #import "NotificationNameCenter.h"
- #import "OLOSettingViewController.h"
- #import "CustomerEditViewController.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];
-
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- [RANetwork LoadImage:appDelegate.user_icon into:self.user_head ];
- });
-
-
- if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/true)
- self.btnContact.hidden = NO;
- // else
- // self.btnContact.hidden = YES;
-
- NSDictionary * customerinfo=appDelegate.customerInfo;
- NSString * contact=nil;
- NSString * customer=nil;
- if(customerinfo==nil)
- {
- contact=@"Select Contact";
- [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
- }
- else
- {
- contact=[customerinfo valueForKey:@"customer_contact"];
- customer=[customerinfo valueForKey:@"customer_name"];
- if(contact==nil||contact.length==0)
- {
- contact=@"No Name";
- [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
- }
- else
- {
- [self.btnContact setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
- }
- }
-
- self.btnContact.hidden = !appDelegate.bLogin;// 修复登出后仍旧显示select contact
-
-
- NSMutableArray* arr_contact = [[NSMutableArray alloc] init];
- if(contact.length>0)
- [arr_contact addObject:contact];
- if(customer.length>0)
- [arr_contact addObject:customer];
-
- NSString *contact_string = [arr_contact componentsJoinedByString:@" @"];
-
-
- [self.btnContact setTitle:contact_string forState:UIControlStateNormal];
-
- // if(appDelegate.bLogin)
- // [self.buttonUser setTitle:appDelegate.user forState:UIControlStateNormal];
- // else
- // [self.buttonUser setTitle:@"Sign in" forState:UIControlStateNormal];
-
-
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"DetailViewController,PDFListViewController,CartViewController,PortfolioViewController,WatchListViewController,OrderListViewController,OrderListViewController,ContactListViewController,CategoryViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- #else
- [self reloadDocuments:true immediately:false];
- [self reloadCart:true immediately:false];
- [self reloadPortfolio:true immediately:false];
- [self reloadWish:true immediately:false];
-
- [self reloadOrder:true immediately:false];
- [self reloadContact:true immediately:false];
- [self reloadCategory:true immediately:false];
-
-
-
- ActiveViewController* lrvc = (ActiveViewController*)appDelegate.active_controller;
- if(reloadCurrentVC)
- {
-
-
- if(lrvc!=nil)
- [ lrvc refresh_on_login];
- }
- else
- {
- if(lrvc.refresh_type<=REFRESH_DATA)
- lrvc.refresh_type = REFRESH_DATA;
- else if(lrvc.refresh_type<=REFRESH_VIEW)
- lrvc.refresh_type = REFRESH_VIEW;
- }
- #endif
- // [self reload];
-
-
- }
- - (IBAction)onContactClick:(id)sender {
-
-
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- NSString* contactid=appDelegate.contact_id ;
-
- if(contactid==nil)
- {
-
-
- 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"];
- __block MainViewController *brself= self;
-
-
- #ifdef SCANNER_ORDER
-
- self.scanorderViewController =[[UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"ScanOrderListViewController"];
- #else
- self.orderViewController =[[UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
- 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];
-
- };
-
- #endif
-
- self.contactListViewController = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- self.contactListViewController.contact_type = @"Sales_Order_Customer";
-
- self.contactListViewController.edit_icon = true;
- self.contactListViewController.assig_icon = true;
- self.contactListViewController.reset_icon = false;
- self.contactListViewController.ui_type = CONTACT_LIST;
- self.contactListViewController.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- appDelegate.contact_id=[value valueForKey:@"customer_cid"];
- appDelegate.customerInfo = value;
- [brself refreshContactDisplay];
- [brself switchToCart:nil];
-
- // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
- //Capturing strongly warring;
-
-
-
- self.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)
- {
- __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Sign out" completion:^{
- [RANetwork request_logout:^(NSMutableDictionary *result) {
- NSMutableDictionary* return_json =result;
-
- [waitalert dismissViewControllerAnimated:YES completion:^{
- 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] ;
- }
- }];
-
-
-
-
-
-
-
-
- }];
- }];
-
-
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* return_json = [RANetwork logout];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [waitalert dismissViewControllerAnimated:YES completion:nil];
- //
- //
- // 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:^{
- 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&& !RASingleton.sharedInstance.enable_OfflineOrder)
- {
-
- LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
- // loginvc.delegate = self;
- // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
-
- loginvc.returnValue = ^(bool blogin){
-
-
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
-
-
-
- if(blogin)
- {
- if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/true)
- {
-
- [self checklogin:false];
- if(appDelegate.can_create_order)
- {
-
- NSString* msg =@"";
- if(appDelegate.contact_id.length>0)
- {
- msg = [msg stringByAppendingString:@"\n\nCustomer:"];
- msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
-
- }
-
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Switch To Cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
-
- UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- //open exist
-
- 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];
- }];
- UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- //create new;
-
- if(appDelegate.customerInfo==nil)// select contact if current contact not exist
- {
- ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- cvc.showNavibar = true;
- cvc.contact_type = @"Sales_Order_Customer";
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- appDelegate.contact_id=[value valueForKey:@"customer_cid"];
- appDelegate.customerInfo = value;
-
-
- if(appDelegate.order_code==nil)
- [self neworderforCart];
-
- };
-
- cvc.onCancel = ^(){
-
- [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
-
-
-
- };
- cvc.onReset = ^(){
- [self checklogin:true];
- };
-
- [self.navigationController pushViewController:cvc animated:true];
- }
- else
- {
- [self neworderforCart];
- }
-
- }];
- UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
-
-
- }];
-
- [alertController addAction:action_1];
- [alertController addAction:action_2];
- [alertController addAction:action_3];
-
-
- [self presentViewController:alertController animated:YES completion:nil];
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch To Cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil),NSLocalizedString(@"Create new order", nil), nil];
- //
- //
- //
- // // alert.
- // [alert show];
- }
- else
- {
-
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Switch To Cart" message:@"Do you want to switch to a pending order?" preferredStyle:UIAlertControllerStyleAlert];
-
-
- UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- //open exist
-
- 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];
- }];
- UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
-
-
- }];
-
-
- [alertController addAction:action_2];
- [alertController addAction:action_3];
-
-
- [self presentViewController:alertController animated:YES completion:nil];
-
-
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch To Cart", nil) message:NSLocalizedString(@"Do you want to switch to a pending order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil), nil];
- //
- // // alert.
- // [alert show];
- }
- }
- // else
- // {
- // [self checklogin:true];
- // self.previous_VC = self.current_VC;
- // [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- // }
- }
-
- // self.offset = 0;
- // [self.content_data removeAllObjects];
- // [self loadpage];
- //
- // [[self navigationController] setNavigationBarHidden:YES animated:NO];
-
- };
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
-
-
-
-
-
- // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-
- navi.modalPresentationStyle = 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"]];
-
- }
-
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Switch To Cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
-
- UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
- //open exist
-
- 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];
- }];
- UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- //create new;
-
- if(appDelegate.customerInfo==nil)// select contact if current contact not exist
- {
- ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- cvc.showNavibar = true;
- cvc.contact_type = @"Sales_Order_Customer";
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- appDelegate.contact_id=[value valueForKey:@"customer_cid"];
- appDelegate.customerInfo = value;
-
-
- if(appDelegate.order_code==nil)
- [self neworderforCart];
-
- };
-
- cvc.onCancel = ^(){
-
- [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
-
-
-
- };
- cvc.onReset = ^(){
- [self checklogin:true];
- };
-
- [self.navigationController pushViewController:cvc animated:true];
- }
- else
- {
- [self neworderforCart];
- }
-
- }];
- UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
-
-
- }];
-
- [alertController addAction:action_1];
- [alertController addAction:action_2];
- [alertController addAction:action_3];
-
-
- [self presentViewController:alertController animated:YES completion:nil];
-
-
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch to cart", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Check for saved order", nil),NSLocalizedString(@"Create new order", nil), nil];
- //
- // // alert.
- // [alert show];
- }
- else
- {
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Switch To Cart" message:@"Do you want to switch to a pending order?" preferredStyle:UIAlertControllerStyleAlert];
-
-
- UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Switch to pending order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- //open exist
-
- 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];
- }];
- UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
-
-
- }];
-
-
- [alertController addAction:action_2];
- [alertController addAction:action_3];
-
-
- [self presentViewController:alertController animated:YES completion:nil];
-
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch to cart", nil) message:NSLocalizedString(@"Do you want to Switch to a pending order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Switch to pending order", nil), nil];
- //
- // // alert.
- // [alert show];
- }
- }
- else
- {
-
- self.previous_VC = self.current_VC;
- [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
-
-
-
- }
- }
-
-
-
- }
- -(void) switchToOrder
- {
- if([self.current_VC isKindOfClass:[OrderListViewController class]])
- return;
- // if([self.current_VC isKindOfClass:[ScanOrderListViewController 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];
-
- #ifdef SCANNER_ORDER
- [self flipFromViewController:self.current_VC toViewController:self.scanorderViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- #else
- [self flipFromViewController:self.current_VC toViewController:self.orderViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- #endif
- }
-
-
- };
-
- 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
- {
- #ifdef SCANNER_ORDER
- [self flipFromViewController:self.current_VC toViewController:self.scanorderViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- #else
- [self flipFromViewController:self.current_VC toViewController:self.orderViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- #endif
-
- }
-
- }
- - (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)
- [map setValue:@"Scanner Setting" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
- # endif
-
- #if defined(SCANNER_ORDER)
- [map setValue:@"Scanner Order" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
- # endif
-
- #if defined(BUILD_NPD)|| defined (BUILD_CONTRAST)
- if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
- {
- [map setValue:@"Offline Setting" forKey:@"title"];
- [map setValue:@"rect_market_news" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- }
- #endif
-
- if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore ) {
- [map setValue:@"Price Setting" forKey:@"title"];
- // [map setValue:@"rect_market_news" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
- }
- if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore ) {
- if ([RASingleton sharedInstance].global_lock) {
- [map setValue:@"Unlock" forKey:@"title"];
- } else {
- [map setValue:@"Lock" forKey:@"title"];
- }
-
- [self.sideMenuItems addObject:map.copy];
- }
-
-
- #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
- /*
- if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
- {
- [map setValue:@"Offline Setting" forKey:@"title"];
- [map setValue:@"rect_market_news" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- }
- */
- // if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER) {
- // [map setValue:@"Price Setting" forKey:@"title"];
- // // [map setValue:@"rect_market_news" forKey:@"img"];
- // [self.sideMenuItems addObject:map.copy];
- // }
- if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore ) {
- if ([Singleton sharedInstance].global_lock) {
- [map setValue:@"Unlock" forKey:@"title"];
- } else {
- [map setValue:@"Lock" forKey:@"title"];
- }
-
- [self.sideMenuItems addObject:map.copy];
- }
-
- # endif
-
- #ifdef DEBUG
- // if([[appDelegate.user lowercaseString] isEqualToString:@"larryl"]||[[appDelegate.user lowercaseString] isEqualToString:@"arpithat"])
- {
- // [map setValue:@"Contact" forKey:@"title"];
- // [map setValue:@"rect_contact_list" forKey:@"img"];
- // [self.sideMenuItems addObject:map.copy];
-
-
- [map setValue:@"Function Test" forKey:@"title"];
- [map setValue:@"rect_market_news" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- }
-
- #endif
-
- [map setValue:@"Privacy Policy" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
-
- [map setValue:@"About us" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
-
- #ifdef BUILD_HMLG
- [map setValue:@"Homelegance Website" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
- #endif
-
- #if defined(BUILD_NPD)
- [map setValue:@"BLOG" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- [map setValue:[NSString stringWithFormat:@"%@ Website",COMPANY_SHORT_NAME] forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- [map setValue:[NSString stringWithFormat:@"%@ Policy",COMPANY_SHORT_NAME] forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- [map setValue:@"Simplified Buying Program" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
- #endif
-
- #ifdef BUILD_USAI
- // [map setValue:@"BLOG" forKey:@"title"];
- // [map setValue:@"rect_change_password" forKey:@"img"];
- // [self.sideMenuItems addObject:map.copy];
-
- [map setValue:@"USAI Website" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- #endif
-
- #ifdef BUILD_HOMER
- /*
- [map setValue:@"BLOG" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
- */
-
- [map setValue:@"HOMER Website" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- #endif
-
- #ifdef BUILD_GATIT
-
- [map setValue:@"TITAN Website" forKey:@"title"];
- [map setValue:@"rect_change_password" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
-
- # endif
-
-
-
- if(appDelegate.bLogin&&!appDelegate.offline_mode)
- {
- [map setValue:@"Delete Account" forKey:@"title"];
- [map setValue:@"rect_announcements" forKey:@"img"];
- [self.sideMenuItems addObject:map.copy];
- }
-
- [self.sideMenuTable reloadData];
-
- //
-
- }
- - (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius sourceImage:(UIImage*)sourceImage tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage
- {
- // Check pre-conditions.
- if (sourceImage.size.width < 1 || sourceImage.size.height < 1) {
- DebugLog (@"*** error: invalid size: (%.2f x %.2f). Both dimensions must be >= 1: %@", sourceImage.size.width, sourceImage.size.height, self);
- return nil;
- }
- if (!sourceImage.CGImage) {
- DebugLog (@"*** error: image must be backed by a CGImage: %@", self);
- return nil;
- }
- if (maskImage && !maskImage.CGImage) {
- DebugLog (@"*** error: maskImage must be backed by a CGImage: %@", maskImage);
- return nil;
- }
-
- CGRect imageRect = { CGPointZero, sourceImage.size };
- UIImage *effectImage = sourceImage;
-
- BOOL hasBlur = blurRadius > __FLT_EPSILON__;
- BOOL hasSaturationChange = fabs(saturationDeltaFactor - 1.) > __FLT_EPSILON__;
- if (hasBlur || hasSaturationChange) {
- UIGraphicsBeginImageContextWithOptions(sourceImage.size, NO, [[UIScreen mainScreen] scale]);
- CGContextRef effectInContext = UIGraphicsGetCurrentContext();
- CGContextScaleCTM(effectInContext, 1.0, -1.0);
- CGContextTranslateCTM(effectInContext, 0, -sourceImage.size.height);
- CGContextDrawImage(effectInContext, imageRect, sourceImage.CGImage);
-
- vImage_Buffer effectInBuffer;
- effectInBuffer.data = CGBitmapContextGetData(effectInContext);
- effectInBuffer.width = CGBitmapContextGetWidth(effectInContext);
- effectInBuffer.height = CGBitmapContextGetHeight(effectInContext);
- effectInBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectInContext);
-
- UIGraphicsBeginImageContextWithOptions(sourceImage.size, NO, [[UIScreen mainScreen] scale]);
- CGContextRef effectOutContext = UIGraphicsGetCurrentContext();
- vImage_Buffer effectOutBuffer;
- effectOutBuffer.data = CGBitmapContextGetData(effectOutContext);
- effectOutBuffer.width = CGBitmapContextGetWidth(effectOutContext);
- effectOutBuffer.height = CGBitmapContextGetHeight(effectOutContext);
- effectOutBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectOutContext);
-
- if (hasBlur) {
- // A description of how to compute the box kernel width from the Gaussian
- // radius (aka standard deviation) appears in the SVG spec:
- // http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement
- //
- // For larger values of 's' (s >= 2.0), an approximation can be used: Three
- // successive box-blurs build a piece-wise quadratic convolution kernel, which
- // approximates the Gaussian kernel to within roughly 3%.
- //
- // let d = floor(s * 3*sqrt(2*pi)/4 + 0.5)
- //
- // ... if d is odd, use three box-blurs of size 'd', centered on the output pixel.
- //
- CGFloat inputRadius = blurRadius * [[UIScreen mainScreen] scale];
-
-
- NSUInteger radius = floor(inputRadius * 3. * sqrt(2 * M_PI) / 4 + 0.5);
- if (radius % 2 != 1) {
- radius += 1; // force radius to be odd so that the three box-blur methodology works.
- }
- vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, (unsigned int)radius, (unsigned int)radius, 0, kvImageEdgeExtend);
- vImageBoxConvolve_ARGB8888(&effectOutBuffer, &effectInBuffer, NULL, 0, 0, (unsigned int)radius, (unsigned int)radius, 0, kvImageEdgeExtend);
- vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, (unsigned int)radius, (unsigned int)radius, 0, kvImageEdgeExtend);
- }
- BOOL effectImageBuffersAreSwapped = NO;
- if (hasSaturationChange) {
- CGFloat s = saturationDeltaFactor;
- CGFloat floatingPointSaturationMatrix[] = {
- 0.0722 + 0.9278 * s, 0.0722 - 0.0722 * s, 0.0722 - 0.0722 * s, 0,
- 0.7152 - 0.7152 * s, 0.7152 + 0.2848 * s, 0.7152 - 0.7152 * s, 0,
- 0.2126 - 0.2126 * s, 0.2126 - 0.2126 * s, 0.2126 + 0.7873 * s, 0,
- 0, 0, 0, 1,
- };
- const int32_t divisor = 256;
- NSUInteger matrixSize = sizeof(floatingPointSaturationMatrix)/sizeof(floatingPointSaturationMatrix[0]);
- int16_t saturationMatrix[matrixSize];
- for (NSUInteger i = 0; i < matrixSize; ++i) {
- saturationMatrix[i] = (int16_t)roundf(floatingPointSaturationMatrix[i] * divisor);
- }
- if (hasBlur) {
- vImageMatrixMultiply_ARGB8888(&effectOutBuffer, &effectInBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags);
- effectImageBuffersAreSwapped = YES;
- }
- else {
- vImageMatrixMultiply_ARGB8888(&effectInBuffer, &effectOutBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags);
- }
- }
- if (!effectImageBuffersAreSwapped)
- effectImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
-
- if (effectImageBuffersAreSwapped)
- effectImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- }
-
- // Set up output context.
- UIGraphicsBeginImageContextWithOptions(sourceImage.size, NO, [[UIScreen mainScreen] scale]);
- CGContextRef outputContext = UIGraphicsGetCurrentContext();
- CGContextScaleCTM(outputContext, 1.0, -1.0);
- CGContextTranslateCTM(outputContext, 0, -sourceImage.size.height);
-
- // Draw base image.
- CGContextDrawImage(outputContext, imageRect, sourceImage.CGImage);
-
- // Draw effect image.
- if (hasBlur) {
- CGContextSaveGState(outputContext);
- if (maskImage) {
- CGContextClipToMask(outputContext, imageRect, maskImage.CGImage);
- }
- CGContextDrawImage(outputContext, imageRect, effectImage.CGImage);
- CGContextRestoreGState(outputContext);
- }
-
- // Add in color tint.
- if (tintColor) {
- CGContextSaveGState(outputContext);
- CGContextSetFillColorWithColor(outputContext, tintColor.CGColor);
- CGContextFillRect(outputContext, imageRect);
- CGContextRestoreGState(outputContext);
- }
-
- // Output image is ready.
- UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
-
- return outputImage;
- }
- //- (IBAction)openMenu:(UIButton *)sender {
- //}
- #pragma mark - Table view data source
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
-
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
-
- return self.sideMenuItems.count;
-
-
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- NSString *CellIdentifier = @"SideMenuItem";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- NSString* title = [self.sideMenuItems[indexPath.row] valueForKey:@"title"];
- cell.backgroundColor = [UIColor clearColor];
- // [cell.backgroundColor:[UIColor clearColor]];
- // UIImageView* iv= [[UIImageView alloc] initWithImage:];
- cell.textLabel.text = title;
- cell.detailTextLabel.textColor =[UIColor redColor];
- if([title isEqualToString:@"Wish List"]&&appDelegate.wish_count>0)
- cell.detailTextLabel.text = [NSString stringWithFormat:@"%ld",appDelegate.wish_count];
- else if(([title isEqualToString:@"Portfolio"] || [title isEqualToString:@"Hang Tag"])&&appDelegate.port_count>0)
- cell.detailTextLabel.text = [NSString stringWithFormat:@"%ld",appDelegate.port_count];
- else
- {
- cell.detailTextLabel.text =nil;
- }
- // cell.imageView.image = [UIImage imageNamed:[self.toolsinfo[indexPath.row] valueForKey:@"img"]];
-
- return cell;
-
-
- }
- #ifdef SCANNER_ORDER
- #pragma mark - Offline Order
- -(void) CreateOfflineOrder
- {
-
- RASingleton.sharedInstance.enable_OfflineOrder = true;
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- __block MainViewController *brself= self;
- if(appDelegate.contact_id.length<=0)
- {
-
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"New Offline Order" message:nil preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"With Offline Contact" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
- // if(appDelegate.order_code && appDelegate.order_code.length>0)
- // {
- // [RAUtils message_alert:@"Please close current order and try again." title:@"" controller:self];
- // }
- // NSLog(@"new click");
-
- NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
-
- // NSString *path = [[NSBundle mainBundle] pathForResource:@"editContact.json" ofType:nil];
-
- CustomerEditViewController * cuseditVC = [[CustomerEditViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
- cuseditVC.bnewcustomer=true;
- cuseditVC.bolocustomer = true;
- cuseditVC.url_type = URL_FILE;
- cuseditVC.request_url=[OLDataProvider scanTemplatePath:@"scan_contact.json"];
-
- cuseditVC.params = params;
-
- cuseditVC.returnValue=^(NSMutableDictionary* value)
- {
- if(value==nil)
- {
- [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
- }
- else
- {
- NSString* contact_id=[[NSUUID new] UUIDString];
-
-
-
-
-
-
- value [@"customer_cid"] = contact_id;
- appDelegate.contact_id=contact_id;
- appDelegate.customerInfo = value;
- [brself refreshContactDisplay];
- [self newoloorder];
- // [brself switchToCart:nil];
-
- }
- };
-
-
- // cuseditVC.delegate=self;
- //
- // if(checked.count==count)
- // {
- // orderinfoVC.have_tail = true
- // }
-
- [[self navigationController] setNavigationBarHidden:NO animated:NO];
- [self.navigationController pushViewController:cuseditVC animated:false];
-
- // [self dismissViewControllerAnimated:NO completion:^{
- //// [(UINavigationController*)[self parentViewController] pushViewController:cuseditVC animated:false];;
- //// [[self navigationController] setNavigationBarHidden:NO animated:NO];
- //
- //// [self pushViewController:cuseditVC animated:false];
- // }];
-
- // [[self navigationController] setNavigationBarHidden:NO animated:NO];
- // [self.navigationController pushViewController:cuseditVC animated:false];
-
-
- }];
- UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"With Online Contact" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- if(appDelegate.order_code && appDelegate.order_code.length>0)
- {
- // appDelegate.order_code= nil;
- // [appDelegate SetSo:nil];
-
-
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- 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;
-
- // self.norefresh = true;
- [self newoloorder];
-
-
-
- // [main_vc checklogin:true];
- // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
- cvc.onCancel = ^(){
- // self.norefresh = true;
- if(appDelegate.customerInfo==nil)
- {
- [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
- }
- else
- {
- [self newoloorder];
- }
- // [main_vc checklogin:true];
- };
- cvc.onReset = ^(){
- // [main_vc checklogin:true];
- };
-
- [self.navigationController pushViewController:cvc animated:true];
-
-
- }
- else
- {
- //create new;
-
- if(appDelegate.customerInfo==nil)// select contact if current contact not exist
- {
- MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- 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 newoloorder];
-
- // [main_vc checklogin:true];
- // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
- cvc.onCancel = ^(){
-
- [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
-
-
-
- };
- cvc.onReset = ^(){
- [main_vc checklogin:true];
- };
-
- [self.navigationController pushViewController:cvc animated:true];
- }
- else
- {
- [self newoloorder];
- }
- }
-
- }];
- UIAlertAction *alertCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
-
- }];
-
- [alertControl addAction:actionOne];
-
- [alertControl addAction:alertthree];
- [alertControl addAction:alertCancel];
-
- [self presentViewController:alertControl animated:YES completion:nil];
- }
- else
- {
- [self newoloorder];
- }
- }
- -(void) newoloorder
- {
- NSString* order_code = [[NSUUID new] UUIDString];
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- appDelegate.order_code = order_code;
-
- // NSData* json =[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:URL_SO_CART ofType:@"json" ]];
- NSMutableDictionary* cartTemplate=[OLDataProvider loadScanTemplate:@"scan_cart.json"];
- RASingleton.sharedInstance.scan_cart=cartTemplate;//[[RAConvertor data2dict:json] mutableCopy];
- appDelegate.user_type = USER_ROLE_EMPLOYEE;
- appDelegate.can_set_cart_price = true;
- appDelegate.can_see_price = true;
-
- // __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Create Order" completion:^{
- // [RANetwork request_create_order:^(NSMutableDictionary *result) {
- // NSMutableDictionary* return_json =result;
- //
- // [waitalert dismissViewControllerAnimated:YES completion:^{
- // 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];
- //
- //
- // #ifdef RA_NOTIFICATION
- // [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- // #else
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- // [main_vc reloadCart:true immediately:false];
- // #endif
- //
- //// [self ReloadData];
- //
- //
- // // [self performSelector:@selector(loadpage) withObject:nil afterDelay:1];
- // // [self loadpage];
- //
- //
- // // if(self.shopCartBlock!=nil)
- // // {
- // // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
- // //
- // //
- // // CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
- // // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
- // // iv.image = img;
- // // // [self.contentView addSubview:iv];
- // // self.shopCartBlock(iv);
- // //
- // // }
- //
- // }
- // }
- // else
- // {
- // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:self] ;
- // }
- // }];
- // // [waitalert dismissViewControllerAnimated:YES completion:nil];
- //
- //
- //
- //
- //
- //
- //
- //
- // }];
- //
- // }];
-
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* return_json = [RANetwork new_Order];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [waitalert dismissViewControllerAnimated:YES completion:nil];
- //
- //
- // 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];
- //
- //
- //#ifdef RA_NOTIFICATION
- // [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- //#else
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- // [main_vc reloadCart:true immediately:false];
- //#endif
- //
- // [self ReloadData];
- //
- //
- // // [self performSelector:@selector(loadpage) withObject:nil afterDelay:1];
- // // [self loadpage];
- //
- //
- // // if(self.shopCartBlock!=nil)
- // // {
- // // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
- // //
- // //
- // // CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
- // // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
- // // iv.image = img;
- // // // [self.contentView addSubview:iv];
- // // self.shopCartBlock(iv);
- // //
- // // }
- //
- // }
- // }
- // else
- // {
- // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- }
- #endif
- #pragma mark - Table view delegate
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NSString* title = [self.sideMenuItems[indexPath.row] valueForKey:@"title"];
- if([title isEqualToString:@"Cache"])
- {
- CacheViewController * settingvc=[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CacheViewController"];
-
-
- PopupNavigationController * navi=[[PopupNavigationController alloc] initWithRootViewController:settingvc];
- navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
- [self presentViewController:navi animated:YES completion:^{
-
- //DebugLog(@"login.........");
- // <#code#>
- }];
-
-
-
-
- }
- #ifdef SCANNER_ORDER
- else if([title isEqualToString:@"Scanner Order"])
- {
-
- OLOSettingViewController * offlineVC =[ [UIStoryboard storyboardWithName:@"OLM" bundle:nil] instantiateViewControllerWithIdentifier:@"OLOSettingViewController"];
- offlineVC.returnValue=^(int type){
- if(type == OOC_CREATE_ORDER){
- [self CreateOfflineOrder];
- }
- };
- // 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#>
- }];
-
- }
- #endif
- else if([title isEqualToString:@"Scanner Setting"])
- {
-
-
-
- //
- #ifndef RA_NOTIFICATION
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- UIViewController* active_vc = appDelegate.active_controller;
- ScannerSettingViewController * gunVC =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ScannerSettingViewController"];
- appDelegate.active_controller = gunVC;
- gunVC.onDismissVC = ^(){
- appDelegate.active_controller = active_vc;
- };
- #else
- ScannerSettingViewController * gunVC =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ScannerSettingViewController"];
- #endif
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:gunVC] ;
-
-
-
-
-
- // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-
- navi.modalPresentationStyle = 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
- #ifdef BUILD_CONTRAST
- NSString* title = @"CONTRAST BLOG";
- #endif
-
-
- title = [NSString stringWithFormat:@"%@ BLOG",COMPANY_SHORT_NAME];
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"NPD Website"])
- {
-
- NSString* url = @"https://www.newpacificdirect.com";//@"https://shopla.homelegance.com/general.htm?websiteId=1";//
-
-
- NSString* title = @"NPD";
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- //
- //
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"USAI Website"])
- {
-
- NSString* url = @"http://www.united-us.net/";//@"https://shopla.homelegance.com/general.htm?websiteId=1";//
-
-
- NSString* title = @"USAI";
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- //
- //
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"Homelegance Website"])
- {
-
- NSString* url = @"http://207.140.24.83";//@"https://shopla.homelegance.com/general.htm?websiteId=1";//
-
-
- NSString* title = @"Homelegance";
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- //
- //
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"HOMER Website"])
- {
-
- NSString* url = COMPANY_WEB;
-
- NSString* title = @"HOMER";
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"TITAN Website"])
- {
-
- NSString* url = COMPANY_WEB;
-
- NSString* title = @"TITAN";
-
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"NPD Policy"])
- {
-
- NSString* url = URL_NPD_POLICY;//@"https://shopla.homelegance.com/general.htm?websiteId=1";//
-
-
- NSString* title = @"NPD Policy";
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- //
- //
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"USAI Policy"])
- {
-
- NSString* url = URL_NPD_POLICY;
-
-
- NSString* title = @"USAI Policy";
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"HOMER Policy"])
- {
-
- NSString* url = URL_NPD_POLICY;
-
- NSString* title = @"HOMER Policy";
-
- WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
- ViewController.url = url;
- ViewController.title = title;
-
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- else if([title isEqualToString:@"Simplified Buying Program"])
- {
-
- SimplifiedBuyingProgramViewController *ViewController = [[UIStoryboard storyboardWithName:@"NPD_Mobile" bundle:nil] instantiateViewControllerWithIdentifier:@"SimplifiedBuyingProgramViewController"];
-
-
-
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:ViewController] ;
-
-
-
-
-
- // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
-
- navi.modalPresentationStyle = 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 && [RASingleton sharedInstance].global_lock) {
-
- JKLockController *lockVC = [[JKLockController alloc] init];
- [lockVC setPasswordKey:[NSString stringWithFormat:@"%@_password",appDelegate.user]];
- __weak typeof(self) weakself = self;
- lockVC.authoReturn = ^(BOOL failure) {
-
- if (weakself) {
- __strong typeof(weakself) strongself = weakself;
- [appDelegate set_priceHidden:false];
-
- [strongself initMenuItems];
- [strongself hideMenu];
- }
- };
- [self.navigationController pushViewController:lockVC animated:YES];
-
- } else {
-
- [appDelegate set_priceHidden:false];
-
- [self initMenuItems];
- [self hideMenu];
- }
-
-
-
- }
- else if([title isEqualToString:@"Delete Account"])
- {
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Delete Account" message:@"Are you sure you want to permanently delete your account?" preferredStyle:UIAlertControllerStyleAlert];
- //增加确定按钮
- [alertController addAction:[UIAlertAction actionWithTitle:@"Delete" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){
- //获取第1个输入框;
- UITextField *titleTextField = alertController.textFields.firstObject;
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- if([appDelegate.password isEqualToString:titleTextField.text])
- {
- NSLog(@"%@", @"run process");
- __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Delete Account" completion:^{
- [RANetwork request_delete_account:^(NSMutableDictionary *result) {
- NSMutableDictionary* return_json =result;
-
- [waitalert dismissViewControllerAnimated:YES completion:^{
- if([[return_json valueForKey:@"result"] intValue]==2)
- {
- // [self hideMenu];
- // [self switchToHome:nil];
- [appDelegate Logout];
- [self checklogin :false];
- [RAUtils message_alert:@"Account deleted." title:nil controller:self];
- }
- else
- {
- [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Delete Account" controller:self] ;
- }
- }];
-
-
-
-
-
-
-
-
- }];
- }];
-
-
- }
- else
- {
- [RAUtils message_alert:@"Wrong password." title:nil controller:self];
- }
-
- }]];
- //增加取消按钮;
- [alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:nil]];
- //定义第一个输入框;
- [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
- textField.placeholder = @"Login Password";
- textField.textContentType = UITextContentTypePassword;
- }];
- [self presentViewController:alertController animated:true completion:nil];
- }
-
-
- else if([title isEqualToString:@"Hide Price"])
- {
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore && [RASingleton sharedInstance].global_lock) {
-
- JKLockController *lockVC = [[JKLockController alloc] init];
- [lockVC setPasswordKey:[NSString stringWithFormat:@"%@_password",appDelegate.user]];
- __weak typeof(self) weakself = self;
- lockVC.authoReturn = ^(BOOL failure) {
-
- if (weakself) {
- __strong typeof(weakself) strongself = weakself;
- [appDelegate set_priceHidden:true];
-
- [strongself initMenuItems];
- [strongself hideMenu];
- }
- };
- [self.navigationController pushViewController:lockVC animated:YES];
-
- } else {
-
- [appDelegate set_priceHidden:true];
-
- [self initMenuItems];
- [self hideMenu];
-
- }
-
- }
-
-
-
- else if([title isEqualToString:@"Portfolio"] || [title isEqualToString:@"Hang Tag"])
- {
- [self hideMenu];
- if([self.current_VC isKindOfClass:[PortfolioViewController class]])
- return;
- [self flipFromViewController:self.current_VC toViewController:self.portfolioViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- }
- else if([title isEqualToString:@"View Portfolios"] || [title isEqualToString:@"View Hang Tags"])
- {
- [self hideMenu];
- if([self.current_VC isKindOfClass:[PortfolioListViewController class]])
- return;
- [self flipFromViewController:self.current_VC toViewController:self.pdfListViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- }
- else if([title isEqualToString:@"Contact"])
- {
- // UITableViewCell* cell =(UITableViewCell*) sender.superview.superview;
- //
- // NSIndexPath * indexPath = [self.detailTable indexPathForCell:cell];
- //
- // if(indexPath.section!=1)
- // return ;
- // // DebugLog(@"shouldchangeedit %d_%d",indexPath.section,indexPath.row);
- // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
- //
- // NSString* product_id = [item_json valueForKey:@"product_id"];
- [self hideMenu];
-
- [self switchtocontact];
- }
- else if([title isEqualToString:@"Cam Scan"])
- {
-
-
-
- // UITableViewCell* cell =(UITableViewCell*) sender.superview.superview;
- //
- // NSIndexPath * indexPath = [self.detailTable indexPathForCell:cell];
- //
- // if(indexPath.section!=1)
- // return ;
- // // DebugLog(@"shouldchangeedit %d_%d",indexPath.section,indexPath.row);
- // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
- //
- // NSString* product_id = [item_json valueForKey:@"product_id"];
- [self hideMenu];
- //
- // [self switchtocontact];
-
-
- ScannerViewController * scannerVC =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ScannerViewController"];
-
- [self.navigationController pushViewController:scannerVC animated:true];
- } else if ([title isEqualToString:@"Price Setting"]) {
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- if ([RASingleton sharedInstance].global_lock) {
-
- JKLockController *lockVC = [[JKLockController alloc] init];
- [lockVC setPasswordKey:[NSString stringWithFormat:@"%@_password",appDelegate.user]];
- __weak typeof(self) weakself = self;
- lockVC.authoReturn = ^(BOOL failure) {
-
- if (weakself) {
- __strong typeof(weakself) strongself = weakself;
-
- PriceSettingViewController *priceSettingVC =[ [UIStoryboard storyboardWithName:@"CUL" bundle:nil] instantiateViewControllerWithIdentifier:@"PriceSettingViewController"];
-
- UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:priceSettingVC] ;
-
- navi.navigationBar.translucent = NO;
- navi.modalPresentationStyle = 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;
-
- [RASingleton sharedInstance].global_lock = ![RASingleton sharedInstance].global_lock;
- [strongself initMenuItems];
- [strongself hideMenu];
- }
- };
- [self.navigationController pushViewController:lockVC animated:YES];
-
- }
- }
- //#pragma mark - UIAlertViewDelegate
- //// Called when a button is clicked. The view will be automatically dismissed after this call returns
- //- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- //{
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- //
- //
- //
- // // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- // if(buttonIndex==alertView.cancelButtonIndex)
- // {
- //
- //
- //
- // }
- // else if(buttonIndex==1)
- // {
- // //open exist
- //
- // OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
- // ovc.showNavibar = true;
- // ovc.selectOrder = ^(NSMutableDictionary* order_detail){
- // if(appDelegate.order_code==nil)
- // {
- // [self neworderforCart];
- // }
- // else
- // {
- // self.previous_VC = self.current_VC;
- // [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
- //
- // [self checklogin:true];
- //
- // }
- //
- // };
- // ovc.init_style = OL_OPEN;
- // ovc.onCancel = ^(){
- //
- // [self checklogin:true];
- //
- // };
- // ovc.title = @"SAVED ORDER";
- // [self.navigationController pushViewController:ovc animated:true];
- // }
- // else
- // {
- // //create new;
- //
- // if(appDelegate.customerInfo==nil)// select contact if current contact not exist
- // {
- //
- // ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- // cvc.showNavibar = true;
- // cvc.contact_type = @"Sales_Order_Customer";
- // cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
- //
- // appDelegate.contact_id=[value valueForKey:@"customer_cid"];
- // appDelegate.customerInfo = value;
- //
- //
- // if(appDelegate.order_code==nil)
- // [self neworderforCart];
- //
- //
- // };
- //
- // cvc.onCancel = ^(){
- //
- // [RAUtils message_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
- {
-
- __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Create Order" completion:^{
- [RANetwork request_create_order:^(NSMutableDictionary *result) {
- NSMutableDictionary* return_json = result;
-
- [waitalert dismissViewControllerAnimated:YES completion:^{
- 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] ;
- }
- }];
-
-
-
-
-
-
-
-
- }];
- }];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* return_json = [RANetwork new_Order];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [waitalert dismissViewControllerAnimated:YES completion:nil];
- //
- //
- // 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
|