MainViewController.m 137 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600
  1. //
  2. // ViewController.m
  3. // RedAnt ERP Suite
  4. //
  5. // Created by Ray on 14-5-19.
  6. // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "MainViewController.h"
  9. //#import "SideMenuViewController.h"
  10. //#import "RootContainerViewController.h"
  11. #import <Accelerate/Accelerate.h>
  12. #import "PopupNavigationController.h"
  13. //#import "CommonGridViewController.h"
  14. #import "CacheViewController.h"
  15. #import "ScannerViewController.h"
  16. #import "ContactListViewController.h"
  17. #import "RAUtils.h"
  18. #import "AboutViewController.h"
  19. #import "ScannerSettingViewController.h"
  20. #import "ActiveViewController.h"
  21. #import "WebViewController.h"
  22. #import "FunctionTestViewController.h"
  23. #import "SimplifiedBuyingProgramViewController.h"
  24. #import "UserListViewController.h"
  25. #import "OfflineSettingViewController.h"
  26. #import "DefaultAppearance.h"
  27. #import "PriceSettingViewController.h"
  28. #import "JKLockController.h"
  29. #import "RASingleton.h"
  30. #import "NotificationNameCenter.h"
  31. #import "OLOSettingViewController.h"
  32. #import "CustomerEditViewController.h"
  33. @interface MainViewController ()
  34. @end
  35. @implementation MainViewController
  36. -(void) logoutDocuments
  37. {
  38. [self.pdfListViewController logout];
  39. }
  40. -(void) logoutCart
  41. {
  42. [self.cartViewController logout];
  43. }
  44. -(void) logoutWish
  45. {
  46. [self.watchListViewController logout];
  47. }
  48. -(void) logoutPortfolio
  49. {
  50. [self.portfolioViewController logout];
  51. }
  52. -(void) logoutOrder
  53. {
  54. [self.orderViewController logout];
  55. }
  56. -(void) logoutContact
  57. {
  58. [self.contactListViewController logout];
  59. }
  60. -(void) logoutCategory
  61. {
  62. [self.categoryViewController logout];
  63. }
  64. #ifndef RA_NOTIFICATION
  65. -(void) reloadCategory:(BOOL) update_data immediately:(bool)immediately
  66. {
  67. if(immediately)
  68. [ self.categoryViewController reload_container_getdata:update_data];
  69. else
  70. {
  71. if(update_data&&self.categoryViewController.refresh_type<=REFRESH_DATA)
  72. self.categoryViewController.refresh_type = REFRESH_DATA;
  73. else if(self.categoryViewController.refresh_type<=REFRESH_VIEW)
  74. self.categoryViewController.refresh_type = REFRESH_VIEW;
  75. }
  76. }
  77. -(void) reloadDocuments:(BOOL) update_data immediately:(bool)immediately
  78. {
  79. if(immediately)
  80. [ self.pdfListViewController reload_container_getdata:update_data];
  81. else
  82. {
  83. if(update_data&&self.pdfListViewController.refresh_type<=REFRESH_DATA)
  84. self.pdfListViewController.refresh_type = REFRESH_DATA;
  85. else if(self.pdfListViewController.refresh_type<=REFRESH_VIEW)
  86. self.pdfListViewController.refresh_type = REFRESH_VIEW;
  87. }
  88. //[self.pdfListViewController reload_container_getdata:update_data];
  89. }
  90. -(void) reloadCart:(BOOL) update_data immediately:(bool)immediately
  91. {
  92. if(immediately)
  93. [ self.cartViewController reload_container_getdata:update_data];
  94. else
  95. {
  96. if(update_data&&self.cartViewController.refresh_type<=REFRESH_DATA)
  97. self.cartViewController.refresh_type = REFRESH_DATA;
  98. else if(self.cartViewController.refresh_type<=REFRESH_VIEW)
  99. self.cartViewController.refresh_type = REFRESH_VIEW;
  100. }
  101. // [self.cartViewController reload_container_getdata:update_data];
  102. }
  103. -(void) reloadWish:(BOOL) update_data immediately:(bool)immediately
  104. {
  105. if(immediately)
  106. [ self.watchListViewController reload_container_getdata:update_data];
  107. else
  108. {
  109. if(update_data&&self.watchListViewController.refresh_type<=REFRESH_DATA)
  110. self.watchListViewController.refresh_type = REFRESH_DATA;
  111. else if(self.watchListViewController.refresh_type<=REFRESH_VIEW)
  112. self.watchListViewController.refresh_type = REFRESH_VIEW;
  113. }
  114. // [self.watchListViewController reload_container_getdata:update_data];
  115. }
  116. -(void) reloadPortfolio:(BOOL) update_data immediately:(bool)immediately
  117. {
  118. // NSMutableDictionary* dict = [NSMutableDictionary new];
  119. // dict[@"receiver"]=@[@"PortfolioViewController"];
  120. // NSString* notificationname = nil;
  121. // if(update_data)
  122. // notificationname = RA_NOTIFICATION_RELOAD_DATA;
  123. // else
  124. // notificationname = RA_NOTIFICATION_REFRESH_UI;
  125. // NSNotification *notification =[NSNotification notificationWithName:notificationname object:nil userInfo:dict];
  126. //
  127. // //通过通知中心发送通知
  128. //
  129. // [[NSNotificationCenter defaultCenter] postNotification:notification];
  130. // return;
  131. if(immediately)
  132. [ self.portfolioViewController reload_container_getdata:update_data];
  133. else
  134. {
  135. if(update_data&&self.portfolioViewController.refresh_type<=REFRESH_DATA)
  136. self.portfolioViewController.refresh_type = REFRESH_DATA;
  137. else if(self.portfolioViewController.refresh_type<=REFRESH_VIEW)
  138. self.portfolioViewController.refresh_type = REFRESH_VIEW;
  139. }
  140. // [self.portfolioViewController reload_container_getdata:update_data];
  141. }
  142. -(void) reloadOrder:(BOOL) update_data immediately:(bool)immediately
  143. {
  144. if(immediately)
  145. [ self.orderViewController reload_container_getdata:update_data];
  146. else
  147. {
  148. if(update_data&&self.orderViewController.refresh_type<=REFRESH_DATA)
  149. self.orderViewController.refresh_type = REFRESH_DATA;
  150. else if(self.orderViewController.refresh_type<=REFRESH_VIEW)
  151. self.orderViewController.refresh_type = REFRESH_VIEW;
  152. }
  153. // [self.orderViewController reload_container_getdata:update_data];
  154. }
  155. -(void) reloadContact:(BOOL) update_data immediately:(bool)immediately
  156. {
  157. //[self.con reload_container];
  158. if(immediately)
  159. [ self.contactListViewController reload_container_getdata:update_data];
  160. else
  161. {
  162. if(update_data&&self.contactListViewController.refresh_type<=REFRESH_DATA)
  163. self.contactListViewController.refresh_type = REFRESH_DATA;
  164. else if(self.contactListViewController.refresh_type<=REFRESH_VIEW)
  165. self.contactListViewController.refresh_type = REFRESH_VIEW;
  166. }
  167. }
  168. #endif
  169. -(void)viewWillLayoutSubviews
  170. {
  171. self.headerView.layer.shadowPath =[UIBezierPath bezierPathWithRect:self.headerView.bounds].CGPath;
  172. }
  173. -(void) viewWillAppear:(BOOL)animated
  174. {
  175. [super viewWillAppear:animated];
  176. // [self.label_ccount.layer setMasksToBounds:YES];
  177. [self refreshContactDisplay];
  178. [[self navigationController] setNavigationBarHidden:YES animated:NO];
  179. }
  180. -(void) refreshContactDisplay
  181. {
  182. UIApplication * app = [UIApplication sharedApplication];
  183. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  184. // self.labelContact.text=appDelegate.contact_name;
  185. NSString * contact =[appDelegate.customerInfo valueForKey:@"customer_contact"];
  186. NSString * customer=[appDelegate.customerInfo valueForKey:@"customer_name"];
  187. NSDictionary * customerinfo=appDelegate.customerInfo;
  188. if(customerinfo==nil)
  189. {
  190. contact=@"Select Contact";
  191. [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
  192. }
  193. // if(contact==nil||contact.length==0)
  194. // {
  195. // contact=@"No Name";
  196. // [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
  197. // }
  198. else
  199. {
  200. if(contact==nil||contact.length==0)
  201. {
  202. contact=@"No Name";
  203. [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
  204. }
  205. else
  206. {
  207. [self.btnContact setTitleColor:UIColorFromRGB(0x009900) forState:UIControlStateNormal];
  208. }
  209. }
  210. NSMutableArray* arr_contact = [[NSMutableArray alloc] init];
  211. if(contact.length>0)
  212. [arr_contact addObject:contact];
  213. if(customer.length>0)
  214. [arr_contact addObject:customer];
  215. NSString *contact_string = [arr_contact componentsJoinedByString:@" @"];
  216. [self.btnContact setTitle:contact_string forState:UIControlStateNormal];
  217. }
  218. - (void) checklogin:(bool) reloadCurrentVC
  219. {
  220. [self initMenuItems];
  221. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  222. self.sideMenu_UserName.text =appDelegate.user;
  223. [self.btn_sideMenu_UserName setTitle:appDelegate.user forState:UIControlStateNormal];
  224. if(appDelegate.bLogin)
  225. [self.btnLogin setTitle:@"Sign out" forState:UIControlStateNormal];
  226. else
  227. [self.btnLogin setTitle:@"Sign in" forState:UIControlStateNormal];
  228. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  229. [RANetwork LoadImage:appDelegate.user_icon into:self.user_head ];
  230. });
  231. if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/true)
  232. self.btnContact.hidden = NO;
  233. // else
  234. // self.btnContact.hidden = YES;
  235. NSDictionary * customerinfo=appDelegate.customerInfo;
  236. NSString * contact=nil;
  237. NSString * customer=nil;
  238. if(customerinfo==nil)
  239. {
  240. contact=@"Select Contact";
  241. [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
  242. }
  243. else
  244. {
  245. contact=[customerinfo valueForKey:@"customer_contact"];
  246. customer=[customerinfo valueForKey:@"customer_name"];
  247. if(contact==nil||contact.length==0)
  248. {
  249. contact=@"No Name";
  250. [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
  251. }
  252. else
  253. {
  254. [self.btnContact setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
  255. }
  256. }
  257. self.btnContact.hidden = !appDelegate.bLogin;// 修复登出后仍旧显示select contact
  258. NSMutableArray* arr_contact = [[NSMutableArray alloc] init];
  259. if(contact.length>0)
  260. [arr_contact addObject:contact];
  261. if(customer.length>0)
  262. [arr_contact addObject:customer];
  263. NSString *contact_string = [arr_contact componentsJoinedByString:@" @"];
  264. [self.btnContact setTitle:contact_string forState:UIControlStateNormal];
  265. // if(appDelegate.bLogin)
  266. // [self.buttonUser setTitle:appDelegate.user forState:UIControlStateNormal];
  267. // else
  268. // [self.buttonUser setTitle:@"Sign in" forState:UIControlStateNormal];
  269. #ifdef RA_NOTIFICATION
  270. [ActiveViewController Notify:@"DetailViewController,PDFListViewController,CartViewController,PortfolioViewController,WatchListViewController,OrderListViewController,OrderListViewController,ContactListViewController,CategoryViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  271. #else
  272. [self reloadDocuments:true immediately:false];
  273. [self reloadCart:true immediately:false];
  274. [self reloadPortfolio:true immediately:false];
  275. [self reloadWish:true immediately:false];
  276. [self reloadOrder:true immediately:false];
  277. [self reloadContact:true immediately:false];
  278. [self reloadCategory:true immediately:false];
  279. ActiveViewController* lrvc = (ActiveViewController*)appDelegate.active_controller;
  280. if(reloadCurrentVC)
  281. {
  282. if(lrvc!=nil)
  283. [ lrvc refresh_on_login];
  284. }
  285. else
  286. {
  287. if(lrvc.refresh_type<=REFRESH_DATA)
  288. lrvc.refresh_type = REFRESH_DATA;
  289. else if(lrvc.refresh_type<=REFRESH_VIEW)
  290. lrvc.refresh_type = REFRESH_VIEW;
  291. }
  292. #endif
  293. // [self reload];
  294. }
  295. - (IBAction)onContactClick:(id)sender {
  296. UIApplication * app = [UIApplication sharedApplication];
  297. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  298. NSString* contactid=appDelegate.contact_id ;
  299. if(contactid==nil)
  300. {
  301. ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  302. cvc.update_order = true;
  303. cvc.edit_icon = true;
  304. cvc.assig_icon = true;
  305. cvc.reset_icon = false;
  306. cvc.showNavibar = true;
  307. cvc.contact_type = @"Sales_Order_Customer";
  308. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  309. [self.navigationController popViewControllerAnimated:false];
  310. appDelegate.contact_id=[value valueForKey:@"customer_cid"];
  311. appDelegate.customerInfo = value;
  312. // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  313. //
  314. // if(self.returnValue)
  315. // self.returnValue(value);
  316. };
  317. [self.navigationController pushViewController:cvc animated:true];
  318. }
  319. else
  320. {
  321. CustomerInfoViewController * vc = [[CustomerInfoViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
  322. vc.url_type = URL_LOCAL;
  323. // if(appDelegate.order_code.length>0)
  324. {
  325. vc.edit_icon = false;
  326. vc.assig_icon = true;
  327. vc.reset_icon = true;
  328. vc.request_url=LOCAL_URL_CUSTOMER_INFO_EDIT;
  329. }
  330. // else
  331. // {
  332. // vc.edit_icon = false;
  333. // vc.assig_icon = false;
  334. // vc.reset_icon = true;
  335. // vc.request_url=LOCAL_URL_CUSTOMER_INFO_EDITOR;
  336. // }
  337. // NSDictionary* dd=appDelegate.customerInfo;;
  338. vc.data_init = appDelegate.customerInfo;
  339. vc.update_order = true;
  340. vc.contactId=contactid;
  341. // vc.delegate = self;
  342. vc.returnValue = ^(NSMutableDictionary* value){
  343. appDelegate.contact_id=[value valueForKey:@"customer_cid"];
  344. appDelegate.customerInfo = value;
  345. };
  346. [self.navigationController pushViewController:vc animated:true];
  347. }
  348. }
  349. - (void)viewDidLoad
  350. {
  351. [super viewDidLoad];
  352. // NSLog(@"decrypt:%@",[AESCrypt fastdecrypt:@"vafHUwfRPIUbPNVnKhLc5aAVK7sOFRztlfJVRHW7QVa/qGgm11E5UwfYWZEBTQpH"]);
  353. self.automaticallyAdjustsScrollViewInsets = NO;
  354. NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultColor" valuename:@"labelcolor"];
  355. if(value==nil)
  356. value=@"";
  357. unsigned long frontcolor = strtoul([value UTF8String],0,16);
  358. [self.labelSo setTextColor:UIColorFromRGB(frontcolor)];
  359. float vx =[[DefaultAppearance get_noneappearance_value:@"MainLogo" valuename:@"x"] floatValue];
  360. float vy =[[DefaultAppearance get_noneappearance_value:@"MainLogo" valuename:@"y"] floatValue];
  361. float vwidth =[[DefaultAppearance get_noneappearance_value:@"MainLogo" valuename:@"width"] floatValue];
  362. float vheight =[[DefaultAppearance get_noneappearance_value:@"MainLogo" valuename:@"height"] floatValue];
  363. self.btn_LogoHome.frame = CGRectMake(vx, vy, vwidth, vheight);
  364. float mvx =[[DefaultAppearance get_noneappearance_value:@"ModePos" valuename:@"x"] floatValue];
  365. float mvy =[[DefaultAppearance get_noneappearance_value:@"ModePos" valuename:@"y"] floatValue];
  366. float mvwidth =[[DefaultAppearance get_noneappearance_value:@"ModePos" valuename:@"width"] floatValue];
  367. float mvheight =[[DefaultAppearance get_noneappearance_value:@"ModePos" valuename:@"height"] floatValue];
  368. self.labelMode.frame = CGRectMake(mvx, mvy, mvwidth, mvheight);
  369. self.label_ccount.layer.cornerRadius=10.5;
  370. self.label_ccount.layer.masksToBounds=true;
  371. self.label_wcount.layer.cornerRadius=10.5;
  372. self.label_wcount.layer.masksToBounds=true;
  373. self.label_cccount.layer.cornerRadius=10.5;
  374. self.label_cccount.layer.masksToBounds=true;
  375. self.label_cwcount.layer.cornerRadius=10.5;
  376. self.label_cwcount.layer.masksToBounds=true;
  377. self.employee_bp.hidden = false;
  378. self.customer_bp.hidden = true;
  379. UIApplication * app = [UIApplication sharedApplication];
  380. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  381. appDelegate.main_vc = self;
  382. [appDelegate update_count_mark];
  383. NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
  384. NSString* build =[infoDict objectForKey:@"CFBundleVersion"];
  385. NSString* version =[infoDict objectForKey:@"CFBundleShortVersionString"];
  386. //#ifdef BUILD_HMLG
  387. // NSString* versionNum = [NSString stringWithFormat:@"HMLG %@ Build %@",version,build];
  388. //#endif
  389. //#if defined(BUILD_NPD) || defined(BUILD_USAI)
  390. // NSString* versionNum = [NSString stringWithFormat:@"npd %@ Build %@",version,build];
  391. //#endif
  392. //#ifdef BUILD_HOMER
  393. NSString* versionNum = [NSString stringWithFormat:@"%@ %@ Build %@",COMPANY_SHORT_NAME,version,build];
  394. //#endif
  395. [self initMenuItems];
  396. self.homeViewController =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"HomeViewController"];
  397. self.categoryViewController =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Search" bundle:nil] instantiateViewControllerWithIdentifier:@"CategoryViewController"];
  398. self.cartViewController =[[UIStoryboard storyboardWithName:@"ERP_Mobile_Cart" bundle:nil] instantiateViewControllerWithIdentifier:@"CartViewController"];
  399. __block MainViewController *brself= self;
  400. #ifdef SCANNER_ORDER
  401. self.scanorderViewController =[[UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"ScanOrderListViewController"];
  402. #else
  403. self.orderViewController =[[UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
  404. self.orderViewController.selectOrder=^(NSMutableDictionary* order_detail){
  405. //main view 下打开order
  406. //Capturing strongly warring;
  407. __block MainViewController *brbrself= brself;
  408. brself.cartViewController.onFinishLoad=^()
  409. {
  410. [brbrself.cartViewController placeOrder];
  411. brbrself.cartViewController.onFinishLoad=nil;
  412. };
  413. [brself refreshContactDisplay];
  414. [brself switchToCart:nil];
  415. };
  416. #endif
  417. self.contactListViewController = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  418. self.contactListViewController.contact_type = @"Sales_Order_Customer";
  419. self.contactListViewController.edit_icon = true;
  420. self.contactListViewController.assig_icon = true;
  421. self.contactListViewController.reset_icon = false;
  422. self.contactListViewController.ui_type = CONTACT_LIST;
  423. self.contactListViewController.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  424. appDelegate.contact_id=[value valueForKey:@"customer_cid"];
  425. appDelegate.customerInfo = value;
  426. [brself refreshContactDisplay];
  427. [brself switchToCart:nil];
  428. // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  429. //
  430. // if(self.returnValue)
  431. // self.returnValue(value);
  432. };
  433. //Capturing strongly warring;
  434. self.watchListViewController =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"WatchListViewController"];
  435. self.portfolioViewController = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Portfolio" bundle:nil] instantiateViewControllerWithIdentifier:@"PortfolioViewController" ];
  436. self.pdfListViewController = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Portfolio" bundle:nil] instantiateViewControllerWithIdentifier:@"PortfolioListViewController" ];
  437. self.itemSearchViewController=[[UIStoryboard storyboardWithName:@"ERP_Mobile_Search" bundle:nil] instantiateViewControllerWithIdentifier:@"ItemSearchViewController"];
  438. self.searchViewController=[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Search" bundle:nil] instantiateViewControllerWithIdentifier:@"SearchViewController"];
  439. [self addChildViewController:self.homeViewController]; //1
  440. self.homeViewController.view.frame = self.container.bounds;
  441. [self.container addSubview:self.homeViewController.view]; //2
  442. [self.homeViewController didMoveToParentViewController:self];
  443. self.current_VC = self.homeViewController;
  444. // self.is_home = true;
  445. // [UIBezierPath bezierPathWithRect:self.headerView.bounds].CGPath;
  446. self.headerView.layer.shadowPath =[UIBezierPath bezierPathWithRect:self.headerView.bounds].CGPath;
  447. self.headerView.layer.masksToBounds = false;
  448. //添加四个边阴影
  449. self.headerView.layer.shadowColor = [UIColor blackColor].CGColor;
  450. self.headerView.layer.shadowOffset = CGSizeMake(0, 0);
  451. self.headerView.layer.shadowOpacity = 0.5;
  452. self.headerView.layer.shadowRadius = 2.0;
  453. self.labelVer.text=versionNum;
  454. // UIApplication * app = [UIApplication sharedApplication];
  455. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  456. if(appDelegate.categoryMenu==nil)
  457. {
  458. [RANetwork request_category:^(NSMutableDictionary *result) {
  459. NSDictionary* category=result;
  460. if([[category valueForKey:@"result"] intValue]==2)
  461. {
  462. appDelegate.categoryMenu = category;
  463. }
  464. }];
  465. return;
  466. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  467. //
  468. //
  469. // NSDictionary* category=[RANetwork request_Cagegory];
  470. //
  471. // dispatch_async(dispatch_get_main_queue(), ^{
  472. //
  473. // if([[category valueForKey:@"result"] intValue]==2)
  474. // {
  475. // appDelegate.categoryMenu = category;
  476. // }
  477. // else
  478. // {
  479. // // [RAUtils error_alert:[category valueForKey:@"err_msg"] title:@"Failed to load category."] ;
  480. // }
  481. //
  482. //
  483. //
  484. // // self.categoryViewController.categoryMenu = category;
  485. //
  486. //
  487. //
  488. // });
  489. // });
  490. }
  491. // Do any additional setup after loading the view, typically from a nib.
  492. }
  493. - (IBAction)onmenuButtonClicked:(id)sender {
  494. self.openMenuButton.hidden = true;
  495. self.sideMenu.hidden = false;
  496. [self showMenu];
  497. }
  498. - (IBAction)switchMenu:(UIButton *)sender {
  499. // if(self.menuShown==true)
  500. [self hideMenu];
  501. self.openMenuButton.hidden = false;
  502. self.sideMenu.hidden = true;
  503. // else
  504. // [self showMenu];
  505. }
  506. -(void) Loginout:(bool)showlogin
  507. {
  508. UIApplication * app = [UIApplication sharedApplication];
  509. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  510. if(appDelegate.bLogin)
  511. {
  512. __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Sign out" completion:^{
  513. [RANetwork request_logout:^(NSMutableDictionary *result) {
  514. NSMutableDictionary* return_json =result;
  515. [waitalert dismissViewControllerAnimated:YES completion:^{
  516. if([[return_json valueForKey:@"result"] intValue]==2)
  517. {
  518. // [self hideMenu];
  519. // [self switchToHome:nil];
  520. [appDelegate Logout];
  521. [self checklogin :false];
  522. if(showlogin)
  523. {
  524. LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
  525. loginvc.returnValue = ^(bool blogin){
  526. [self checklogin :true];
  527. };
  528. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  529. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  530. [self presentViewController:navi animated:YES completion:^{
  531. DebugLog(@"login present.........");
  532. }];
  533. }
  534. }
  535. else
  536. {
  537. [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Sign Out" controller:self] ;
  538. }
  539. }];
  540. }];
  541. }];
  542. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  543. //
  544. // NSDictionary* return_json = [RANetwork logout];
  545. //
  546. // dispatch_async(dispatch_get_main_queue(), ^{
  547. // [waitalert dismissViewControllerAnimated:YES completion:nil];
  548. //
  549. //
  550. // if([[return_json valueForKey:@"result"] intValue]==2)
  551. // {
  552. //// [self hideMenu];
  553. //// [self switchToHome:nil];
  554. // [appDelegate Logout];
  555. // [self checklogin :false];
  556. // if(showlogin)
  557. // {
  558. // LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
  559. // loginvc.returnValue = ^(bool blogin){
  560. //
  561. // [self checklogin :true];
  562. //
  563. // };
  564. //
  565. // UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  566. //
  567. //
  568. //
  569. //
  570. //
  571. //
  572. // navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  573. // [self presentViewController:navi animated:YES completion:^{
  574. //
  575. // DebugLog(@"login present.........");
  576. //
  577. // }];
  578. // }
  579. // }
  580. // else
  581. // {
  582. // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Sign Out" controller:self] ;
  583. // }
  584. //
  585. //
  586. //
  587. //
  588. // });
  589. // });
  590. }
  591. else
  592. {
  593. LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
  594. loginvc.returnValue = ^(bool blogin){
  595. [self checklogin :true];
  596. };
  597. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  598. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  599. [self presentViewController:navi animated:YES completion:^{
  600. DebugLog(@"login present.........");
  601. }];
  602. }
  603. }
  604. - (IBAction)onUserListClick:(id)sender {
  605. UIApplication * app = [UIApplication sharedApplication];
  606. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  607. if(!appDelegate.bLogin)
  608. return;
  609. UserListViewController * vc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"UserListViewController"];
  610. vc.returnValue = ^(bool blogin){
  611. if(blogin==false)
  612. {
  613. LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
  614. loginvc.returnValue = ^(bool blogin){
  615. [self checklogin :true];
  616. };
  617. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  618. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  619. [self presentViewController:navi animated:YES completion:^{
  620. DebugLog(@"login present.........");
  621. }];
  622. }
  623. };
  624. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:vc] ;
  625. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  626. [self presentViewController:navi animated:YES completion:^{
  627. DebugLog(@"login present.........");
  628. }];
  629. }
  630. - (IBAction)OnLoginClick:(UIButton *)sender {
  631. [self Loginout:true];
  632. }
  633. - (IBAction)onScanClick:(id)sender {
  634. ScannerViewController * scannerVC =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ScannerViewController"];
  635. [self.navigationController pushViewController:scannerVC animated:true];
  636. }
  637. - (IBAction)switchToSearch:(UIButton *)sender {
  638. if([self.current_VC isKindOfClass:[SearchViewController class]])
  639. return;
  640. [self flipFromViewController:self.current_VC toViewController:self.searchViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  641. }
  642. - (IBAction)switchToWishlist:(UIButton *)sender {
  643. [self switchtowishlist];
  644. }
  645. -(void)switchtowishlist
  646. {
  647. if([self.current_VC isKindOfClass:[WatchListViewController class]])
  648. return;
  649. // if([self.current_VC isKindOfClass:[OrderListViewController class]])
  650. // return;
  651. UIApplication * app = [UIApplication sharedApplication];
  652. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  653. if(appDelegate.bLogin==false)
  654. {
  655. LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
  656. // loginvc.delegate = self;
  657. // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  658. loginvc.returnValue = ^(bool blogin){
  659. if(blogin)
  660. {
  661. [self checklogin:true];
  662. [self flipFromViewController:self.current_VC toViewController:self.watchListViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  663. }
  664. };
  665. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  666. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  667. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  668. [self presentViewController:navi animated:YES completion:^{
  669. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  670. DebugLog(@"LoginViewController present.........");
  671. // self.btop = false;
  672. // <#code#>
  673. }];
  674. }
  675. else
  676. [self flipFromViewController:self.current_VC toViewController:self.watchListViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  677. }
  678. - (IBAction)switchToContact:(UIButton *)sender {
  679. [self switchtocontact];
  680. }
  681. -(void)switchtocontact
  682. {
  683. if([self.current_VC isKindOfClass:[ContactListViewController class]])
  684. return;
  685. UIApplication * app = [UIApplication sharedApplication];
  686. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  687. if(appDelegate.bLogin==false)
  688. {
  689. LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
  690. // loginvc.delegate = self;
  691. // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  692. loginvc.returnValue = ^(bool blogin){
  693. if(blogin)
  694. {
  695. [self checklogin:true];
  696. if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
  697. {
  698. [self flipFromViewController:self.current_VC toViewController:self.contactListViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  699. }
  700. else
  701. {
  702. [RAUtils message_alert:@"Customer Login does not support this feature." title:@"Contact List" controller:self] ;
  703. }
  704. }
  705. };
  706. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  707. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  708. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  709. [self presentViewController:navi animated:YES completion:^{
  710. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  711. DebugLog(@"LoginViewController present.........");
  712. // self.btop = false;
  713. // <#code#>
  714. }];
  715. }
  716. else
  717. [self flipFromViewController:self.current_VC toViewController:self.contactListViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  718. }
  719. - (void) reload
  720. {
  721. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  722. [RANetwork request_category:^(NSMutableDictionary *result) {
  723. NSDictionary* category=result;
  724. if([[category valueForKey:@"result"] intValue]==2)
  725. {
  726. appDelegate.categoryMenu = category;
  727. }
  728. }];
  729. return;
  730. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  731. //
  732. //
  733. // NSDictionary* category=[RANetwork request_Cagegory];
  734. //
  735. // dispatch_async(dispatch_get_main_queue(), ^{
  736. //
  737. // if([[category valueForKey:@"result"] intValue]==2)
  738. // {
  739. // appDelegate.categoryMenu = category;
  740. // }
  741. // else
  742. // {
  743. // // [RAUtils error_alert:[category valueForKey:@"err_msg"]] ;
  744. // }
  745. //
  746. // });
  747. // });
  748. }
  749. - (IBAction)onUserButtonClick:(id)sender {
  750. DebugLog(@"header view login");
  751. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  752. if( appDelegate.user ==nil)
  753. {
  754. LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
  755. // loginvc.delegate = self;
  756. // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  757. loginvc.returnValue = ^(bool blogin){
  758. [self checklogin:true];
  759. };
  760. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  761. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  762. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  763. [self presentViewController:navi animated:YES completion:^{
  764. // <#code#>
  765. }];
  766. }
  767. }
  768. #pragma mark - LoginViewControllerDelegate
  769. -(void)LoginViewControllerDidLogin:(LoginViewController *)viewController
  770. {
  771. [viewController dismissViewControllerAnimated:YES completion:^{
  772. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  773. self.sideMenu_UserName.text =appDelegate.user;
  774. [self.btn_sideMenu_UserName setTitle:appDelegate.user forState:UIControlStateNormal];
  775. [self.btnLogin setTitle:@"Sign out" forState:UIControlStateNormal];
  776. [RANetwork LoadImage:appDelegate.user_icon into:self.user_head ];
  777. if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/true)
  778. self.btnContact.hidden = NO;
  779. // else
  780. // self.btnContact.hidden = YES;
  781. NSDictionary * customerinfo=appDelegate.customerInfo;
  782. NSString * contact=nil;
  783. NSString * customer=nil;
  784. if(customerinfo==nil)
  785. {
  786. contact=@"Select Contact";
  787. [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
  788. }
  789. else
  790. {
  791. contact=[customerinfo valueForKey:@"customer_contact"];
  792. customer=[customerinfo valueForKey:@"customer_name"];
  793. if(contact==nil||contact.length==0)
  794. {
  795. contact=@"No Name";
  796. [self.btnContact setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
  797. }
  798. else
  799. {
  800. [self.btnContact setTitleColor:UIColorFromRGB(0x009900) forState:UIControlStateNormal];
  801. }
  802. }
  803. NSMutableArray* arr_contact = [[NSMutableArray alloc] init];
  804. if(contact.length>0)
  805. [arr_contact addObject:contact];
  806. if(customer.length>0)
  807. [arr_contact addObject:customer];
  808. NSString *contact_string = [arr_contact componentsJoinedByString:@" @"];
  809. [self.btnContact setTitle:contact_string forState:UIControlStateNormal];
  810. // [self.buttonUser setTitle:appDelegate.user forState:UIControlStateNormal];
  811. [self reload];
  812. }];
  813. }
  814. - (void) flipFromViewController:(UIViewController*) fromController
  815. toViewController:(UIViewController*) toController
  816. withDirection:(UIViewAnimationOptions) direction
  817. {
  818. toController.view.frame = self.container.bounds; // 1
  819. // UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
  820. // UIViewAutoresizingFlexibleWidth = 1 << 1,
  821. // UIViewAutoresizingFlexibleRightMargin = 1 << 2,
  822. // UIViewAutoresizingFlexibleTopMargin = 1 << 3,
  823. // UIViewAutoresizingFlexibleHeight = 1 << 4,
  824. // UIViewAutoresizingFlexibleBottomMargin = 1 << 5
  825. toController.view.autoresizingMask = UIViewAutoresizingFlexibleHeight |UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleBottomMargin;
  826. NSLog(@"MAIN VIEWCONTROLLER CHILD COUNT %lu",(unsigned long)self.childViewControllers.count);
  827. [self addChildViewController:toController]; //
  828. [fromController willMoveToParentViewController:nil]; //
  829. [self transitionFromViewController:fromController
  830. toViewController:toController
  831. duration:0.0
  832. options:direction | UIViewAnimationOptionCurveEaseIn
  833. animations:nil
  834. completion:^(BOOL finished) {
  835. [toController didMoveToParentViewController:self]; // 2
  836. [fromController removeFromParentViewController]; // 3
  837. self.current_VC = toController;
  838. if([fromController isKindOfClass:[HomeViewController class]])
  839. {
  840. // [[NSNotificationCenter defaultCenter] postNotificationName:CYCLESCROLL_STOPTIMMER object:nil];
  841. // self.homeViewController = nil;
  842. }
  843. }];
  844. }
  845. -(void)topicViewSelected:(int) type _id: (int) _id
  846. {
  847. [self switchToCagegory:nil];
  848. if(type==0)
  849. {
  850. // [self.categoryViewController showDetailat:_id];
  851. }
  852. else
  853. {
  854. [self.categoryViewController showCategory];
  855. }
  856. }
  857. -(void)categoryMenuSelected:(NSString*)_id
  858. {
  859. [self switchToCagegory:_id];
  860. // [self.categoryViewController showCategory];
  861. }
  862. - (void)switchToItemSearch:(NSString* )coverttype {
  863. self.itemSearchViewController.default_filter = nil;
  864. self.itemSearchViewController.covertype = coverttype;
  865. self.itemSearchViewController.saved_covertype = coverttype;
  866. self.itemSearchViewController.p_available = nil;
  867. self.itemSearchViewController.p_price = nil;
  868. self.itemSearchViewController.p_QTY = nil;
  869. self.itemSearchViewController.p_bestseller = nil;
  870. #ifdef RA_NOTIFICATION
  871. [ActiveViewController Notify:@"ItemSearchViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  872. #else
  873. [self.itemSearchViewController reload_container_getdata:true];
  874. #endif
  875. if([self.current_VC isKindOfClass:[ItemSearchViewController class]])
  876. return;
  877. [self flipFromViewController:self.current_VC toViewController:self.itemSearchViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  878. [[self navigationController] setNavigationBarHidden:YES animated:NO];
  879. // self.is_home = false;
  880. // self.current_vc = VC_CATEGORY;
  881. // [self.homeViewController willMoveToParentViewController:nil]; //1
  882. // [self.homeViewController.view removeFromSuperview]; //2
  883. // [self.homeViewController removeFromParentViewController]; //3
  884. //
  885. // [self.container addSubview:self.cagegoryViewController.view]; //2
  886. // [self.cagegoryViewController didMoveToParentViewController:self];
  887. }
  888. - (void)switchToCagegory:(NSString* )categoryid {
  889. // NSString* ttt =[@"Category" stringByAppendingString:[self categoryString:categoryid node:self.categoryMenu level:0]];
  890. UIApplication * app = [UIApplication sharedApplication];
  891. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  892. #if defined(BUILD_UWAVER)
  893. self.categoryViewController.categoryString = [@"Collections" stringByAppendingString:[self categoryString:categoryid node:appDelegate.categoryMenu level:0]];
  894. #else
  895. self.categoryViewController.categoryString = [@"Category" stringByAppendingString:[self categoryString:categoryid node:appDelegate.categoryMenu level:0]];
  896. #endif
  897. self.categoryViewController.cagegoryLabel.text =self.categoryViewController.categoryString;
  898. self.categoryViewController.categoryid = categoryid ;
  899. self.categoryViewController.loadall=false;
  900. // self.categoryViewController.collectionview
  901. self.categoryViewController.p_alert = nil;
  902. self.categoryViewController.p_available = nil;
  903. self.categoryViewController.p_price = nil;
  904. self.categoryViewController.p_QTY = nil;
  905. self.categoryViewController.p_bestseller = nil;
  906. self.categoryViewController.modelname = nil;
  907. self.categoryViewController.modeldescrip = nil;
  908. #ifdef RA_NOTIFICATION
  909. [ActiveViewController Notify:@"CategoryViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  910. #else
  911. [self.categoryViewController reload_container_getdata:true];
  912. #endif
  913. [self.categoryViewController showCategory];
  914. if([self.current_VC isKindOfClass:[CategoryViewController class]])
  915. return;
  916. [self flipFromViewController:self.current_VC toViewController:self.categoryViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  917. [[self navigationController] setNavigationBarHidden:YES animated:NO];
  918. // self.is_home = false;
  919. // self.current_vc = VC_CATEGORY;
  920. // [self.homeViewController willMoveToParentViewController:nil]; //1
  921. // [self.homeViewController.view removeFromSuperview]; //2
  922. // [self.homeViewController removeFromParentViewController]; //3
  923. //
  924. // [self.container addSubview:self.cagegoryViewController.view]; //2
  925. // [self.cagegoryViewController didMoveToParentViewController:self];
  926. }
  927. - (IBAction)switchToHome:(UIButton *)sender {
  928. [self switchToHome];
  929. // self.current_vc = VC_HOME;
  930. // self.is_home = true;
  931. //
  932. // [self.cagegoryViewController willMoveToParentViewController:nil]; //1
  933. // [self.cagegoryViewController.view removeFromSuperview]; //2
  934. // [self.cagegoryViewController removeFromParentViewController]; //3
  935. //
  936. // [self.container addSubview:self.homeViewController.view]; //2
  937. // [self.homeViewController didMoveToParentViewController:self];
  938. }
  939. -(void)switchToHome
  940. {
  941. if([self.current_VC isKindOfClass:[HomeViewController class]])
  942. return;
  943. if(self.homeViewController == nil)
  944. {
  945. self.homeViewController =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"HomeViewController"];
  946. self.homeViewController.view.frame = self.container.bounds;
  947. }
  948. [self flipFromViewController:self.current_VC toViewController:self.homeViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  949. }
  950. -(void) switchToPreviousVC
  951. {
  952. if(self.previous_VC==nil)
  953. return;
  954. if([self.current_VC isKindOfClass:[self.previous_VC class]])
  955. return;
  956. [self flipFromViewController:self.current_VC toViewController:self.previous_VC withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  957. }
  958. - (IBAction)switchToCart:(UIButton *)sender {
  959. [self switchToCart];
  960. // self.current_vc = VC_HOME;
  961. }
  962. -(void) switchToCart
  963. {
  964. if([self.current_VC isKindOfClass:[CartViewController class]])
  965. return;
  966. UIApplication * app = [UIApplication sharedApplication];
  967. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  968. // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  969. if(appDelegate.bLogin==false&& !RASingleton.sharedInstance.enable_OfflineOrder)
  970. {
  971. LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
  972. // loginvc.delegate = self;
  973. // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  974. loginvc.returnValue = ^(bool blogin){
  975. // UIApplication * app = [UIApplication sharedApplication];
  976. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  977. if(blogin)
  978. {
  979. if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE*/true)
  980. {
  981. [self checklogin:false];
  982. if(appDelegate.can_create_order)
  983. {
  984. NSString* msg =@"";
  985. if(appDelegate.contact_id.length>0)
  986. {
  987. msg = [msg stringByAppendingString:@"\n\nCustomer:"];
  988. msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
  989. }
  990. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Switch To Cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
  991. UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  992. //open exist
  993. OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
  994. ovc.showNavibar = true;
  995. ovc.selectOrder = ^(NSMutableDictionary* order_detail){
  996. if(appDelegate.order_code==nil)
  997. {
  998. [self neworderforCart];
  999. }
  1000. else
  1001. {
  1002. self.previous_VC = self.current_VC;
  1003. [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  1004. [self checklogin:true];
  1005. }
  1006. };
  1007. ovc.init_style = OL_OPEN;
  1008. ovc.onCancel = ^(){
  1009. [self checklogin:true];
  1010. };
  1011. ovc.title = @"SAVED ORDER";
  1012. [self.navigationController pushViewController:ovc animated:true];
  1013. }];
  1014. UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  1015. //create new;
  1016. if(appDelegate.customerInfo==nil)// select contact if current contact not exist
  1017. {
  1018. ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  1019. cvc.showNavibar = true;
  1020. cvc.contact_type = @"Sales_Order_Customer";
  1021. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  1022. appDelegate.contact_id=[value valueForKey:@"customer_cid"];
  1023. appDelegate.customerInfo = value;
  1024. if(appDelegate.order_code==nil)
  1025. [self neworderforCart];
  1026. };
  1027. cvc.onCancel = ^(){
  1028. [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
  1029. };
  1030. cvc.onReset = ^(){
  1031. [self checklogin:true];
  1032. };
  1033. [self.navigationController pushViewController:cvc animated:true];
  1034. }
  1035. else
  1036. {
  1037. [self neworderforCart];
  1038. }
  1039. }];
  1040. UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  1041. }];
  1042. [alertController addAction:action_1];
  1043. [alertController addAction:action_2];
  1044. [alertController addAction:action_3];
  1045. [self presentViewController:alertController animated:YES completion:nil];
  1046. // 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];
  1047. //
  1048. //
  1049. //
  1050. // // alert.
  1051. // [alert show];
  1052. }
  1053. else
  1054. {
  1055. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Switch To Cart" message:@"Do you want to switch to a pending order?" preferredStyle:UIAlertControllerStyleAlert];
  1056. UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  1057. //open exist
  1058. OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
  1059. ovc.showNavibar = true;
  1060. ovc.selectOrder = ^(NSMutableDictionary* order_detail){
  1061. if(appDelegate.order_code==nil)
  1062. {
  1063. [self neworderforCart];
  1064. }
  1065. else
  1066. {
  1067. self.previous_VC = self.current_VC;
  1068. [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  1069. [self checklogin:true];
  1070. }
  1071. };
  1072. ovc.init_style = OL_OPEN;
  1073. ovc.onCancel = ^(){
  1074. [self checklogin:true];
  1075. };
  1076. ovc.title = @"SAVED ORDER";
  1077. [self.navigationController pushViewController:ovc animated:true];
  1078. }];
  1079. UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  1080. }];
  1081. [alertController addAction:action_2];
  1082. [alertController addAction:action_3];
  1083. [self presentViewController:alertController animated:YES completion:nil];
  1084. // 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];
  1085. //
  1086. // // alert.
  1087. // [alert show];
  1088. }
  1089. }
  1090. // else
  1091. // {
  1092. // [self checklogin:true];
  1093. // self.previous_VC = self.current_VC;
  1094. // [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  1095. // }
  1096. }
  1097. // self.offset = 0;
  1098. // [self.content_data removeAllObjects];
  1099. // [self loadpage];
  1100. //
  1101. // [[self navigationController] setNavigationBarHidden:YES animated:NO];
  1102. };
  1103. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  1104. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  1105. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  1106. [self presentViewController:navi animated:YES completion:^{
  1107. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  1108. DebugLog(@"LoginViewController present.........");
  1109. // self.btop = false;
  1110. // <#code#>
  1111. }];
  1112. }
  1113. else
  1114. {
  1115. // if(/*appDelegate.user_type==USER_ROLE_EMPLOYEE&&/*appDelegate.contact_id==nil&&*/appDelegate.order_code==nil)
  1116. if(appDelegate.order_code==nil)
  1117. {
  1118. // [self checklogin:false];
  1119. if(appDelegate.can_create_order)
  1120. {
  1121. NSString* msg =@"";
  1122. if(appDelegate.contact_id.length>0)
  1123. {
  1124. msg = [msg stringByAppendingString:@"\n\nCustomer:"];
  1125. msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
  1126. }
  1127. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Switch To Cart" message:msg preferredStyle:UIAlertControllerStyleAlert];
  1128. UIAlertAction *action_1 = [UIAlertAction actionWithTitle:@"Check for saved order" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  1129. //open exist
  1130. OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
  1131. ovc.showNavibar = true;
  1132. ovc.selectOrder = ^(NSMutableDictionary* order_detail){
  1133. if(appDelegate.order_code==nil)
  1134. {
  1135. [self neworderforCart];
  1136. }
  1137. else
  1138. {
  1139. self.previous_VC = self.current_VC;
  1140. [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  1141. [self checklogin:true];
  1142. }
  1143. };
  1144. ovc.init_style = OL_OPEN;
  1145. ovc.onCancel = ^(){
  1146. [self checklogin:true];
  1147. };
  1148. ovc.title = @"SAVED ORDER";
  1149. [self.navigationController pushViewController:ovc animated:true];
  1150. }];
  1151. UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Create new order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  1152. //create new;
  1153. if(appDelegate.customerInfo==nil)// select contact if current contact not exist
  1154. {
  1155. ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  1156. cvc.showNavibar = true;
  1157. cvc.contact_type = @"Sales_Order_Customer";
  1158. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  1159. appDelegate.contact_id=[value valueForKey:@"customer_cid"];
  1160. appDelegate.customerInfo = value;
  1161. if(appDelegate.order_code==nil)
  1162. [self neworderforCart];
  1163. };
  1164. cvc.onCancel = ^(){
  1165. [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
  1166. };
  1167. cvc.onReset = ^(){
  1168. [self checklogin:true];
  1169. };
  1170. [self.navigationController pushViewController:cvc animated:true];
  1171. }
  1172. else
  1173. {
  1174. [self neworderforCart];
  1175. }
  1176. }];
  1177. UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  1178. }];
  1179. [alertController addAction:action_1];
  1180. [alertController addAction:action_2];
  1181. [alertController addAction:action_3];
  1182. [self presentViewController:alertController animated:YES completion:nil];
  1183. // 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];
  1184. //
  1185. // // alert.
  1186. // [alert show];
  1187. }
  1188. else
  1189. {
  1190. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Switch To Cart" message:@"Do you want to switch to a pending order?" preferredStyle:UIAlertControllerStyleAlert];
  1191. UIAlertAction *action_2 = [UIAlertAction actionWithTitle:@"Switch to pending order" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  1192. //open exist
  1193. OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
  1194. ovc.showNavibar = true;
  1195. ovc.selectOrder = ^(NSMutableDictionary* order_detail){
  1196. if(appDelegate.order_code==nil)
  1197. {
  1198. [self neworderforCart];
  1199. }
  1200. else
  1201. {
  1202. self.previous_VC = self.current_VC;
  1203. [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  1204. [self checklogin:true];
  1205. }
  1206. };
  1207. ovc.init_style = OL_OPEN;
  1208. ovc.onCancel = ^(){
  1209. [self checklogin:true];
  1210. };
  1211. ovc.title = @"SAVED ORDER";
  1212. [self.navigationController pushViewController:ovc animated:true];
  1213. }];
  1214. UIAlertAction *action_3 = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  1215. }];
  1216. [alertController addAction:action_2];
  1217. [alertController addAction:action_3];
  1218. [self presentViewController:alertController animated:YES completion:nil];
  1219. // 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];
  1220. //
  1221. // // alert.
  1222. // [alert show];
  1223. }
  1224. }
  1225. else
  1226. {
  1227. self.previous_VC = self.current_VC;
  1228. [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  1229. }
  1230. }
  1231. }
  1232. -(void) switchToOrder
  1233. {
  1234. if([self.current_VC isKindOfClass:[OrderListViewController class]])
  1235. return;
  1236. // if([self.current_VC isKindOfClass:[ScanOrderListViewController class]])
  1237. // return;
  1238. UIApplication * app = [UIApplication sharedApplication];
  1239. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  1240. if(appDelegate.bLogin==false)
  1241. {
  1242. LoginViewController * loginvc =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
  1243. // loginvc.delegate = self;
  1244. // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  1245. loginvc.returnValue = ^(bool blogin){
  1246. if(blogin)
  1247. {
  1248. [self checklogin:true];
  1249. #ifdef SCANNER_ORDER
  1250. [self flipFromViewController:self.current_VC toViewController:self.scanorderViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  1251. #else
  1252. [self flipFromViewController:self.current_VC toViewController:self.orderViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  1253. #endif
  1254. }
  1255. };
  1256. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  1257. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  1258. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  1259. [self presentViewController:navi animated:YES completion:^{
  1260. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  1261. DebugLog(@"LoginViewController present.........");
  1262. // self.btop = false;
  1263. // <#code#>
  1264. }];
  1265. }
  1266. else
  1267. {
  1268. #ifdef SCANNER_ORDER
  1269. [self flipFromViewController:self.current_VC toViewController:self.scanorderViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  1270. #else
  1271. [self flipFromViewController:self.current_VC toViewController:self.orderViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  1272. #endif
  1273. }
  1274. }
  1275. - (IBAction)switchToOrder:(id)sender {
  1276. [self switchToOrder];
  1277. }
  1278. #pragma mark - CategoryMenuDelegate
  1279. -(void)SelectCategory:(NSString *)category
  1280. {
  1281. [self switchToCagegory:category];
  1282. }
  1283. - (IBAction)showCategoryMenu:(id)sender {
  1284. RAViewController * categorymenuVC =[[UIStoryboard storyboardWithName:@"ERP_Mobile_Search" bundle:nil] instantiateViewControllerWithIdentifier:@"RAViewController"];
  1285. // categorymenuVC.rootViewController = self;
  1286. categorymenuVC.CateMenu_delegate = self;
  1287. // categorymenuVC.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  1288. // [self presentViewController:categorymenuVC animated:YES completion:^{
  1289. //
  1290. // DebugLog(@"login.........");
  1291. // // <#code#>
  1292. // }];
  1293. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:categorymenuVC] ;
  1294. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  1295. [self presentViewController:navi animated:YES completion:^{
  1296. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  1297. DebugLog(@"bundle present.........");
  1298. // self.btop = false;
  1299. // <#code#>
  1300. }];
  1301. // if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
  1302. // categorymenuVC.providesPresentationContextTransitionStyle = YES;
  1303. // categorymenuVC.definesPresentationContext = YES;
  1304. // categorymenuVC.modalPresentationStyle = UIModalPresentationFormSheet;
  1305. // [self presentViewController:categorymenuVC animated:YES completion:nil];
  1306. // } else {
  1307. // categorymenuVC.modalPresentationStyle = UIModalPresentationFormSheet;
  1308. // [self presentViewController:categorymenuVC animated:NO completion:nil];
  1309. //// self.view.window.rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;
  1310. // }
  1311. UIApplication * app = [UIApplication sharedApplication];
  1312. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  1313. if(appDelegate.categoryMenu == nil)
  1314. {
  1315. [RANetwork request_category:^(NSMutableDictionary *result) {
  1316. NSDictionary* category=result;
  1317. if([[category valueForKey:@"result"] intValue]==2)
  1318. {
  1319. appDelegate.categoryMenu = category;
  1320. [categorymenuVC SetMenu:appDelegate.categoryMenu ];
  1321. }
  1322. else
  1323. if([[category valueForKey:@"result"] intValue]==RESULT_NET_ERROR)
  1324. {
  1325. [categorymenuVC SetMenu:nil ];
  1326. }
  1327. else
  1328. {
  1329. [RAUtils message_alert:[category valueForKey:@"err_msg"] title:@"Load Category Menu" controller:self] ;
  1330. }
  1331. }];
  1332. return;
  1333. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1334. //
  1335. //
  1336. // NSDictionary* category=[RANetwork request_Cagegory];
  1337. //
  1338. // dispatch_async(dispatch_get_main_queue(), ^{
  1339. //
  1340. // if([[category valueForKey:@"result"] intValue]==2)
  1341. // {
  1342. // appDelegate.categoryMenu = category;
  1343. // [categorymenuVC SetMenu:appDelegate.categoryMenu ];
  1344. // }
  1345. // else
  1346. // if([[category valueForKey:@"result"] intValue]==RESULT_NET_ERROR)
  1347. // {
  1348. // [categorymenuVC SetMenu:nil ];
  1349. // }
  1350. // else
  1351. // {
  1352. // [RAUtils message_alert:[category valueForKey:@"err_msg"] title:@"Load Category Menu" controller:self] ;
  1353. // }
  1354. //
  1355. //
  1356. //
  1357. // });
  1358. // });
  1359. }
  1360. else
  1361. [categorymenuVC SetMenu:appDelegate.categoryMenu];
  1362. }
  1363. -(NSString*) categoryString:(NSString*) categoryid node:(NSDictionary*) json level:(int) level;
  1364. {
  1365. if(categoryid.length==0)
  1366. return @">All Products>";
  1367. //NSString* idString = [NSString stringWithFormat:@"%d",categoryid];
  1368. NSString* categoryString =@">";
  1369. int count = [[json valueForKey:@"count"] intValue];
  1370. for(int i=0;i<count;i++)
  1371. {
  1372. NSDictionary * category_json = [json objectForKey:[NSString stringWithFormat:@"category_%d",i]];
  1373. NSString* cid = [category_json valueForKey:@"id"] ;
  1374. // NSString* ttt =[categoryid substringToIndex:2+level*2];
  1375. // NSString * qqq =[cid substringToIndex:2+level*2];
  1376. // NSString *ds1=[categoryid substringToIndex:3+level*3];
  1377. // NSString*ds2 = [cid substringToIndex:3+level*3];
  1378. if(cid.length<3+level*3)
  1379. continue;
  1380. if(categoryid.length<3+level*3)
  1381. continue;
  1382. if([[categoryid substringToIndex:3+level*3] isEqualToString: [cid substringToIndex:3+level*3]])
  1383. {
  1384. //categoryString = [categoryString stringByAppendingString:@">"];
  1385. categoryString =[categoryString stringByAppendingString: [category_json valueForKey:@"title" ] ];
  1386. categoryString = [categoryString stringByAppendingString:[ self categoryString:categoryid node:category_json level:level+1]];
  1387. break;
  1388. }
  1389. }
  1390. return categoryString;
  1391. }
  1392. - (void)didReceiveMemoryWarning
  1393. {
  1394. [super didReceiveMemoryWarning];
  1395. // Dispose of any resources that can be recreated.
  1396. }
  1397. - (IBAction)openMenu:(UIButton *)sender {
  1398. [self showMenu];
  1399. }
  1400. - (UIImage*)screen_shot
  1401. {
  1402. // CGRect r = self.view.frame;
  1403. // CGRect r1 = self.view.bounds;
  1404. // double width,height;
  1405. //
  1406. // UIInterfaceOrientation orientation =[UIApplication sharedApplication].statusBarOrientation;
  1407. // ;
  1408. // if(orientation == UIDeviceOrientationLandscapeLeft ||orientation == UIDeviceOrientationLandscapeRight)
  1409. // {
  1410. // width = self.view.frame.size.width>self.view.frame.size.height? self.view.frame.size.width:self.view.frame.size.height;
  1411. // height =self.view.frame.size.width<self.view.frame.size.height? self.view.frame.size.width:self.view.frame.size.height;
  1412. // }
  1413. // else
  1414. // {
  1415. // width = self.view.frame.size.width<self.view.frame.size.height? self.view.frame.size.width:self.view.frame.size.height;
  1416. // height =self.view.frame.size.width>self.view.frame.size.height? self.view.frame.size.width:self.view.frame.size.height;
  1417. // }
  1418. UIGraphicsBeginImageContext(CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height));
  1419. [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
  1420. UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
  1421. UIGraphicsEndImageContext();
  1422. return viewImage;
  1423. }
  1424. - (IBAction)onhideMenuClick:(id)sender {
  1425. [self hideMenu];
  1426. self.backgroundButton.hidden=true;
  1427. self.openMenuButton.hidden = false;
  1428. self.sideMenu.hidden = true;
  1429. }
  1430. - (void)hideMenu
  1431. {
  1432. CGRect frame ;
  1433. frame.origin.x = -300;
  1434. frame.origin.y = 0;
  1435. frame.size.height = self.view.bounds.size.height;
  1436. frame.size.width = 364;
  1437. self.sideMenu.frame=frame;
  1438. self.sideMenu.hidden = true;
  1439. self.blurView.alpha = 0;
  1440. [self.menuButton setImage:[UIImage imageNamed:@"menu_open"] forState:UIControlStateNormal];
  1441. self.menuShown = false;
  1442. self.backgroundButton.hidden=true;
  1443. self.openMenuButton.hidden = false;
  1444. }
  1445. - (void)showMenu
  1446. {
  1447. [self.sideMenuTable reloadData];
  1448. UIImage* imgsource = [self screen_shot];
  1449. self.blurView.alpha = 0;
  1450. UIImage* imgBlur =[self applyBlurWithRadius:5 sourceImage:imgsource tintColor:[UIColor colorWithWhite:0.2 alpha:0.73] saturationDeltaFactor:1.8 maskImage:nil];
  1451. self.blurView.image = imgBlur;
  1452. // self.blurView.hidden = imgBlur;
  1453. // [self.sideMenu becomeFirstResponder];
  1454. self.sideMenu.hidden = false;
  1455. self.backgroundButton.hidden=false;
  1456. CGRect frame ;
  1457. frame.origin.x = 0;
  1458. frame.origin.y = 0;
  1459. frame.size.height = self.view.bounds.size.height;
  1460. frame.size.width = 364;
  1461. // [UIView animateWithDuration:1.0 animations:^{ self.sideMenu.frame=frame;
  1462. // self.blurView.alpha = 1;
  1463. // [self.menuButton setImage:[UIImage imageNamed:@"menu"] forState:UIControlStateNormal];
  1464. //
  1465. // }];
  1466. [UIView animateWithDuration:0.5 animations:^{ self.sideMenu.frame=frame;
  1467. self.blurView.alpha = 1;
  1468. }
  1469. completion:^(BOOL finished) {
  1470. [self.menuButton setImage:[UIImage imageNamed:@"menu"] forState:UIControlStateNormal];
  1471. }];
  1472. // UIImage* img= [UIImage imageNamed:@"menu"];
  1473. // self.menuButton.imageView.image = nil;
  1474. self.menuShown = true;
  1475. }
  1476. -(void)initMenuItems
  1477. {
  1478. UIApplication * app = [UIApplication sharedApplication];
  1479. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  1480. self.sideMenuItems = [[NSMutableArray alloc] init];
  1481. NSMutableDictionary* map = [[NSMutableDictionary alloc] init];
  1482. if(appDelegate.user!=nil)
  1483. {
  1484. [map setValue:@"Wish List" forKey:@"title"];
  1485. [map setValue:@"rect_market_news" forKey:@"img"];
  1486. [self.sideMenuItems addObject:map.copy];
  1487. }
  1488. #if !defined(BUILD_HOMER) && !defined(BUILD_GATIT)
  1489. //#ifndef BUILD_HOMER //homer 要求去掉cam scan 2017/12/20
  1490. // if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
  1491. {
  1492. [map setValue:@"Cam Scan" forKey:@"title"];
  1493. [map setValue:@"rect_contact_list" forKey:@"img"];
  1494. [self.sideMenuItems addObject:map.copy];
  1495. }
  1496. #endif
  1497. if(appDelegate.user_type==USER_ROLE_EMPLOYEE || (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeCustomer))
  1498. {
  1499. // [map setValue:@"Contact" forKey:@"title"];
  1500. // [map setValue:@"rect_contact_list" forKey:@"img"];
  1501. // [self.sideMenuItems addObject:map.copy];
  1502. //#ifdef BUILD_UWAVER
  1503. // [map setValue:@"Hang Tag" forKey:@"title"];
  1504. //#else
  1505. [map setValue:@"Portfolio" forKey:@"title"];
  1506. //#endif
  1507. [map setValue:@"rect_market_news" forKey:@"img"];
  1508. [self.sideMenuItems addObject:map.copy];
  1509. //#ifdef BUILD_UWAVER
  1510. // [map setValue:@"View Hang Tags" forKey:@"title"];
  1511. //#else
  1512. [map setValue:@"View Portfolios" forKey:@"title"];
  1513. //#endif
  1514. [map setValue:@"rect_pdf_list" forKey:@"img"];
  1515. [self.sideMenuItems addObject:map.copy];
  1516. }
  1517. if(appDelegate.can_show_price)
  1518. {
  1519. if(appDelegate.price_hidden)
  1520. [map setValue:@"Show Price" forKey:@"title"];
  1521. else
  1522. [map setValue:@"Hide Price" forKey:@"title"];
  1523. [map setValue:@"rect_announcements" forKey:@"img"];
  1524. [self.sideMenuItems addObject:map.copy];
  1525. }
  1526. // [map setValue:@"Contact" forKey:@"title"];
  1527. // [map setValue:@"rect_market_news" forKey:@"img"];
  1528. // [self.sideMenuItems addObject:map.copy];
  1529. // [map setValue:@"Cache" forKey:@"title"];
  1530. // [map setValue:@"rect_announcements" forKey:@"img"];
  1531. //[self.sideMenuItems addObject:map.copy];
  1532. // NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  1533. // [map setValue:@"Message" forKey:@"title"];
  1534. // [map setValue:@"rect_search_history" forKey:@"img"];
  1535. // [self.sideMenuItems addObject:map.copy];
  1536. //
  1537. #if defined(BUILD_NPD)
  1538. [map setValue:@"Scanner Setting" forKey:@"title"];
  1539. [map setValue:@"rect_change_password" forKey:@"img"];
  1540. [self.sideMenuItems addObject:map.copy];
  1541. # endif
  1542. #if defined(SCANNER_ORDER)
  1543. [map setValue:@"Scanner Order" forKey:@"title"];
  1544. [map setValue:@"rect_change_password" forKey:@"img"];
  1545. [self.sideMenuItems addObject:map.copy];
  1546. # endif
  1547. #if defined(BUILD_NPD)|| defined (BUILD_CONTRAST)
  1548. if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
  1549. {
  1550. [map setValue:@"Offline Setting" forKey:@"title"];
  1551. [map setValue:@"rect_market_news" forKey:@"img"];
  1552. [self.sideMenuItems addObject:map.copy];
  1553. }
  1554. #endif
  1555. if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore ) {
  1556. [map setValue:@"Price Setting" forKey:@"title"];
  1557. // [map setValue:@"rect_market_news" forKey:@"img"];
  1558. [self.sideMenuItems addObject:map.copy];
  1559. }
  1560. if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore ) {
  1561. if ([RASingleton sharedInstance].global_lock) {
  1562. [map setValue:@"Unlock" forKey:@"title"];
  1563. } else {
  1564. [map setValue:@"Lock" forKey:@"title"];
  1565. }
  1566. [self.sideMenuItems addObject:map.copy];
  1567. }
  1568. #if defined(BUILD_HOMER) || defined(BUILD_GATIT)
  1569. /*
  1570. if(appDelegate.user_type==USER_ROLE_EMPLOYEE)
  1571. {
  1572. [map setValue:@"Offline Setting" forKey:@"title"];
  1573. [map setValue:@"rect_market_news" forKey:@"img"];
  1574. [self.sideMenuItems addObject:map.copy];
  1575. }
  1576. */
  1577. // if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER) {
  1578. // [map setValue:@"Price Setting" forKey:@"title"];
  1579. // // [map setValue:@"rect_market_news" forKey:@"img"];
  1580. // [self.sideMenuItems addObject:map.copy];
  1581. // }
  1582. if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore ) {
  1583. if ([Singleton sharedInstance].global_lock) {
  1584. [map setValue:@"Unlock" forKey:@"title"];
  1585. } else {
  1586. [map setValue:@"Lock" forKey:@"title"];
  1587. }
  1588. [self.sideMenuItems addObject:map.copy];
  1589. }
  1590. # endif
  1591. #ifdef DEBUG
  1592. // if([[appDelegate.user lowercaseString] isEqualToString:@"larryl"]||[[appDelegate.user lowercaseString] isEqualToString:@"arpithat"])
  1593. {
  1594. // [map setValue:@"Contact" forKey:@"title"];
  1595. // [map setValue:@"rect_contact_list" forKey:@"img"];
  1596. // [self.sideMenuItems addObject:map.copy];
  1597. [map setValue:@"Function Test" forKey:@"title"];
  1598. [map setValue:@"rect_market_news" forKey:@"img"];
  1599. [self.sideMenuItems addObject:map.copy];
  1600. }
  1601. #endif
  1602. [map setValue:@"Privacy Policy" forKey:@"title"];
  1603. [map setValue:@"rect_change_password" forKey:@"img"];
  1604. [self.sideMenuItems addObject:map.copy];
  1605. [map setValue:@"About us" forKey:@"title"];
  1606. [map setValue:@"rect_change_password" forKey:@"img"];
  1607. [self.sideMenuItems addObject:map.copy];
  1608. #ifdef BUILD_HMLG
  1609. [map setValue:@"Homelegance Website" forKey:@"title"];
  1610. [map setValue:@"rect_change_password" forKey:@"img"];
  1611. [self.sideMenuItems addObject:map.copy];
  1612. #endif
  1613. #if defined(BUILD_NPD)
  1614. [map setValue:@"BLOG" forKey:@"title"];
  1615. [map setValue:@"rect_change_password" forKey:@"img"];
  1616. [self.sideMenuItems addObject:map.copy];
  1617. [map setValue:[NSString stringWithFormat:@"%@ Website",COMPANY_SHORT_NAME] forKey:@"title"];
  1618. [map setValue:@"rect_change_password" forKey:@"img"];
  1619. [self.sideMenuItems addObject:map.copy];
  1620. [map setValue:[NSString stringWithFormat:@"%@ Policy",COMPANY_SHORT_NAME] forKey:@"title"];
  1621. [map setValue:@"rect_change_password" forKey:@"img"];
  1622. [self.sideMenuItems addObject:map.copy];
  1623. [map setValue:@"Simplified Buying Program" forKey:@"title"];
  1624. [map setValue:@"rect_change_password" forKey:@"img"];
  1625. [self.sideMenuItems addObject:map.copy];
  1626. #endif
  1627. #ifdef BUILD_USAI
  1628. // [map setValue:@"BLOG" forKey:@"title"];
  1629. // [map setValue:@"rect_change_password" forKey:@"img"];
  1630. // [self.sideMenuItems addObject:map.copy];
  1631. [map setValue:@"USAI Website" forKey:@"title"];
  1632. [map setValue:@"rect_change_password" forKey:@"img"];
  1633. [self.sideMenuItems addObject:map.copy];
  1634. #endif
  1635. #ifdef BUILD_HOMER
  1636. /*
  1637. [map setValue:@"BLOG" forKey:@"title"];
  1638. [map setValue:@"rect_change_password" forKey:@"img"];
  1639. [self.sideMenuItems addObject:map.copy];
  1640. */
  1641. [map setValue:@"HOMER Website" forKey:@"title"];
  1642. [map setValue:@"rect_change_password" forKey:@"img"];
  1643. [self.sideMenuItems addObject:map.copy];
  1644. #endif
  1645. #ifdef BUILD_GATIT
  1646. [map setValue:@"TITAN Website" forKey:@"title"];
  1647. [map setValue:@"rect_change_password" forKey:@"img"];
  1648. [self.sideMenuItems addObject:map.copy];
  1649. # endif
  1650. [self.sideMenuTable reloadData];
  1651. //
  1652. }
  1653. - (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius sourceImage:(UIImage*)sourceImage tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage
  1654. {
  1655. // Check pre-conditions.
  1656. if (sourceImage.size.width < 1 || sourceImage.size.height < 1) {
  1657. DebugLog (@"*** error: invalid size: (%.2f x %.2f). Both dimensions must be >= 1: %@", sourceImage.size.width, sourceImage.size.height, self);
  1658. return nil;
  1659. }
  1660. if (!sourceImage.CGImage) {
  1661. DebugLog (@"*** error: image must be backed by a CGImage: %@", self);
  1662. return nil;
  1663. }
  1664. if (maskImage && !maskImage.CGImage) {
  1665. DebugLog (@"*** error: maskImage must be backed by a CGImage: %@", maskImage);
  1666. return nil;
  1667. }
  1668. CGRect imageRect = { CGPointZero, sourceImage.size };
  1669. UIImage *effectImage = sourceImage;
  1670. BOOL hasBlur = blurRadius > __FLT_EPSILON__;
  1671. BOOL hasSaturationChange = fabs(saturationDeltaFactor - 1.) > __FLT_EPSILON__;
  1672. if (hasBlur || hasSaturationChange) {
  1673. UIGraphicsBeginImageContextWithOptions(sourceImage.size, NO, [[UIScreen mainScreen] scale]);
  1674. CGContextRef effectInContext = UIGraphicsGetCurrentContext();
  1675. CGContextScaleCTM(effectInContext, 1.0, -1.0);
  1676. CGContextTranslateCTM(effectInContext, 0, -sourceImage.size.height);
  1677. CGContextDrawImage(effectInContext, imageRect, sourceImage.CGImage);
  1678. vImage_Buffer effectInBuffer;
  1679. effectInBuffer.data = CGBitmapContextGetData(effectInContext);
  1680. effectInBuffer.width = CGBitmapContextGetWidth(effectInContext);
  1681. effectInBuffer.height = CGBitmapContextGetHeight(effectInContext);
  1682. effectInBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectInContext);
  1683. UIGraphicsBeginImageContextWithOptions(sourceImage.size, NO, [[UIScreen mainScreen] scale]);
  1684. CGContextRef effectOutContext = UIGraphicsGetCurrentContext();
  1685. vImage_Buffer effectOutBuffer;
  1686. effectOutBuffer.data = CGBitmapContextGetData(effectOutContext);
  1687. effectOutBuffer.width = CGBitmapContextGetWidth(effectOutContext);
  1688. effectOutBuffer.height = CGBitmapContextGetHeight(effectOutContext);
  1689. effectOutBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectOutContext);
  1690. if (hasBlur) {
  1691. // A description of how to compute the box kernel width from the Gaussian
  1692. // radius (aka standard deviation) appears in the SVG spec:
  1693. // http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement
  1694. //
  1695. // For larger values of 's' (s >= 2.0), an approximation can be used: Three
  1696. // successive box-blurs build a piece-wise quadratic convolution kernel, which
  1697. // approximates the Gaussian kernel to within roughly 3%.
  1698. //
  1699. // let d = floor(s * 3*sqrt(2*pi)/4 + 0.5)
  1700. //
  1701. // ... if d is odd, use three box-blurs of size 'd', centered on the output pixel.
  1702. //
  1703. CGFloat inputRadius = blurRadius * [[UIScreen mainScreen] scale];
  1704. NSUInteger radius = floor(inputRadius * 3. * sqrt(2 * M_PI) / 4 + 0.5);
  1705. if (radius % 2 != 1) {
  1706. radius += 1; // force radius to be odd so that the three box-blur methodology works.
  1707. }
  1708. vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, (unsigned int)radius, (unsigned int)radius, 0, kvImageEdgeExtend);
  1709. vImageBoxConvolve_ARGB8888(&effectOutBuffer, &effectInBuffer, NULL, 0, 0, (unsigned int)radius, (unsigned int)radius, 0, kvImageEdgeExtend);
  1710. vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, (unsigned int)radius, (unsigned int)radius, 0, kvImageEdgeExtend);
  1711. }
  1712. BOOL effectImageBuffersAreSwapped = NO;
  1713. if (hasSaturationChange) {
  1714. CGFloat s = saturationDeltaFactor;
  1715. CGFloat floatingPointSaturationMatrix[] = {
  1716. 0.0722 + 0.9278 * s, 0.0722 - 0.0722 * s, 0.0722 - 0.0722 * s, 0,
  1717. 0.7152 - 0.7152 * s, 0.7152 + 0.2848 * s, 0.7152 - 0.7152 * s, 0,
  1718. 0.2126 - 0.2126 * s, 0.2126 - 0.2126 * s, 0.2126 + 0.7873 * s, 0,
  1719. 0, 0, 0, 1,
  1720. };
  1721. const int32_t divisor = 256;
  1722. NSUInteger matrixSize = sizeof(floatingPointSaturationMatrix)/sizeof(floatingPointSaturationMatrix[0]);
  1723. int16_t saturationMatrix[matrixSize];
  1724. for (NSUInteger i = 0; i < matrixSize; ++i) {
  1725. saturationMatrix[i] = (int16_t)roundf(floatingPointSaturationMatrix[i] * divisor);
  1726. }
  1727. if (hasBlur) {
  1728. vImageMatrixMultiply_ARGB8888(&effectOutBuffer, &effectInBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags);
  1729. effectImageBuffersAreSwapped = YES;
  1730. }
  1731. else {
  1732. vImageMatrixMultiply_ARGB8888(&effectInBuffer, &effectOutBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags);
  1733. }
  1734. }
  1735. if (!effectImageBuffersAreSwapped)
  1736. effectImage = UIGraphicsGetImageFromCurrentImageContext();
  1737. UIGraphicsEndImageContext();
  1738. if (effectImageBuffersAreSwapped)
  1739. effectImage = UIGraphicsGetImageFromCurrentImageContext();
  1740. UIGraphicsEndImageContext();
  1741. }
  1742. // Set up output context.
  1743. UIGraphicsBeginImageContextWithOptions(sourceImage.size, NO, [[UIScreen mainScreen] scale]);
  1744. CGContextRef outputContext = UIGraphicsGetCurrentContext();
  1745. CGContextScaleCTM(outputContext, 1.0, -1.0);
  1746. CGContextTranslateCTM(outputContext, 0, -sourceImage.size.height);
  1747. // Draw base image.
  1748. CGContextDrawImage(outputContext, imageRect, sourceImage.CGImage);
  1749. // Draw effect image.
  1750. if (hasBlur) {
  1751. CGContextSaveGState(outputContext);
  1752. if (maskImage) {
  1753. CGContextClipToMask(outputContext, imageRect, maskImage.CGImage);
  1754. }
  1755. CGContextDrawImage(outputContext, imageRect, effectImage.CGImage);
  1756. CGContextRestoreGState(outputContext);
  1757. }
  1758. // Add in color tint.
  1759. if (tintColor) {
  1760. CGContextSaveGState(outputContext);
  1761. CGContextSetFillColorWithColor(outputContext, tintColor.CGColor);
  1762. CGContextFillRect(outputContext, imageRect);
  1763. CGContextRestoreGState(outputContext);
  1764. }
  1765. // Output image is ready.
  1766. UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
  1767. UIGraphicsEndImageContext();
  1768. return outputImage;
  1769. }
  1770. //- (IBAction)openMenu:(UIButton *)sender {
  1771. //}
  1772. #pragma mark - Table view data source
  1773. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  1774. {
  1775. return 1;
  1776. }
  1777. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  1778. {
  1779. return self.sideMenuItems.count;
  1780. }
  1781. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  1782. {
  1783. UIApplication * app = [UIApplication sharedApplication];
  1784. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  1785. NSString *CellIdentifier = @"SideMenuItem";
  1786. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  1787. NSString* title = [self.sideMenuItems[indexPath.row] valueForKey:@"title"];
  1788. cell.backgroundColor = [UIColor clearColor];
  1789. // [cell.backgroundColor:[UIColor clearColor]];
  1790. // UIImageView* iv= [[UIImageView alloc] initWithImage:];
  1791. cell.textLabel.text = title;
  1792. cell.detailTextLabel.textColor =[UIColor redColor];
  1793. if([title isEqualToString:@"Wish List"]&&appDelegate.wish_count>0)
  1794. cell.detailTextLabel.text = [NSString stringWithFormat:@"%ld",appDelegate.wish_count];
  1795. else if(([title isEqualToString:@"Portfolio"] || [title isEqualToString:@"Hang Tag"])&&appDelegate.port_count>0)
  1796. cell.detailTextLabel.text = [NSString stringWithFormat:@"%ld",appDelegate.port_count];
  1797. else
  1798. {
  1799. cell.detailTextLabel.text =nil;
  1800. }
  1801. // cell.imageView.image = [UIImage imageNamed:[self.toolsinfo[indexPath.row] valueForKey:@"img"]];
  1802. return cell;
  1803. }
  1804. #ifdef SCANNER_ORDER
  1805. #pragma mark - Offline Order
  1806. -(void) CreateOfflineOrder
  1807. {
  1808. RASingleton.sharedInstance.enable_OfflineOrder = true;
  1809. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1810. __block MainViewController *brself= self;
  1811. if(appDelegate.contact_id.length<=0)
  1812. {
  1813. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"New Offline Order" message:nil preferredStyle:UIAlertControllerStyleAlert];
  1814. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"With Offline Contact" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  1815. // if(appDelegate.order_code && appDelegate.order_code.length>0)
  1816. // {
  1817. // [RAUtils message_alert:@"Please close current order and try again." title:@"" controller:self];
  1818. // }
  1819. // NSLog(@"new click");
  1820. NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
  1821. // NSString *path = [[NSBundle mainBundle] pathForResource:@"editContact.json" ofType:nil];
  1822. CustomerEditViewController * cuseditVC = [[CustomerEditViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
  1823. cuseditVC.bnewcustomer=true;
  1824. cuseditVC.bolocustomer = true;
  1825. cuseditVC.url_type = URL_FILE;
  1826. cuseditVC.request_url=[OLDataProvider scanTemplatePath:@"scan_contact.json"];
  1827. cuseditVC.params = params;
  1828. cuseditVC.returnValue=^(NSMutableDictionary* value)
  1829. {
  1830. if(value==nil)
  1831. {
  1832. [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
  1833. }
  1834. else
  1835. {
  1836. NSString* contact_id=[[NSUUID new] UUIDString];
  1837. value [@"customer_cid"] = contact_id;
  1838. appDelegate.contact_id=contact_id;
  1839. appDelegate.customerInfo = value;
  1840. [brself refreshContactDisplay];
  1841. [self newoloorder];
  1842. // [brself switchToCart:nil];
  1843. }
  1844. };
  1845. // cuseditVC.delegate=self;
  1846. //
  1847. // if(checked.count==count)
  1848. // {
  1849. // orderinfoVC.have_tail = true
  1850. // }
  1851. [[self navigationController] setNavigationBarHidden:NO animated:NO];
  1852. [self.navigationController pushViewController:cuseditVC animated:false];
  1853. // [self dismissViewControllerAnimated:NO completion:^{
  1854. //// [(UINavigationController*)[self parentViewController] pushViewController:cuseditVC animated:false];;
  1855. //// [[self navigationController] setNavigationBarHidden:NO animated:NO];
  1856. //
  1857. //// [self pushViewController:cuseditVC animated:false];
  1858. // }];
  1859. // [[self navigationController] setNavigationBarHidden:NO animated:NO];
  1860. // [self.navigationController pushViewController:cuseditVC animated:false];
  1861. }];
  1862. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"With Online Contact" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  1863. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1864. if(appDelegate.order_code && appDelegate.order_code.length>0)
  1865. {
  1866. // appDelegate.order_code= nil;
  1867. // [appDelegate SetSo:nil];
  1868. // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  1869. ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  1870. cvc.showNavibar = true;
  1871. cvc.contact_type = @"Sales_Order_Customer";
  1872. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  1873. appDelegate.contact_id=[value valueForKey:@"customer_cid"];
  1874. appDelegate.customerInfo = value;
  1875. // self.norefresh = true;
  1876. [self newoloorder];
  1877. // [main_vc checklogin:true];
  1878. // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  1879. //
  1880. // if(self.returnValue)
  1881. // self.returnValue(value);
  1882. };
  1883. cvc.onCancel = ^(){
  1884. // self.norefresh = true;
  1885. if(appDelegate.customerInfo==nil)
  1886. {
  1887. [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
  1888. }
  1889. else
  1890. {
  1891. [self newoloorder];
  1892. }
  1893. // [main_vc checklogin:true];
  1894. };
  1895. cvc.onReset = ^(){
  1896. // [main_vc checklogin:true];
  1897. };
  1898. [self.navigationController pushViewController:cvc animated:true];
  1899. }
  1900. else
  1901. {
  1902. //create new;
  1903. if(appDelegate.customerInfo==nil)// select contact if current contact not exist
  1904. {
  1905. MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  1906. ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  1907. cvc.showNavibar = true;
  1908. cvc.contact_type = @"Sales_Order_Customer";
  1909. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  1910. appDelegate.contact_id=[value valueForKey:@"customer_cid"];
  1911. appDelegate.customerInfo = value;
  1912. if(appDelegate.order_code==nil)
  1913. [self newoloorder];
  1914. // [main_vc checklogin:true];
  1915. // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  1916. //
  1917. // if(self.returnValue)
  1918. // self.returnValue(value);
  1919. };
  1920. cvc.onCancel = ^(){
  1921. [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
  1922. };
  1923. cvc.onReset = ^(){
  1924. [main_vc checklogin:true];
  1925. };
  1926. [self.navigationController pushViewController:cvc animated:true];
  1927. }
  1928. else
  1929. {
  1930. [self newoloorder];
  1931. }
  1932. }
  1933. }];
  1934. UIAlertAction *alertCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  1935. }];
  1936. [alertControl addAction:actionOne];
  1937. [alertControl addAction:alertthree];
  1938. [alertControl addAction:alertCancel];
  1939. [self presentViewController:alertControl animated:YES completion:nil];
  1940. }
  1941. else
  1942. {
  1943. [self newoloorder];
  1944. }
  1945. }
  1946. -(void) newoloorder
  1947. {
  1948. NSString* order_code = [[NSUUID new] UUIDString];
  1949. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1950. appDelegate.order_code = order_code;
  1951. // NSData* json =[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:URL_SO_CART ofType:@"json" ]];
  1952. NSMutableDictionary* cartTemplate=[OLDataProvider loadScanTemplate:@"scan_cart.json"];
  1953. RASingleton.sharedInstance.scan_cart=cartTemplate;//[[RAConvertor data2dict:json] mutableCopy];
  1954. appDelegate.user_type = USER_ROLE_EMPLOYEE;
  1955. appDelegate.can_set_cart_price = true;
  1956. appDelegate.can_see_price = true;
  1957. // __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Create Order" completion:^{
  1958. // [RANetwork request_create_order:^(NSMutableDictionary *result) {
  1959. // NSMutableDictionary* return_json =result;
  1960. //
  1961. // [waitalert dismissViewControllerAnimated:YES completion:^{
  1962. // if([[return_json valueForKey:@"result"] intValue]==2)
  1963. // {
  1964. // int result=[[return_json valueForKey:@"result"] intValue];
  1965. // if(result==2)
  1966. // {
  1967. // //successed.
  1968. //
  1969. // NSString* order_code = [return_json valueForKey:@"orderCode"];
  1970. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1971. // appDelegate.order_code = order_code;
  1972. // appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
  1973. //
  1974. //
  1975. // #ifdef RA_NOTIFICATION
  1976. // [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  1977. // #else
  1978. // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  1979. // [main_vc reloadCart:true immediately:false];
  1980. // #endif
  1981. //
  1982. //// [self ReloadData];
  1983. //
  1984. //
  1985. // // [self performSelector:@selector(loadpage) withObject:nil afterDelay:1];
  1986. // // [self loadpage];
  1987. //
  1988. //
  1989. // // if(self.shopCartBlock!=nil)
  1990. // // {
  1991. // // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  1992. // //
  1993. // //
  1994. // // CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  1995. // // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  1996. // // iv.image = img;
  1997. // // // [self.contentView addSubview:iv];
  1998. // // self.shopCartBlock(iv);
  1999. // //
  2000. // // }
  2001. //
  2002. // }
  2003. // }
  2004. // else
  2005. // {
  2006. // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:self] ;
  2007. // }
  2008. // }];
  2009. // // [waitalert dismissViewControllerAnimated:YES completion:nil];
  2010. //
  2011. //
  2012. //
  2013. //
  2014. //
  2015. //
  2016. //
  2017. //
  2018. // }];
  2019. //
  2020. // }];
  2021. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2022. //
  2023. // NSDictionary* return_json = [RANetwork new_Order];
  2024. //
  2025. // dispatch_async(dispatch_get_main_queue(), ^{
  2026. // [waitalert dismissViewControllerAnimated:YES completion:nil];
  2027. //
  2028. //
  2029. // if([[return_json valueForKey:@"result"] intValue]==2)
  2030. // {
  2031. // int result=[[return_json valueForKey:@"result"] intValue];
  2032. // if(result==2)
  2033. // {
  2034. // //successed.
  2035. //
  2036. // NSString* order_code = [return_json valueForKey:@"orderCode"];
  2037. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2038. // appDelegate.order_code = order_code;
  2039. // appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
  2040. //
  2041. //
  2042. //#ifdef RA_NOTIFICATION
  2043. // [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  2044. //#else
  2045. // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  2046. // [main_vc reloadCart:true immediately:false];
  2047. //#endif
  2048. //
  2049. // [self ReloadData];
  2050. //
  2051. //
  2052. // // [self performSelector:@selector(loadpage) withObject:nil afterDelay:1];
  2053. // // [self loadpage];
  2054. //
  2055. //
  2056. // // if(self.shopCartBlock!=nil)
  2057. // // {
  2058. // // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  2059. // //
  2060. // //
  2061. // // CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  2062. // // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  2063. // // iv.image = img;
  2064. // // // [self.contentView addSubview:iv];
  2065. // // self.shopCartBlock(iv);
  2066. // //
  2067. // // }
  2068. //
  2069. // }
  2070. // }
  2071. // else
  2072. // {
  2073. // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:self] ;
  2074. // }
  2075. //
  2076. //
  2077. //
  2078. //
  2079. // });
  2080. // });
  2081. }
  2082. #endif
  2083. #pragma mark - Table view delegate
  2084. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  2085. {
  2086. NSString* title = [self.sideMenuItems[indexPath.row] valueForKey:@"title"];
  2087. if([title isEqualToString:@"Cache"])
  2088. {
  2089. CacheViewController * settingvc=[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CacheViewController"];
  2090. PopupNavigationController * navi=[[PopupNavigationController alloc] initWithRootViewController:settingvc];
  2091. navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  2092. [self presentViewController:navi animated:YES completion:^{
  2093. //DebugLog(@"login.........");
  2094. // <#code#>
  2095. }];
  2096. }
  2097. #ifdef SCANNER_ORDER
  2098. else if([title isEqualToString:@"Scanner Order"])
  2099. {
  2100. OLOSettingViewController * offlineVC =[ [UIStoryboard storyboardWithName:@"OLM" bundle:nil] instantiateViewControllerWithIdentifier:@"OLOSettingViewController"];
  2101. offlineVC.returnValue=^(int type){
  2102. if(type == OOC_CREATE_ORDER){
  2103. [self CreateOfflineOrder];
  2104. }
  2105. };
  2106. // loginvc.delegate = self;
  2107. // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  2108. // appDelegate.active_controller = gunVC;
  2109. // gunVC.onDismissVC = ^(){
  2110. // appDelegate.active_controller = active_vc;
  2111. // };
  2112. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:offlineVC] ;
  2113. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  2114. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  2115. [self presentViewController:navi animated:YES completion:^{
  2116. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  2117. DebugLog(@"about present.........");
  2118. // self.btop = false;
  2119. // <#code#>
  2120. }];
  2121. }
  2122. #endif
  2123. else if([title isEqualToString:@"Scanner Setting"])
  2124. {
  2125. //
  2126. #ifndef RA_NOTIFICATION
  2127. UIApplication * app = [UIApplication sharedApplication];
  2128. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  2129. UIViewController* active_vc = appDelegate.active_controller;
  2130. ScannerSettingViewController * gunVC =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ScannerSettingViewController"];
  2131. appDelegate.active_controller = gunVC;
  2132. gunVC.onDismissVC = ^(){
  2133. appDelegate.active_controller = active_vc;
  2134. };
  2135. #else
  2136. ScannerSettingViewController * gunVC =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ScannerSettingViewController"];
  2137. #endif
  2138. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:gunVC] ;
  2139. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  2140. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  2141. [self presentViewController:navi animated:YES completion:^{
  2142. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  2143. DebugLog(@"about present.........");
  2144. // self.btop = false;
  2145. // <#code#>
  2146. }];
  2147. }
  2148. else if([title isEqualToString:@"Offline Setting"])
  2149. {
  2150. // UIApplication * app = [UIApplication sharedApplication];
  2151. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  2152. //UIViewController* active_vc = appDelegate.active_controller;
  2153. OfflineSettingViewController * offlineVC =[ [UIStoryboard storyboardWithName:@"OLM" bundle:nil] instantiateViewControllerWithIdentifier:@"OfflineSettingViewController"];
  2154. // loginvc.delegate = self;
  2155. // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  2156. // appDelegate.active_controller = gunVC;
  2157. // gunVC.onDismissVC = ^(){
  2158. // appDelegate.active_controller = active_vc;
  2159. // };
  2160. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:offlineVC] ;
  2161. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  2162. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  2163. [self presentViewController:navi animated:YES completion:^{
  2164. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  2165. DebugLog(@"about present.........");
  2166. // self.btop = false;
  2167. // <#code#>
  2168. }];
  2169. // [iSalesDB testdata];
  2170. }
  2171. else if([title isEqualToString:@"Function Test"])
  2172. {
  2173. // NSString* url = @"https://shopla.homelegance.com/";
  2174. //
  2175. //
  2176. // NSString* title = @"NPD";
  2177. // UIApplication * app = [UIApplication sharedApplication];
  2178. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  2179. // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  2180. //
  2181. //
  2182. FunctionTestViewController *ViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"FunctionTestViewController"];
  2183. // ViewController.url = url;
  2184. // ViewController.title = title;
  2185. [self.navigationController pushViewController:ViewController animated:YES];
  2186. }
  2187. else if ([title isEqualToString:@"BLOG"]) {
  2188. NSString* url = URL_BLOG;
  2189. #ifdef BUILD_HOMER
  2190. NSString* title = @"HOMER BLOG";
  2191. #endif
  2192. #ifdef BUILD_GATIT
  2193. NSString* title = @"TITAN BLOG";
  2194. #endif
  2195. #ifdef BUILD_NPD
  2196. NSString* title = @"NPD BLOG";
  2197. #endif
  2198. #ifdef BUILD_USAI
  2199. NSString* title = @"USAI BLOG";
  2200. #endif
  2201. #ifdef BUILD_CONTRAST
  2202. NSString* title = @"CONTRAST BLOG";
  2203. #endif
  2204. title = [NSString stringWithFormat:@"%@ BLOG",COMPANY_SHORT_NAME];
  2205. WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
  2206. ViewController.url = url;
  2207. ViewController.title = title;
  2208. [self.navigationController pushViewController:ViewController animated:YES];
  2209. }
  2210. else if([title isEqualToString:@"NPD Website"])
  2211. {
  2212. NSString* url = @"https://www.newpacificdirect.com";//@"https://shopla.homelegance.com/general.htm?websiteId=1";//
  2213. NSString* title = @"NPD";
  2214. // UIApplication * app = [UIApplication sharedApplication];
  2215. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  2216. // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  2217. //
  2218. //
  2219. WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
  2220. ViewController.url = url;
  2221. ViewController.title = title;
  2222. [self.navigationController pushViewController:ViewController animated:YES];
  2223. }
  2224. else if([title isEqualToString:@"USAI Website"])
  2225. {
  2226. NSString* url = @"http://www.united-us.net/";//@"https://shopla.homelegance.com/general.htm?websiteId=1";//
  2227. NSString* title = @"USAI";
  2228. // UIApplication * app = [UIApplication sharedApplication];
  2229. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  2230. // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  2231. //
  2232. //
  2233. WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
  2234. ViewController.url = url;
  2235. ViewController.title = title;
  2236. [self.navigationController pushViewController:ViewController animated:YES];
  2237. }
  2238. else if([title isEqualToString:@"Homelegance Website"])
  2239. {
  2240. NSString* url = @"http://207.140.24.83";//@"https://shopla.homelegance.com/general.htm?websiteId=1";//
  2241. NSString* title = @"Homelegance";
  2242. // UIApplication * app = [UIApplication sharedApplication];
  2243. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  2244. // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  2245. //
  2246. //
  2247. WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
  2248. ViewController.url = url;
  2249. ViewController.title = title;
  2250. [self.navigationController pushViewController:ViewController animated:YES];
  2251. }
  2252. else if([title isEqualToString:@"HOMER Website"])
  2253. {
  2254. NSString* url = COMPANY_WEB;
  2255. NSString* title = @"HOMER";
  2256. WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
  2257. ViewController.url = url;
  2258. ViewController.title = title;
  2259. [self.navigationController pushViewController:ViewController animated:YES];
  2260. }
  2261. else if([title isEqualToString:@"TITAN Website"])
  2262. {
  2263. NSString* url = COMPANY_WEB;
  2264. NSString* title = @"TITAN";
  2265. WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
  2266. ViewController.url = url;
  2267. ViewController.title = title;
  2268. [self.navigationController pushViewController:ViewController animated:YES];
  2269. }
  2270. else if([title isEqualToString:@"NPD Policy"])
  2271. {
  2272. NSString* url = URL_NPD_POLICY;//@"https://shopla.homelegance.com/general.htm?websiteId=1";//
  2273. NSString* title = @"NPD Policy";
  2274. // UIApplication * app = [UIApplication sharedApplication];
  2275. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  2276. // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  2277. //
  2278. //
  2279. WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
  2280. ViewController.url = url;
  2281. ViewController.title = title;
  2282. [self.navigationController pushViewController:ViewController animated:YES];
  2283. }
  2284. else if([title isEqualToString:@"USAI Policy"])
  2285. {
  2286. NSString* url = URL_NPD_POLICY;
  2287. NSString* title = @"USAI Policy";
  2288. WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
  2289. ViewController.url = url;
  2290. ViewController.title = title;
  2291. [self.navigationController pushViewController:ViewController animated:YES];
  2292. }
  2293. else if([title isEqualToString:@"HOMER Policy"])
  2294. {
  2295. NSString* url = URL_NPD_POLICY;
  2296. NSString* title = @"HOMER Policy";
  2297. WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
  2298. ViewController.url = url;
  2299. ViewController.title = title;
  2300. [self.navigationController pushViewController:ViewController animated:YES];
  2301. }
  2302. else if([title isEqualToString:@"Simplified Buying Program"])
  2303. {
  2304. SimplifiedBuyingProgramViewController *ViewController = [[UIStoryboard storyboardWithName:@"NPD_Mobile" bundle:nil] instantiateViewControllerWithIdentifier:@"SimplifiedBuyingProgramViewController"];
  2305. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:ViewController] ;
  2306. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  2307. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  2308. [self presentViewController:navi animated:YES completion:^{
  2309. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  2310. DebugLog(@"about present.........");
  2311. // self.btop = false;
  2312. // <#code#>
  2313. }];
  2314. }
  2315. else if ([title isEqualToString:@"Privacy Policy"]) {
  2316. NSString* url = URL_PRIVACY;
  2317. NSString* title = @"Privacy Policy";
  2318. WebViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"WebViewController"];
  2319. ViewController.url = url;
  2320. ViewController.title = title;
  2321. [self.navigationController pushViewController:ViewController animated:YES];
  2322. }
  2323. else if([title isEqualToString:@"About us"])
  2324. {
  2325. AboutViewController * aboutVC =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"AboutViewController"];
  2326. // loginvc.delegate = self;
  2327. // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  2328. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:aboutVC] ;
  2329. // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  2330. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  2331. [self presentViewController:navi animated:YES completion:^{
  2332. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  2333. DebugLog(@"about present.........");
  2334. // self.btop = false;
  2335. // <#code#>
  2336. }];
  2337. }
  2338. else if([title isEqualToString:@"Wish List"])
  2339. {
  2340. [self hideMenu];
  2341. [self switchtowishlist];
  2342. }
  2343. else if([title isEqualToString:@"Show Price"])
  2344. {
  2345. UIApplication * app = [UIApplication sharedApplication];
  2346. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  2347. if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore && [RASingleton sharedInstance].global_lock) {
  2348. JKLockController *lockVC = [[JKLockController alloc] init];
  2349. [lockVC setPasswordKey:[NSString stringWithFormat:@"%@_password",appDelegate.user]];
  2350. __weak typeof(self) weakself = self;
  2351. lockVC.authoReturn = ^(BOOL failure) {
  2352. if (weakself) {
  2353. __strong typeof(weakself) strongself = weakself;
  2354. [appDelegate set_priceHidden:false];
  2355. [strongself initMenuItems];
  2356. [strongself hideMenu];
  2357. }
  2358. };
  2359. [self.navigationController pushViewController:lockVC animated:YES];
  2360. } else {
  2361. [appDelegate set_priceHidden:false];
  2362. [self initMenuItems];
  2363. [self hideMenu];
  2364. }
  2365. }
  2366. else if([title isEqualToString:@"Hide Price"])
  2367. {
  2368. UIApplication * app = [UIApplication sharedApplication];
  2369. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  2370. if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore && [RASingleton sharedInstance].global_lock) {
  2371. JKLockController *lockVC = [[JKLockController alloc] init];
  2372. [lockVC setPasswordKey:[NSString stringWithFormat:@"%@_password",appDelegate.user]];
  2373. __weak typeof(self) weakself = self;
  2374. lockVC.authoReturn = ^(BOOL failure) {
  2375. if (weakself) {
  2376. __strong typeof(weakself) strongself = weakself;
  2377. [appDelegate set_priceHidden:true];
  2378. [strongself initMenuItems];
  2379. [strongself hideMenu];
  2380. }
  2381. };
  2382. [self.navigationController pushViewController:lockVC animated:YES];
  2383. } else {
  2384. [appDelegate set_priceHidden:true];
  2385. [self initMenuItems];
  2386. [self hideMenu];
  2387. }
  2388. }
  2389. else if([title isEqualToString:@"Portfolio"] || [title isEqualToString:@"Hang Tag"])
  2390. {
  2391. [self hideMenu];
  2392. if([self.current_VC isKindOfClass:[PortfolioViewController class]])
  2393. return;
  2394. [self flipFromViewController:self.current_VC toViewController:self.portfolioViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  2395. }
  2396. else if([title isEqualToString:@"View Portfolios"] || [title isEqualToString:@"View Hang Tags"])
  2397. {
  2398. [self hideMenu];
  2399. if([self.current_VC isKindOfClass:[PortfolioListViewController class]])
  2400. return;
  2401. [self flipFromViewController:self.current_VC toViewController:self.pdfListViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  2402. }
  2403. else if([title isEqualToString:@"Contact"])
  2404. {
  2405. // UITableViewCell* cell =(UITableViewCell*) sender.superview.superview;
  2406. //
  2407. // NSIndexPath * indexPath = [self.detailTable indexPathForCell:cell];
  2408. //
  2409. // if(indexPath.section!=1)
  2410. // return ;
  2411. // // DebugLog(@"shouldchangeedit %d_%d",indexPath.section,indexPath.row);
  2412. // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  2413. //
  2414. // NSString* product_id = [item_json valueForKey:@"product_id"];
  2415. [self hideMenu];
  2416. [self switchtocontact];
  2417. }
  2418. else if([title isEqualToString:@"Cam Scan"])
  2419. {
  2420. // UITableViewCell* cell =(UITableViewCell*) sender.superview.superview;
  2421. //
  2422. // NSIndexPath * indexPath = [self.detailTable indexPathForCell:cell];
  2423. //
  2424. // if(indexPath.section!=1)
  2425. // return ;
  2426. // // DebugLog(@"shouldchangeedit %d_%d",indexPath.section,indexPath.row);
  2427. // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  2428. //
  2429. // NSString* product_id = [item_json valueForKey:@"product_id"];
  2430. [self hideMenu];
  2431. //
  2432. // [self switchtocontact];
  2433. ScannerViewController * scannerVC =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"ScannerViewController"];
  2434. [self.navigationController pushViewController:scannerVC animated:true];
  2435. } else if ([title isEqualToString:@"Price Setting"]) {
  2436. UIApplication * app = [UIApplication sharedApplication];
  2437. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  2438. if ([RASingleton sharedInstance].global_lock) {
  2439. JKLockController *lockVC = [[JKLockController alloc] init];
  2440. [lockVC setPasswordKey:[NSString stringWithFormat:@"%@_password",appDelegate.user]];
  2441. __weak typeof(self) weakself = self;
  2442. lockVC.authoReturn = ^(BOOL failure) {
  2443. if (weakself) {
  2444. __strong typeof(weakself) strongself = weakself;
  2445. PriceSettingViewController *priceSettingVC =[ [UIStoryboard storyboardWithName:@"CUL" bundle:nil] instantiateViewControllerWithIdentifier:@"PriceSettingViewController"];
  2446. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:priceSettingVC] ;
  2447. navi.navigationBar.translucent = NO;
  2448. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  2449. [strongself presentViewController:navi animated:YES completion:^{
  2450. }];
  2451. }
  2452. };
  2453. [self.navigationController pushViewController:lockVC animated:YES];
  2454. } else {
  2455. PriceSettingViewController *priceSettingVC =[ [UIStoryboard storyboardWithName:@"CUL" bundle:nil] instantiateViewControllerWithIdentifier:@"PriceSettingViewController"];
  2456. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:priceSettingVC] ;
  2457. navi.navigationBar.translucent = NO;
  2458. navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  2459. [self presentViewController:navi animated:YES completion:^{
  2460. }];
  2461. }
  2462. } else if ([title isEqualToString:@"Lock"] || [title isEqualToString:@"Unlock"]) {
  2463. UIApplication * app = [UIApplication sharedApplication];
  2464. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  2465. JKLockController *lockVC = [[JKLockController alloc] init];
  2466. [lockVC setPasswordKey:[NSString stringWithFormat:@"%@_password",appDelegate.user]];
  2467. __weak typeof(self) weakself = self;
  2468. lockVC.authoReturn = ^(BOOL failure) {
  2469. if (weakself) {
  2470. __strong typeof(weakself) strongself = weakself;
  2471. [RASingleton sharedInstance].global_lock = ![RASingleton sharedInstance].global_lock;
  2472. [strongself initMenuItems];
  2473. [strongself hideMenu];
  2474. }
  2475. };
  2476. [self.navigationController pushViewController:lockVC animated:YES];
  2477. }
  2478. }
  2479. //#pragma mark - UIAlertViewDelegate
  2480. //// Called when a button is clicked. The view will be automatically dismissed after this call returns
  2481. //- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  2482. //{
  2483. // UIApplication * app = [UIApplication sharedApplication];
  2484. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  2485. //
  2486. //
  2487. //
  2488. // // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  2489. // if(buttonIndex==alertView.cancelButtonIndex)
  2490. // {
  2491. //
  2492. //
  2493. //
  2494. // }
  2495. // else if(buttonIndex==1)
  2496. // {
  2497. // //open exist
  2498. //
  2499. // OrderListViewController* ovc =[ [UIStoryboard storyboardWithName:@"ERP_Mobile_Order" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderListViewController"];
  2500. // ovc.showNavibar = true;
  2501. // ovc.selectOrder = ^(NSMutableDictionary* order_detail){
  2502. // if(appDelegate.order_code==nil)
  2503. // {
  2504. // [self neworderforCart];
  2505. // }
  2506. // else
  2507. // {
  2508. // self.previous_VC = self.current_VC;
  2509. // [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  2510. //
  2511. // [self checklogin:true];
  2512. //
  2513. // }
  2514. //
  2515. // };
  2516. // ovc.init_style = OL_OPEN;
  2517. // ovc.onCancel = ^(){
  2518. //
  2519. // [self checklogin:true];
  2520. //
  2521. // };
  2522. // ovc.title = @"SAVED ORDER";
  2523. // [self.navigationController pushViewController:ovc animated:true];
  2524. // }
  2525. // else
  2526. // {
  2527. // //create new;
  2528. //
  2529. // if(appDelegate.customerInfo==nil)// select contact if current contact not exist
  2530. // {
  2531. //
  2532. // ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  2533. // cvc.showNavibar = true;
  2534. // cvc.contact_type = @"Sales_Order_Customer";
  2535. // cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  2536. //
  2537. // appDelegate.contact_id=[value valueForKey:@"customer_cid"];
  2538. // appDelegate.customerInfo = value;
  2539. //
  2540. //
  2541. // if(appDelegate.order_code==nil)
  2542. // [self neworderforCart];
  2543. //
  2544. //
  2545. // };
  2546. //
  2547. // cvc.onCancel = ^(){
  2548. //
  2549. // [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
  2550. //
  2551. //
  2552. //
  2553. // };
  2554. // cvc.onReset = ^(){
  2555. // [self checklogin:true];
  2556. // };
  2557. //
  2558. // [self.navigationController pushViewController:cvc animated:true];
  2559. // }
  2560. // else
  2561. // {
  2562. // [self neworderforCart];
  2563. // }
  2564. //
  2565. // }
  2566. //}
  2567. -(void) neworderforCart
  2568. {
  2569. __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Create Order" completion:^{
  2570. [RANetwork request_create_order:^(NSMutableDictionary *result) {
  2571. NSMutableDictionary* return_json = result;
  2572. [waitalert dismissViewControllerAnimated:YES completion:^{
  2573. if([[return_json valueForKey:@"result"] intValue]==2)
  2574. {
  2575. int result=[[return_json valueForKey:@"result"] intValue];
  2576. if(result==2)
  2577. {
  2578. //successed.
  2579. NSString* order_code = [return_json valueForKey:@"orderCode"];
  2580. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2581. appDelegate.order_code = order_code;
  2582. appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
  2583. self.previous_VC = self.current_VC;
  2584. [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  2585. #ifdef RA_NOTIFICATION
  2586. [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  2587. #else
  2588. [self reloadCart:true immediately:false];
  2589. [self reloadOrder:true immediately:false];
  2590. #endif
  2591. }
  2592. }
  2593. else
  2594. {
  2595. [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
  2596. }
  2597. }];
  2598. }];
  2599. }];
  2600. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2601. //
  2602. // NSDictionary* return_json = [RANetwork new_Order];
  2603. //
  2604. // dispatch_async(dispatch_get_main_queue(), ^{
  2605. // [waitalert dismissViewControllerAnimated:YES completion:nil];
  2606. //
  2607. //
  2608. // if([[return_json valueForKey:@"result"] intValue]==2)
  2609. // {
  2610. // int result=[[return_json valueForKey:@"result"] intValue];
  2611. // if(result==2)
  2612. // {
  2613. // //successed.
  2614. //
  2615. // NSString* order_code = [return_json valueForKey:@"orderCode"];
  2616. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2617. // appDelegate.order_code = order_code;
  2618. // appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
  2619. //
  2620. // self.previous_VC = self.current_VC;
  2621. // [self flipFromViewController:self.current_VC toViewController:self.cartViewController withDirection:UIViewAnimationOptionTransitionCrossDissolve];
  2622. //
  2623. //
  2624. //#ifdef RA_NOTIFICATION
  2625. // [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
  2626. //#else
  2627. // [self reloadCart:true immediately:false];
  2628. // [self reloadOrder:true immediately:false];
  2629. //#endif
  2630. //
  2631. //
  2632. // }
  2633. // }
  2634. // else
  2635. // {
  2636. // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
  2637. // }
  2638. //
  2639. //
  2640. //
  2641. //
  2642. // });
  2643. // });
  2644. }
  2645. - (void)showPriceAuth:(NSInteger)from {
  2646. }
  2647. @end