CreateOrderViewController.m 164 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868
  1. //
  2. // CreateOrderViewController.m
  3. // RedAnt ERP Mobile
  4. //
  5. // Created by Ray on 8/24/15.
  6. // Copyright (c) 2015 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "CreateOrderViewController.h"
  9. #import "iSalesNetwork.h"
  10. #import "MainViewController.h"
  11. #import "Singleton.h"
  12. #import "config.h"
  13. #import "CustomIOSAlertView.h"
  14. #define SUBMIT_CONFIRM 123
  15. #define KEEP_TAIL 456
  16. #define CLOSE_ACTION 567
  17. @interface CreateOrderViewController ()
  18. // static const char associatedkey;
  19. @property (nonatomic,assign) BOOL isResume;///<恢复
  20. @property (nonatomic,assign) NSInteger userType;///<恢复使用
  21. @end
  22. @implementation CreateOrderViewController
  23. - (void)dealloc {
  24. if (self.isResume && self.userType == USER_ROLE_CUSTOMER) {
  25. [self releaseOrderAfterSave];
  26. }
  27. }
  28. -(void) viewWillAppear:(BOOL)animated
  29. {
  30. [super viewWillAppear:animated];
  31. self.isResume = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_resume"] boolValue];
  32. self.userType = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_userType"] integerValue];
  33. BOOL canSubmit = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_submitOrder"] boolValue];
  34. // 检查权限
  35. NSMutableArray * items = [[NSMutableArray alloc]init];
  36. UIBarButtonItem *savebtn = nil;
  37. savebtn = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"save"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  38. style:UIBarButtonItemStylePlain
  39. target:self
  40. action:@selector(onSaveClick:)];
  41. self.btnSubmitOrder = nil;
  42. self.btnSubmitOrder =[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  43. style:UIBarButtonItemStylePlain
  44. target:self
  45. action:@selector(onCommitOrderClick:)];
  46. UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
  47. fixedItem.width = 20.0f;
  48. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  49. // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
  50. {
  51. [items addObject:savebtn];
  52. [items addObject:fixedItem];
  53. }
  54. if (!self.isResume) {
  55. // 正常情况
  56. if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
  57. // customer的订单必须是Sales Order并且有提交权限才能提交
  58. if ([Singleton sharedInstance].currentOrderIsMerged && [Singleton sharedInstance].permissions_submit_order) {
  59. [items addObject:self.btnSubmitOrder];
  60. }
  61. } else {
  62. [items addObject:self.btnSubmitOrder];
  63. }
  64. } else {
  65. // 恢复
  66. if (self.userType == USER_ROLE_CUSTOMER) {
  67. // customer的订单必须是Sales Order并且有提交权限才能提交
  68. if (canSubmit) {
  69. [items addObject:self.btnSubmitOrder];
  70. }
  71. } else {
  72. [items addObject:self.btnSubmitOrder];
  73. }
  74. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"urgency_resume"];
  75. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"urgency_userType"];
  76. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"urgency_submitOrder"];
  77. }
  78. // [items addObject:item2];
  79. self.navigationItem.rightBarButtonItems=items;
  80. if(appDelegate.can_submit_order)
  81. {
  82. [self.btnSubmitOrder setImage:[UIImage imageNamed:@"commit"]];
  83. self.btnSubmitOrder.enabled = true;
  84. }
  85. else
  86. {
  87. [self.btnSubmitOrder setImage:nil];
  88. self.btnSubmitOrder.enabled = false;
  89. }
  90. self.navigationController.navigationBarHidden=false;
  91. }
  92. -(void) download_success
  93. {
  94. // 用于处理不同child,在成功去的数据后,需要附加的操作。
  95. self.have_tail=[[self.content_data_download valueForKey:@"has_reItem"] boolValue];
  96. NSString* order_customerid=[self getValue:@"customer_cid"];
  97. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  98. appDelegate.order_customer_id = order_customerid;
  99. }
  100. - (void)viewDidLoad {
  101. [super viewDidLoad];
  102. self.editable = YES;
  103. UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"close"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  104. style:UIBarButtonItemStylePlain
  105. target:self
  106. action:@selector(onCloseClick:)];
  107. //[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Close", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCloseClick:)];
  108. // closeButton.title = @"Close";
  109. self.navigationItem.leftBarButtonItem = closeButton;
  110. // self.navigationItem.backBarButtonItem = backButton;
  111. // Do any additional setup after loading the view.
  112. }
  113. - (void)onCommitOrderClick:(id)sender {
  114. // get customer info
  115. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  116. // if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
  117. //
  118. // // 检查价格类型
  119. // // 提货价才能提交订单
  120. // /** 价格类型
  121. // * 0 提货价
  122. // * 1 统一价
  123. // * 2 计算价
  124. // */
  125. // NSInteger priceType = [Singleton sharedInstance].npd_shop_price_type;
  126. // if (priceType != 0) {
  127. //
  128. // NSString* pricename = nil;
  129. // switch (priceType) {
  130. // case 1:
  131. // pricename=flat_price;
  132. // break;
  133. // case 2:
  134. // pricename=given_price;
  135. // break;
  136. // default:
  137. // break;
  138. // }
  139. //
  140. // UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:[NSString stringWithFormat:@"Current price is %@, please change to %@ and try again.",pricename,[Singleton sharedInstance].deliveryString] preferredStyle:UIAlertControllerStyleAlert];
  141. //
  142. // UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  143. //
  144. // [alertVC dismissViewControllerAnimated:YES completion:nil];
  145. //
  146. // }];
  147. //
  148. //
  149. // [alertVC addAction:cancelAction];
  150. //
  151. // [self presentViewController:alertVC animated:YES completion:nil];
  152. //
  153. // return;
  154. // }
  155. // }
  156. NSString* msg;
  157. #ifdef OFFLINE_MODE
  158. if(appDelegate.offline_mode)
  159. {
  160. msg=@"Are you sure to mark offline order as ready for submit?";
  161. }
  162. else
  163. #endif
  164. {
  165. msg=@"Submit order now?";
  166. // if(appDelegate.user_type == USER_ROLE_CUSTOMER) {
  167. //
  168. // NSString *specialInstuction = [Singleton sharedInstance].specialInstruction;
  169. // NSString * deliverprice=[Singleton sharedInstance].deliveryString;
  170. // msg = [NSString stringWithFormat:@"Are you sure to submit order?\n\n1. Your price type is %@, Order will sent to NPD with this price.",deliverprice];
  171. // if (specialInstuction.length) {
  172. // msg = [msg stringByAppendingFormat:@"\n2. Special Instruction: %@.",specialInstuction];
  173. // }
  174. //
  175. // }
  176. }
  177. // 2017-03-20 修改
  178. //
  179. // CustomIOSAlertView *alertView = [[CustomIOSAlertView alloc] init];
  180. //
  181. //
  182. //
  183. //
  184. // // Add some custom content to the alert view
  185. // [alertView setContainerView:[self createDemoView:msg]];
  186. //
  187. // // Modify the parameters
  188. //
  189. //
  190. // NSArray *titleArr = [NSMutableArray arrayWithObjects:@"NO",@"YES", nil];
  191. // [alertView setButtonTitles:titleArr];
  192. // //[alertView setDelegate:self];
  193. //
  194. // // You may use a Block, rather than a delegate.
  195. // [alertView setOnButtonTouchUpInside:^(CustomIOSAlertView *alertView, int buttonIndex) {
  196. // // DebugLog(@"Block: Button at position %d is clicked on alertView %d.", buttonIndex, (int)[alertView tag]);
  197. // if(buttonIndex==0)
  198. // [alertView close];
  199. // else
  200. // {
  201. // // add params check here.
  202. // [self.lastedit endEditing:true];
  203. // [self.lasttextview endEditing:true];
  204. //
  205. //
  206. //
  207. // // self.cancommit=true;
  208. // // NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init];
  209. // // [upparams setValue:[self.params valueForKey:@"cart2Checkbox"] forKey:@"cart2Checkbox"];
  210. // // int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
  211. // // for(int i=0;i<section_count;i++)
  212. // // {
  213. // // NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
  214. // // int item_count = [[sectionjson valueForKey:@"count"] intValue];
  215. // // for(int j=0;j<item_count;j++)
  216. // // {
  217. // // NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
  218. // // NSString* key = [itemjson valueForKey:@"name"];
  219. // // if(key==nil || key.length==0)
  220. // // continue;
  221. // // if([[itemjson valueForKey:@"control"] isEqualToString:@"enum"])
  222. // // {
  223. // // NSString* single_select = [itemjson valueForKey:@"single_select"];
  224. // // if([single_select isEqualToString:@"true"])
  225. // // {
  226. // // NSDictionary* cadejson=[itemjson objectForKey:@"cadedate"];
  227. // // int count = [[cadejson valueForKey:@"count"] intValue];
  228. // // bool setvalue = false;
  229. // // for(int cc=0;cc<count;cc++)
  230. // // {
  231. // // NSDictionary* valjson=[cadejson objectForKey:[NSString stringWithFormat:@"val_%d",cc]];
  232. // // if([[valjson valueForKey:@"check"]intValue]==1)
  233. // // {
  234. // // [upparams setValue:[valjson valueForKey:@"value_id"] forKey:[itemjson valueForKey:@"name"]];
  235. // // setvalue=true;
  236. // // break;
  237. // // }
  238. // // }
  239. // // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
  240. // // {
  241. // // self.cancommit = false;
  242. // // }
  243. // // }
  244. // // else
  245. // // {
  246. // // //not support multi select for now;
  247. // // }
  248. // // /*
  249. // // upparams setValue:itemjson forKey:<#(NSString *)#>
  250. // //
  251. // // */
  252. // // }else
  253. // // if([[itemjson valueForKey:@"control"] isEqualToString:@"action"])
  254. // // {
  255. // // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"data"]==nil)
  256. // // self.cancommit = false;
  257. // // }
  258. // // else if([[itemjson valueForKey:@"control"] isEqualToString:@"signature"])
  259. // // {
  260. // // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"value"] ==nil)
  261. // // self.cancommit = false;
  262. // //
  263. // // NSString* valuestr = [itemjson valueForKey:@"value"];
  264. // // [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
  265. // // }
  266. // // else if([[itemjson valueForKey:@"control"] isEqualToString:@"switch"])
  267. // // {
  268. // // NSString* valuestr = [itemjson valueForKey:@"value"];
  269. // // [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
  270. // //
  271. // // NSString* value = [itemjson valueForKey:@"value"];
  272. // // NSMutableDictionary* boolitem=nil;
  273. // // NSMutableDictionary* subjson=nil;
  274. // // if([value isEqualToString:@"true"])
  275. // // {
  276. // // boolitem =[[itemjson objectForKey:@"true"] mutableCopy];
  277. // //
  278. // // }
  279. // // else
  280. // // {
  281. // // boolitem =[[itemjson objectForKey:@"false"] mutableCopy];
  282. // //
  283. // // }
  284. // // subjson=[[boolitem objectForKey:@"sub_item"] mutableCopy];
  285. // // if( subjson!=nil /*&& !active*/)
  286. // // {
  287. // // int sub_count = [[subjson valueForKey:@"count"] intValue];
  288. // // for(int l=0;l<sub_count;l++)
  289. // // {
  290. // // NSMutableDictionary * modify_item=[[subjson objectForKey:[NSString stringWithFormat:@"item_%d",l ]] mutableCopy];
  291. // //
  292. // //
  293. // //
  294. // //
  295. // // if([modify_item valueForKey:@"value"]!=nil && ![[modify_item valueForKey:@"value"]isEqualToString:@""])
  296. // // [upparams setValue:[modify_item valueForKey:@"value"] forKey:[modify_item valueForKey:@"name"]];
  297. // // else
  298. // // {
  299. // // if([[modify_item valueForKey:@"required"] isEqualToString: @"true"] )
  300. // // self.cancommit = false;
  301. // // }
  302. // // }
  303. // //
  304. // //
  305. // //
  306. // // }
  307. // // }
  308. // // else
  309. // // {
  310. // // if([itemjson valueForKey:@"value"]!=nil && ![[itemjson valueForKey:@"value"]isEqualToString:@""])
  311. // // [upparams setValue:[itemjson valueForKey:@"value"] forKey:[itemjson valueForKey:@"name"]];
  312. // // else
  313. // // {
  314. // // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
  315. // // self.cancommit = false;
  316. // // }
  317. // // }
  318. // // upparams= [self subitem_param:itemjson addto:upparams ];
  319. // // }
  320. // // }
  321. // // if(self.cancommit==false)
  322. // // {
  323. // // [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
  324. // // self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
  325. // // //DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
  326. // // //[self.editorTable reloadData ];
  327. // // [self.editorTable reloadData];
  328. // // // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  329. // // return;
  330. // // }
  331. //
  332. // NSMutableDictionary* upparams = [self check_cancommit:true];
  333. // if(self.cancommit==false)
  334. // return;
  335. //
  336. // if(upparams[@"shipping"]==nil)
  337. // goto commit_order;
  338. // if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
  339. // {
  340. // upparams[@"shipping"] = nil;
  341. // goto commit_order;
  342. // }
  343. // else if([upparams[@"shipping"] doubleValue]==0)
  344. // {
  345. //
  346. //
  347. // UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Shipping is $0.00, continue submit?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  348. // //block代码块取代了delegate
  349. //
  350. //
  351. //
  352. // UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action)
  353. // {
  354. //
  355. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  356. //
  357. // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
  358. // {
  359. //
  360. // if(/*!self.have_tail*/ true)
  361. // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  362. // [upparams setValue:@"false" forKey:@"isHold"];
  363. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  364. //
  365. // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
  366. //
  367. // dispatch_async(dispatch_get_main_queue(), ^{
  368. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  369. //
  370. //
  371. // if([[editor_json valueForKey:@"result"] intValue]==2)
  372. // {
  373. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  374. //
  375. // // debug aaa
  376. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  377. // NSString* company= appDelegate.customerInfo[@"customer_name"];
  378. // NSString* send_to =appDelegate.customerInfo[@"customer_email"];
  379. //
  380. // // appDelegate.customerInfo = customerInfo;
  381. // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  382. // // appDelegate.order_code = nil;
  383. // [appDelegate closeOrder];
  384. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  385. //
  386. // NSString* title=nil;
  387. // NSString* msg=nil;
  388. // if(appDelegate.offline_mode)
  389. // {
  390. // title=TITLE_OFFLINE_SUBMIT;
  391. // msg=MSG_OFFLINE_SUBMIT;
  392. // }
  393. // else
  394. // {
  395. // title=@"Submit successful.";
  396. // msg=[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]];
  397. // }
  398. //
  399. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  400. //
  401. // [alert show];
  402. //
  403. // NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
  404. // NSString* email_content =[editor_json valueForKey:@"email_content"];
  405. // NSString* soid=[editor_json valueForKey:@"so#"];
  406. // // if(pdf_url.length>0)
  407. // // {
  408. // //
  409. // // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  410. // // //[self downloadpdf:pdf_url];
  411. // //
  412. // //
  413. // // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  414. // // {
  415. // // //bbb
  416. // // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  417. // // }
  418. // //
  419. // // [self prepareReturn:nil];
  420. // //
  421. // // [self.navigationController popViewControllerAnimated:true];
  422. // //
  423. // // [appDelegate printPdf:pdf_url];
  424. // //// if(self.printPdfCallback)
  425. // //// self.printPdfCallback(pdf_url);
  426. // // }
  427. // // else
  428. // {
  429. // if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
  430. // {
  431. // //bbb
  432. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  433. // }
  434. // [self prepareReturn:nil];
  435. //
  436. // [self.navigationController popViewControllerAnimated:true];
  437. //
  438. // if(pdf_url.length>0)
  439. // {
  440. //
  441. // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  442. // [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
  443. // // [appDelegate printPdf:pdf_url];
  444. //
  445. // }
  446. // }
  447. //
  448. // }
  449. // else
  450. // {
  451. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  452. // }
  453. //
  454. //
  455. //
  456. //
  457. // });
  458. // });
  459. // }
  460. // else
  461. // {
  462. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Retain models", nil) message:NSLocalizedString(@"There are some models left in cart,do you want to keep them?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
  463. //
  464. //
  465. // alert.tag = KEEP_TAIL;
  466. //
  467. //
  468. // self.upparams = upparams;
  469. //
  470. // [alert show];
  471. // }
  472. //
  473. // }
  474. // else
  475. // { //USER_ROLE_CUSTOMER
  476. //
  477. // // if(self.have_tail)
  478. // // [upparams setValue:@"true" forKey:@"isHold"];
  479. // // else
  480. // // [upparams setValue:@"false" forKey:@"isHold"];
  481. // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  482. //
  483. // [upparams setValue:@"true" forKey:@"isHold"];
  484. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  485. //
  486. // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
  487. //
  488. // dispatch_async(dispatch_get_main_queue(), ^{
  489. //
  490. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  491. //
  492. // if([[editor_json valueForKey:@"result"] intValue]==2)
  493. // {
  494. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  495. //
  496. //
  497. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  498. // // appDelegate.customerInfo = customerInfo;
  499. //
  500. // // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
  501. // // appDelegate.order_code = orderCode;
  502. // // appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
  503. // [appDelegate closeOrder];
  504. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  505. //
  506. // NSString* title=nil;
  507. // NSString* msg=nil;
  508. // if(appDelegate.offline_mode)
  509. // {
  510. // title=TITLE_OFFLINE_SUBMIT;
  511. // msg=MSG_OFFLINE_SUBMIT;
  512. // }
  513. // else
  514. // {
  515. // title=@"Submit successful.";
  516. // msg=[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]];
  517. // }
  518. //
  519. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  520. //
  521. // [alert show];
  522. // // // self.labelContact.text=appDelegate.contact_name;
  523. // //
  524. // // NSDictionary * customerinfo = appDelegate.customerInfo;
  525. // [self prepareReturn:nil];
  526. // [self.navigationController popViewControllerAnimated:true];
  527. // // [self.navigationController dismissViewControllerAnimated:true completion:^{
  528. // //
  529. // //
  530. // // ;
  531. // // }];
  532. //
  533. // }
  534. // else
  535. // {
  536. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  537. // }
  538. //
  539. //
  540. //
  541. //
  542. // });
  543. // });
  544. //
  545. // }
  546. //
  547. //
  548. //
  549. // }];
  550. //
  551. // UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  552. // //DebugLog(@"Cancel");
  553. //
  554. //
  555. // }];
  556. // [alertControl addAction:actionOne];
  557. //
  558. // [alertControl addAction:alertthree];
  559. //
  560. // //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  561. //
  562. //
  563. //
  564. //
  565. // [self presentViewController:alertControl animated:YES completion:nil];
  566. //
  567. //
  568. //
  569. // }
  570. // else
  571. // {
  572. // commit_order:
  573. //
  574. // {
  575. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  576. //
  577. // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
  578. // {
  579. //
  580. // if(/*!self.have_tail*/ true)
  581. // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  582. // [upparams setValue:@"false" forKey:@"isHold"];
  583. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  584. //
  585. // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
  586. //
  587. // dispatch_async(dispatch_get_main_queue(), ^{
  588. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  589. //
  590. //
  591. // if([[editor_json valueForKey:@"result"] intValue]==2)
  592. // {
  593. //
  594. // //debug bbb
  595. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  596. //
  597. //
  598. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  599. // NSString* company= appDelegate.customerInfo[@"customer_name"];
  600. // NSString* send_to =appDelegate.customerInfo[@"customer_email"];
  601. // // appDelegate.customerInfo = customerInfo;
  602. // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  603. // // appDelegate.order_code = nil;
  604. // [appDelegate closeOrder];
  605. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  606. //
  607. // NSString* title=nil;
  608. // NSString* msg=nil;
  609. // if(appDelegate.offline_mode)
  610. // {
  611. // title=TITLE_OFFLINE_SUBMIT;
  612. // msg=MSG_OFFLINE_SUBMIT;
  613. // }
  614. // else
  615. // {
  616. // title=@"Submit successful.";
  617. // msg=[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]];
  618. // }
  619. //
  620. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  621. //
  622. // [alert show];
  623. //
  624. // NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
  625. // NSString* email_content =[editor_json valueForKey:@"email_content"];
  626. // NSString* soid=[editor_json valueForKey:@"so#"];
  627. // // if(pdf_url.length>0)
  628. // // {
  629. // //
  630. // // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  631. // //// [self downloadpdf:pdf_url];
  632. // //
  633. // //
  634. // // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  635. // // {
  636. // // //bbb
  637. // // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  638. // // }
  639. // //
  640. // // [self prepareReturn:nil];
  641. // //
  642. // // [self.navigationController popViewControllerAnimated:true];
  643. // //
  644. // // [appDelegate printPdf:pdf_url];
  645. // //
  646. // //// if(self.printPdfCallback)
  647. // //// self.printPdfCallback(pdf_url);
  648. // // }
  649. // // else
  650. // {
  651. // if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
  652. // {
  653. // //bbb
  654. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  655. // }
  656. // [self prepareReturn:nil];
  657. //
  658. // [self.navigationController popViewControllerAnimated:true];
  659. //
  660. //
  661. // if(pdf_url.length>0)
  662. // {
  663. //
  664. // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  665. //
  666. // [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
  667. //
  668. //
  669. // }
  670. //
  671. //
  672. // }
  673. // // // self.labelContact.text=appDelegate.contact_name;
  674. // //
  675. // // NSDictionary * customerinfo = appDelegate.customerInfo;
  676. //
  677. //
  678. //
  679. //
  680. //
  681. //
  682. // }
  683. // else
  684. // {
  685. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  686. // }
  687. //
  688. //
  689. //
  690. //
  691. // });
  692. // });
  693. // }
  694. // else
  695. // {
  696. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Retain models", nil) message:NSLocalizedString(@"There are some models left in cart,do you want to keep them?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
  697. //
  698. //
  699. // alert.tag = KEEP_TAIL;
  700. //
  701. //
  702. // self.upparams = upparams;
  703. //
  704. // [alert show];
  705. // }
  706. //
  707. // }
  708. // else
  709. // { //USER_ROLE_CUSTOMER
  710. //
  711. // // if(self.have_tail)
  712. // // [upparams setValue:@"true" forKey:@"isHold"];
  713. // // else
  714. // // [upparams setValue:@"false" forKey:@"isHold"];
  715. // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  716. //
  717. // [upparams setValue:@"true" forKey:@"isHold"];
  718. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  719. //
  720. // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
  721. //
  722. // dispatch_async(dispatch_get_main_queue(), ^{
  723. //
  724. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  725. //
  726. // if([[editor_json valueForKey:@"result"] intValue]==2)
  727. // {
  728. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  729. //
  730. //
  731. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  732. // // appDelegate.customerInfo = customerInfo;
  733. //
  734. // // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
  735. // // appDelegate.order_code = orderCode;
  736. // // appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
  737. // [appDelegate closeOrder];
  738. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  739. //
  740. // NSString* title=nil;
  741. // NSString* msg=nil;
  742. // if(appDelegate.offline_mode)
  743. // {
  744. // title=TITLE_OFFLINE_SUBMIT;
  745. // msg=MSG_OFFLINE_SUBMIT;
  746. // }
  747. // else
  748. // {
  749. // title=@"Submit successful.";
  750. // msg=[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]];
  751. // }
  752. //
  753. //
  754. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  755. //
  756. // [alert show];
  757. // // // self.labelContact.text=appDelegate.contact_name;
  758. // //
  759. // // NSDictionary * customerinfo = appDelegate.customerInfo;
  760. // [self prepareReturn:nil];
  761. // // [self.navigationController dismissViewControllerAnimated:true completion:^{
  762. // //
  763. // //
  764. // // ;
  765. // // }];
  766. // [self.navigationController popViewControllerAnimated:true];
  767. //
  768. // }
  769. // else
  770. // {
  771. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  772. // }
  773. //
  774. //
  775. //
  776. //
  777. // });
  778. // });
  779. //
  780. // }
  781. // }
  782. //
  783. //
  784. //
  785. //
  786. // }
  787. //
  788. //
  789. //
  790. //
  791. //
  792. //
  793. //
  794. //
  795. //
  796. //
  797. //
  798. // }
  799. // }];
  800. //
  801. // // [alertView setUseMotionEffects:true];
  802. //
  803. //
  804. // // And launch the dialog
  805. //
  806. // [alertView sizeToFit];
  807. // [alertView show];
  808. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Submit Confirm.", nil) message:NSLocalizedString(msg, nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
  809. //
  810. // alert.tag = SUBMIT_CONFIRM;
  811. // [alert show];
  812. //
  813. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Order Submission" message:msg preferredStyle:UIAlertControllerStyleAlert];
  814. UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"YES" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  815. {
  816. // add params check here.
  817. [self.lastedit endEditing:true];
  818. [self.lasttextview endEditing:true];
  819. NSMutableDictionary* upparams = [self check_cancommit:true];
  820. if(self.cancommit==false)
  821. return;
  822. if(upparams[@"shipping"]==nil)
  823. goto commit_order;
  824. if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
  825. {
  826. upparams[@"shipping"] = nil;
  827. goto commit_order;
  828. }
  829. else if([upparams[@"shipping"] doubleValue]==0)
  830. {
  831. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Shipping is $0.00, continue submit?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  832. //block代码块取代了delegate
  833. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action)
  834. {
  835. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  836. if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
  837. {
  838. if(/*!self.have_tail*/ true)
  839. {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  840. [upparams setValue:@"false" forKey:@"isHold"];
  841. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  842. NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
  843. dispatch_async(dispatch_get_main_queue(), ^{
  844. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  845. if([[editor_json valueForKey:@"result"] intValue]==2)
  846. {
  847. // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  848. // debug aaa
  849. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  850. NSString* company= appDelegate.customerInfo[@"customer_name"];
  851. NSString* send_to =appDelegate.customerInfo[@"customer_email"];
  852. // appDelegate.customerInfo = customerInfo;
  853. // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  854. // appDelegate.order_code = nil;
  855. [appDelegate closeOrder];
  856. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  857. NSString* title=nil;
  858. NSString* msg=nil;
  859. #ifdef OFFLINE_MODE
  860. if(appDelegate.offline_mode)
  861. {
  862. title=TITLE_OFFLINE_SUBMIT;
  863. msg=MSG_OFFLINE_SUBMIT;
  864. }
  865. else
  866. #endif
  867. {
  868. title=@"Order submitted sucessfully";
  869. msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  870. }
  871. UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  872. [alert show];
  873. NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
  874. NSString* email_content =[editor_json valueForKey:@"email_content"];
  875. NSString* soid=[editor_json valueForKey:@"so#"];
  876. // if(pdf_url.length>0)
  877. // {
  878. //
  879. // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  880. // //[self downloadpdf:pdf_url];
  881. //
  882. //
  883. // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  884. // {
  885. // //bbb
  886. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  887. // }
  888. //
  889. // [self prepareReturn:nil];
  890. //
  891. // [self.navigationController popViewControllerAnimated:true];
  892. //
  893. // [appDelegate printPdf:pdf_url];
  894. //// if(self.printPdfCallback)
  895. //// self.printPdfCallback(pdf_url);
  896. // }
  897. // else
  898. {
  899. if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
  900. {
  901. //bbb
  902. [((MainViewController*)appDelegate.main_vc) Loginout:false];
  903. }
  904. [self prepareReturn:nil];
  905. [self.navigationController popViewControllerAnimated:true];
  906. if(pdf_url.length>0)
  907. {
  908. [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  909. [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
  910. // [appDelegate printPdf:pdf_url];
  911. }
  912. }
  913. }
  914. else
  915. {
  916. [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  917. }
  918. });
  919. });
  920. }
  921. else
  922. {
  923. UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Retain models", nil) message:NSLocalizedString(@"There are some models left in cart,do you want to keep them?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
  924. alert.tag = KEEP_TAIL;
  925. self.upparams = upparams;
  926. [alert show];
  927. }
  928. }
  929. else
  930. { //USER_ROLE_CUSTOMER
  931. // if(self.have_tail)
  932. // [upparams setValue:@"true" forKey:@"isHold"];
  933. // else
  934. // [upparams setValue:@"false" forKey:@"isHold"];
  935. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  936. [upparams setValue:@"true" forKey:@"isHold"];
  937. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  938. NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
  939. dispatch_async(dispatch_get_main_queue(), ^{
  940. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  941. if([[editor_json valueForKey:@"result"] intValue]==2)
  942. {
  943. // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  944. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  945. // appDelegate.customerInfo = customerInfo;
  946. // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
  947. // appDelegate.order_code = orderCode;
  948. // appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
  949. [appDelegate closeOrder];
  950. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  951. NSString* title=nil;
  952. NSString* msg=nil;
  953. #ifdef OFFLINE_MODE
  954. if(appDelegate.offline_mode)
  955. {
  956. title=TITLE_OFFLINE_SUBMIT;
  957. msg=MSG_OFFLINE_SUBMIT;
  958. }
  959. else
  960. #endif
  961. {
  962. title=@"Order submitted sucessfully";
  963. msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  964. }
  965. UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  966. [alert show];
  967. // // self.labelContact.text=appDelegate.contact_name;
  968. //
  969. // NSDictionary * customerinfo = appDelegate.customerInfo;
  970. [self prepareReturn:nil];
  971. [self.navigationController popViewControllerAnimated:true];
  972. // [self.navigationController dismissViewControllerAnimated:true completion:^{
  973. //
  974. //
  975. // ;
  976. // }];
  977. }
  978. else
  979. {
  980. [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  981. }
  982. });
  983. });
  984. }
  985. }];
  986. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  987. //DebugLog(@"Cancel");
  988. }];
  989. [alertControl addAction:actionOne];
  990. [alertControl addAction:alertthree];
  991. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  992. [self presentViewController:alertControl animated:YES completion:nil];
  993. }
  994. else
  995. {
  996. commit_order:
  997. {
  998. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  999. if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
  1000. {
  1001. if(/*!self.have_tail*/ true)
  1002. {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  1003. [upparams setValue:@"false" forKey:@"isHold"];
  1004. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1005. NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
  1006. dispatch_async(dispatch_get_main_queue(), ^{
  1007. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1008. if([[editor_json valueForKey:@"result"] intValue]==2)
  1009. {
  1010. //debug bbb
  1011. // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  1012. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1013. NSString* company= appDelegate.customerInfo[@"customer_name"];
  1014. NSString* send_to =appDelegate.customerInfo[@"customer_email"];
  1015. // appDelegate.customerInfo = customerInfo;
  1016. // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  1017. // appDelegate.order_code = nil;
  1018. [appDelegate closeOrder];
  1019. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  1020. NSString* title=nil;
  1021. NSString* msg=nil;
  1022. #ifdef OFFLINE_MODE
  1023. if(appDelegate.offline_mode)
  1024. {
  1025. title=TITLE_OFFLINE_SUBMIT;
  1026. msg=MSG_OFFLINE_SUBMIT;
  1027. }
  1028. else
  1029. #endif
  1030. {
  1031. title=@"Order submitted sucessfully";
  1032. msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  1033. }
  1034. UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  1035. [alert show];
  1036. NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
  1037. NSString* email_content =[editor_json valueForKey:@"email_content"];
  1038. NSString* soid=[editor_json valueForKey:@"so#"];
  1039. // if(pdf_url.length>0)
  1040. // {
  1041. //
  1042. // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  1043. //// [self downloadpdf:pdf_url];
  1044. //
  1045. //
  1046. // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  1047. // {
  1048. // //bbb
  1049. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  1050. // }
  1051. //
  1052. // [self prepareReturn:nil];
  1053. //
  1054. // [self.navigationController popViewControllerAnimated:true];
  1055. //
  1056. // [appDelegate printPdf:pdf_url];
  1057. //
  1058. //// if(self.printPdfCallback)
  1059. //// self.printPdfCallback(pdf_url);
  1060. // }
  1061. // else
  1062. {
  1063. NSMutableDictionary* value=[[NSMutableDictionary alloc]init];
  1064. if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
  1065. {
  1066. //bbb
  1067. [((MainViewController*)appDelegate.main_vc) Loginout:false];
  1068. value[@"commitorder_logout"]=@"true";
  1069. }
  1070. value[@"is_subaction"] = self.params[@"is_subaction"];
  1071. value[@"subaction_tag"] = self.params[@"subaction_tag"];
  1072. [self prepareReturn:value];
  1073. [self.navigationController popViewControllerAnimated:true];
  1074. if(pdf_url.length>0)
  1075. {
  1076. [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  1077. [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
  1078. }
  1079. }
  1080. // // self.labelContact.text=appDelegate.contact_name;
  1081. //
  1082. // NSDictionary * customerinfo = appDelegate.customerInfo;
  1083. }
  1084. else
  1085. {
  1086. [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  1087. }
  1088. });
  1089. });
  1090. }
  1091. else
  1092. {
  1093. UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Retain models", nil) message:NSLocalizedString(@"There are some models left in cart,do you want to keep them?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
  1094. alert.tag = KEEP_TAIL;
  1095. self.upparams = upparams;
  1096. [alert show];
  1097. }
  1098. }
  1099. else
  1100. { //USER_ROLE_CUSTOMER
  1101. // if(self.have_tail)
  1102. // [upparams setValue:@"true" forKey:@"isHold"];
  1103. // else
  1104. // [upparams setValue:@"false" forKey:@"isHold"];
  1105. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  1106. [upparams setValue:@"true" forKey:@"isHold"];
  1107. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1108. NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
  1109. dispatch_async(dispatch_get_main_queue(), ^{
  1110. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1111. if([[editor_json valueForKey:@"result"] intValue]==2)
  1112. {
  1113. // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  1114. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1115. // appDelegate.customerInfo = customerInfo;
  1116. // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
  1117. // appDelegate.order_code = orderCode;
  1118. // appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
  1119. [appDelegate closeOrder];
  1120. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  1121. NSString* title=nil;
  1122. NSString* msg=nil;
  1123. #ifdef OFFLINE_MODE
  1124. if(appDelegate.offline_mode)
  1125. {
  1126. title=TITLE_OFFLINE_SUBMIT;
  1127. msg=MSG_OFFLINE_SUBMIT;
  1128. }
  1129. else
  1130. #endif
  1131. {
  1132. title=@"Order submitted sucessfully";
  1133. msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  1134. }
  1135. UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  1136. [alert show];
  1137. // // self.labelContact.text=appDelegate.contact_name;
  1138. //
  1139. // NSDictionary * customerinfo = appDelegate.customerInfo;
  1140. [self prepareReturn:nil];
  1141. // [self.navigationController dismissViewControllerAnimated:true completion:^{
  1142. //
  1143. //
  1144. // ;
  1145. // }];
  1146. [self.navigationController popViewControllerAnimated:true];
  1147. }
  1148. else
  1149. {
  1150. [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  1151. }
  1152. });
  1153. });
  1154. }
  1155. }
  1156. }
  1157. }
  1158. }];
  1159. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"NO" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  1160. }];
  1161. [alertVC addAction:yesAction];
  1162. [alertVC addAction:cancelAction];
  1163. [self presentViewController:alertVC animated:yesAction completion:nil];
  1164. }
  1165. - (UIView *)createDemoView:(NSString*) msg
  1166. {
  1167. UIView *demoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 290, 200)];
  1168. // UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 270, 180)];
  1169. // [imageView setImage:[UIImage imageNamed:@"demo"]];
  1170. UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 270, 10)];
  1171. titleLabel.font = [UIFont boldSystemFontOfSize:20];
  1172. titleLabel.text=@"Order Submission";
  1173. titleLabel.numberOfLines = 0;
  1174. titleLabel.lineBreakMode =NSLineBreakByWordWrapping;
  1175. // titleLabel.textAlignment = NSTextAlignmentRight;
  1176. titleLabel.textAlignment = NSTextAlignmentCenter;
  1177. CGSize constraintkey = CGSizeMake(270, 20000.0f);//key label width is 40% cell width;
  1178. CGSize sizetitle = [titleLabel.text=@"Order Submission" sizeWithFont:[UIFont systemFontOfSize:20.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
  1179. //[titleLabel sizeToFit];
  1180. // titleLabel.center.x = demoView.center.x;
  1181. titleLabel.frame = CGRectMake(10, 10, 270, sizetitle.height);
  1182. [demoView addSubview:titleLabel];
  1183. UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 260, 10)];
  1184. lineLabel.font = [UIFont systemFontOfSize:17];
  1185. lineLabel.text=msg;
  1186. lineLabel.numberOfLines = 0;
  1187. lineLabel.lineBreakMode =NSLineBreakByWordWrapping;
  1188. CGSize sizemsg = [msg sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
  1189. lineLabel.frame = CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 260, sizemsg.height);
  1190. //[lineLabel sizeToFit];
  1191. [demoView addSubview:lineLabel];
  1192. demoView.frame = CGRectMake(0, 0, 290, lineLabel.frame.origin.y+lineLabel.frame.size.height+25);
  1193. return demoView;
  1194. }
  1195. - (void)onCloseClick:(UIButton *)sender {
  1196. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1197. if (self.resumeOrder) {
  1198. [appDelegate.main_vc.navigationController popViewControllerAnimated:YES];
  1199. return;
  1200. }
  1201. //
  1202. // NSRange range = [tempStr rangeOfString:@")\">"];//判断字符串是否包含
  1203. //
  1204. // //if (range.location ==NSNotFound)//不包含
  1205. // if (range.length >0)//包含
  1206. // {
  1207. //
  1208. //
  1209. //
  1210. // }
  1211. // else//不包含
  1212. // {
  1213. //
  1214. // }
  1215. UIAlertView * alert = nil;
  1216. if(appDelegate.order_status==0)
  1217. {
  1218. alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Choose your action", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Switch to cart", nil),@"Switch to order history",NSLocalizedString(@"Close and cancel order", nil), nil];
  1219. }
  1220. else
  1221. {
  1222. alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Choose your action", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Switch to cart", nil),@"Switch to order history",NSLocalizedString(@"Close and release order", nil), nil];
  1223. }
  1224. alert.tag = CLOSE_ACTION;
  1225. // alert.
  1226. [alert show];
  1227. // if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
  1228. // appDelegate.order_code = nil;
  1229. //
  1230. // }
  1231. }
  1232. - (void)didReceiveMemoryWarning {
  1233. [super didReceiveMemoryWarning];
  1234. // Dispose of any resources that can be recreated.
  1235. }
  1236. - (IBAction)onSaveClick:(id)sender {
  1237. // id foo = nil;
  1238. // [[NSMutableArray array] addObject:foo];
  1239. // add params check here.
  1240. [self.lastedit endEditing:true];
  1241. [self.lasttextview endEditing:true];
  1242. // self.cancommit=true;
  1243. // NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init];
  1244. // [upparams setValue:[self.params valueForKey:@"cart2Checkbox"] forKey:@"cart2Checkbox"];
  1245. // int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
  1246. // for(int i=0;i<section_count;i++)
  1247. // {
  1248. // NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
  1249. // int item_count = [[sectionjson valueForKey:@"count"] intValue];
  1250. // for(int j=0;j<item_count;j++)
  1251. // {
  1252. // NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
  1253. // NSString* key = [itemjson valueForKey:@"name"];
  1254. // if(key==nil || key.length==0)
  1255. // continue;
  1256. // if([[itemjson valueForKey:@"control"] isEqualToString:@"enum"])
  1257. // {
  1258. // NSString* single_select = [itemjson valueForKey:@"single_select"];
  1259. // if([single_select isEqualToString:@"true"])
  1260. // {
  1261. // NSDictionary* cadejson=[itemjson objectForKey:@"cadedate"];
  1262. // int count = [[cadejson valueForKey:@"count"] intValue];
  1263. // bool setvalue = false;
  1264. // for(int cc=0;cc<count;cc++)
  1265. // {
  1266. // NSDictionary* valjson=[cadejson objectForKey:[NSString stringWithFormat:@"val_%d",cc]];
  1267. // if([[valjson valueForKey:@"check"]intValue]==1)
  1268. // {
  1269. // [upparams setValue:[valjson valueForKey:@"value_id"] forKey:[itemjson valueForKey:@"name"]];
  1270. // setvalue=true;
  1271. // break;
  1272. // }
  1273. // }
  1274. // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
  1275. // {
  1276. // self.cancommit = false;
  1277. // }
  1278. // }
  1279. // else
  1280. // {
  1281. // //not support multi select for now;
  1282. // }
  1283. // /*
  1284. // upparams setValue:itemjson forKey:<#(NSString *)#>
  1285. //
  1286. // */
  1287. // }else
  1288. // if([[itemjson valueForKey:@"control"] isEqualToString:@"action"])
  1289. // {
  1290. // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"data"]==nil)
  1291. // self.cancommit = false;
  1292. // }
  1293. // else if([[itemjson valueForKey:@"control"] isEqualToString:@"signature"])
  1294. // {
  1295. // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"value"]==nil)
  1296. // self.cancommit = false;
  1297. //
  1298. // NSString* valuestr = [itemjson valueForKey:@"value"];
  1299. // [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
  1300. // }
  1301. // else if([[itemjson valueForKey:@"control"] isEqualToString:@"switch"])
  1302. // {
  1303. // NSString* valuestr = [itemjson valueForKey:@"value"];
  1304. // [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
  1305. //
  1306. // NSString* value = [itemjson valueForKey:@"value"];
  1307. // NSMutableDictionary* boolitem=nil;
  1308. // NSMutableDictionary* subjson=nil;
  1309. // if([value isEqualToString:@"true"])
  1310. // {
  1311. // boolitem =[[itemjson objectForKey:@"true"] mutableCopy];
  1312. //
  1313. // }
  1314. // else
  1315. // {
  1316. // boolitem =[[itemjson objectForKey:@"false"] mutableCopy];
  1317. //
  1318. // }
  1319. // subjson=[[boolitem objectForKey:@"sub_item"] mutableCopy];
  1320. // if( subjson!=nil /*&& !active*/)
  1321. // {
  1322. // int sub_count = [[subjson valueForKey:@"count"] intValue];
  1323. // for(int l=0;l<sub_count;l++)
  1324. // {
  1325. // NSMutableDictionary * modify_item=[[subjson objectForKey:[NSString stringWithFormat:@"item_%d",l ]] mutableCopy];
  1326. //
  1327. //
  1328. //
  1329. //
  1330. // if([modify_item valueForKey:@"value"]!=nil && ![[modify_item valueForKey:@"value"]isEqualToString:@""])
  1331. // [upparams setValue:[modify_item valueForKey:@"value"] forKey:[modify_item valueForKey:@"name"]];
  1332. // else
  1333. // {
  1334. // if([[modify_item valueForKey:@"required"] isEqualToString: @"true"] )
  1335. // self.cancommit = false;
  1336. // }
  1337. // }
  1338. //
  1339. //
  1340. //
  1341. // }
  1342. // }
  1343. // else
  1344. // {
  1345. // if([itemjson valueForKey:@"value"]!=nil && ![[itemjson valueForKey:@"value"]isEqualToString:@""])
  1346. // [upparams setValue:[itemjson valueForKey:@"value"] forKey:[itemjson valueForKey:@"name"]];
  1347. // else
  1348. // {
  1349. // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
  1350. // self.cancommit = false;
  1351. // }
  1352. // }
  1353. // upparams= [self subitem_param:itemjson addto:upparams ];
  1354. // }
  1355. // }
  1356. // // save order 不检查必填项;
  1357. // self.cancommit=true;
  1358. // if(self.cancommit==false)
  1359. // {
  1360. // [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
  1361. // self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
  1362. // //DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
  1363. // //[self.editorTable reloadData ];
  1364. // [self.editorTable reloadData];
  1365. // return;
  1366. // }
  1367. NSMutableDictionary* upparams = [self check_cancommit:false];
  1368. // if(self.cancommit==false)
  1369. // return;
  1370. if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
  1371. upparams[@"shipping"] = nil;
  1372. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Saving Order"];
  1373. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1374. NSDictionary* editor_json = [iSalesNetwork save_Order:upparams];
  1375. dispatch_async(dispatch_get_main_queue(), ^{
  1376. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1377. if([[editor_json valueForKey:@"result"] intValue]==2)
  1378. {
  1379. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1380. NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  1381. if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
  1382. {
  1383. appDelegate.customerInfo = customerInfo;
  1384. appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  1385. }
  1386. NSString *msg = nil;
  1387. if ([editor_json objectForKey:@"so#"]) {
  1388. msg = [@"SO#:" stringByAppendingString:[editor_json objectForKey:@"so#"]];
  1389. }
  1390. [RAUtils message_alert:msg title:@"Order Saved" controller:self] ;
  1391. if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.save_order_logout && appDelegate.user_type ==USER_ROLE_EMPLOYEE)
  1392. {
  1393. [((MainViewController*)appDelegate.main_vc) Loginout:false];
  1394. [self prepareReturn:nil];
  1395. [self.navigationController popViewControllerAnimated:true];
  1396. }
  1397. if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
  1398. if (![Singleton sharedInstance].currentOrderIsMerged) {
  1399. [self releaseOrderAfterSave];
  1400. }
  1401. }
  1402. // if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
  1403. // appDelegate.order_code = nil;
  1404. //
  1405. // }
  1406. // // self.labelContact.text=appDelegate.contact_name;
  1407. //
  1408. // NSDictionary * customerinfo = appDelegate.customerInfo;
  1409. // [self prepareReturn:nil];
  1410. // [self.navigationController dismissViewControllerAnimated:true completion:^{
  1411. //
  1412. //
  1413. // ;
  1414. // }];
  1415. }
  1416. else
  1417. {
  1418. [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:self] ;
  1419. }
  1420. });
  1421. });
  1422. }
  1423. - (void)textFieldDidEndEditing:(UITextField *)textField
  1424. {
  1425. [super textFieldDidEndEditing:textField];
  1426. UITableViewCell *cell = (UITableViewCell *) textField.superview.superview;
  1427. NSIndexPath * indexPath = [self.editorTable indexPathForCell:cell];
  1428. NSMutableDictionary* section_json=nil;
  1429. // DebugLog(@"endedit %d_%d",indexPath.section,indexPath.row);
  1430. NSMutableDictionary* item_json =[((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row] mutableCopy];
  1431. NSString* name = [item_json valueForKey:@"name"];
  1432. if([name isEqualToString:@"shipping"]|| [name isEqualToString:@"handling_fee_value"]||[name isEqualToString:@"lift_gate_value"]||[name isEqualToString:@"tax_percentage"])
  1433. {
  1434. float shipping = [self getprice:@"shipping" section:indexPath.section];
  1435. float paymentsAndCredits = [self getprice:@"paymentsAndCredits" section:indexPath.section];
  1436. float handling_fee_value = [self getprice:@"handling_fee_value" section:indexPath.section];
  1437. float lift_gate =[self getprice:@"lift_gate_value" section:indexPath.section];
  1438. float tax = [self getprice:@"tax_percentage" section:indexPath.section]/100.0*paymentsAndCredits;
  1439. float totalprice=shipping+paymentsAndCredits+handling_fee_value+lift_gate+tax;
  1440. section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
  1441. int count=0;
  1442. count=[[section_json valueForKey:@"count"] intValue];
  1443. int total_row_idx=-1;
  1444. for(int i=0;i<count;i++)
  1445. {
  1446. NSDictionary * olditem=[[section_json objectForKey:[NSString stringWithFormat:@"item_%d",i ]] mutableCopy];
  1447. if([[olditem valueForKey:@"name"] isEqualToString:@"totalPrice" ])
  1448. {
  1449. [olditem setValue:[NSString stringWithFormat:@"%.2f",totalprice] forKey:@"value"];
  1450. [olditem setValue:@"true" forKey:@"dirty"];
  1451. [section_json setObject:olditem forKey:[NSString stringWithFormat:@"item_%d",i ]];
  1452. total_row_idx=i;
  1453. }
  1454. }
  1455. [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
  1456. self.content_data_control = [self translate_json:self.content_data_download changed: self.changed_data];
  1457. if(total_row_idx>=0)
  1458. {
  1459. NSUInteger newIndex[] = {indexPath.section, total_row_idx};
  1460. NSIndexPath *newPath = [[NSIndexPath alloc] initWithIndexes:newIndex length:2];
  1461. // DebugLog(@"before refresh %@",NSStringFromCGSize(self.editorTable.contentSize));
  1462. [self.editorTable reloadRowsAtIndexPaths:@[newPath]withRowAnimation:UITableViewRowAnimationMiddle];
  1463. // DebugLog(@"after refresh %@",NSStringFromCGSize(self.editorTable.contentSize));
  1464. // CGSize tablecontent =self.editorTable.contentSize;
  1465. // tablecontent.height=tablecontent.height+self.keyboard_h;
  1466. // self.editorTable.contentSize=tablecontent;
  1467. //
  1468. //
  1469. // DebugLog(@"resize to %@",NSStringFromCGSize(self.editorTable.contentSize));
  1470. }
  1471. // self.content_data = [editor_json mutableCopy];
  1472. // self.content_data = [self translate_json:editor_json];
  1473. // NSMutableDictionary* content_data1 = [self translate_json:self.content_data];
  1474. // [self.editorTable reloadData];
  1475. }
  1476. //
  1477. // [item_json setValue:@"true" forKey:@"dirty"];
  1478. // [item_json setValue:textField.text forKey:@"value"];
  1479. }
  1480. -(float) getprice:(NSString*) name section :(long) index
  1481. {
  1482. NSMutableDictionary* section_json=nil;
  1483. section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",index ]] mutableCopy];
  1484. int count=0;
  1485. count=[[section_json valueForKey:@"count"] intValue];
  1486. for(int i=0;i<count;i++)
  1487. {
  1488. NSDictionary * olditem=[[section_json objectForKey:[NSString stringWithFormat:@"item_%d",i ]] mutableCopy];
  1489. if([[olditem valueForKey:@"name"] isEqualToString:name])
  1490. {
  1491. return [[olditem valueForKey:@"value"] floatValue];
  1492. }
  1493. }
  1494. return 0;
  1495. }
  1496. /*
  1497. #pragma mark - Navigation
  1498. // In a storyboard-based application, you will often want to do a little preparation before navigation
  1499. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  1500. // Get the new view controller using [segue destinationViewController].
  1501. // Pass the selected object to the new view controller.
  1502. }
  1503. */
  1504. #pragma mark - UIAlertViewDelegate
  1505. // Called when a button is clicked. The view will be automatically dismissed after this call returns
  1506. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  1507. {
  1508. if(buttonIndex!=alertView.cancelButtonIndex && alertView.tag == SUBMIT_CONFIRM)
  1509. {
  1510. // add params check here.
  1511. [self.lastedit endEditing:true];
  1512. [self.lasttextview endEditing:true];
  1513. // self.cancommit=true;
  1514. // NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init];
  1515. // [upparams setValue:[self.params valueForKey:@"cart2Checkbox"] forKey:@"cart2Checkbox"];
  1516. // int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
  1517. // for(int i=0;i<section_count;i++)
  1518. // {
  1519. // NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
  1520. // int item_count = [[sectionjson valueForKey:@"count"] intValue];
  1521. // for(int j=0;j<item_count;j++)
  1522. // {
  1523. // NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
  1524. // NSString* key = [itemjson valueForKey:@"name"];
  1525. // if(key==nil || key.length==0)
  1526. // continue;
  1527. // if([[itemjson valueForKey:@"control"] isEqualToString:@"enum"])
  1528. // {
  1529. // NSString* single_select = [itemjson valueForKey:@"single_select"];
  1530. // if([single_select isEqualToString:@"true"])
  1531. // {
  1532. // NSDictionary* cadejson=[itemjson objectForKey:@"cadedate"];
  1533. // int count = [[cadejson valueForKey:@"count"] intValue];
  1534. // bool setvalue = false;
  1535. // for(int cc=0;cc<count;cc++)
  1536. // {
  1537. // NSDictionary* valjson=[cadejson objectForKey:[NSString stringWithFormat:@"val_%d",cc]];
  1538. // if([[valjson valueForKey:@"check"]intValue]==1)
  1539. // {
  1540. // [upparams setValue:[valjson valueForKey:@"value_id"] forKey:[itemjson valueForKey:@"name"]];
  1541. // setvalue=true;
  1542. // break;
  1543. // }
  1544. // }
  1545. // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
  1546. // {
  1547. // self.cancommit = false;
  1548. // }
  1549. // }
  1550. // else
  1551. // {
  1552. // //not support multi select for now;
  1553. // }
  1554. // /*
  1555. // upparams setValue:itemjson forKey:<#(NSString *)#>
  1556. //
  1557. // */
  1558. // }else
  1559. // if([[itemjson valueForKey:@"control"] isEqualToString:@"action"])
  1560. // {
  1561. // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"data"]==nil)
  1562. // self.cancommit = false;
  1563. // }
  1564. // else if([[itemjson valueForKey:@"control"] isEqualToString:@"signature"])
  1565. // {
  1566. // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"value"] ==nil)
  1567. // self.cancommit = false;
  1568. //
  1569. // NSString* valuestr = [itemjson valueForKey:@"value"];
  1570. // [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
  1571. // }
  1572. // else if([[itemjson valueForKey:@"control"] isEqualToString:@"switch"])
  1573. // {
  1574. // NSString* valuestr = [itemjson valueForKey:@"value"];
  1575. // [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
  1576. //
  1577. // NSString* value = [itemjson valueForKey:@"value"];
  1578. // NSMutableDictionary* boolitem=nil;
  1579. // NSMutableDictionary* subjson=nil;
  1580. // if([value isEqualToString:@"true"])
  1581. // {
  1582. // boolitem =[[itemjson objectForKey:@"true"] mutableCopy];
  1583. //
  1584. // }
  1585. // else
  1586. // {
  1587. // boolitem =[[itemjson objectForKey:@"false"] mutableCopy];
  1588. //
  1589. // }
  1590. // subjson=[[boolitem objectForKey:@"sub_item"] mutableCopy];
  1591. // if( subjson!=nil /*&& !active*/)
  1592. // {
  1593. // int sub_count = [[subjson valueForKey:@"count"] intValue];
  1594. // for(int l=0;l<sub_count;l++)
  1595. // {
  1596. // NSMutableDictionary * modify_item=[[subjson objectForKey:[NSString stringWithFormat:@"item_%d",l ]] mutableCopy];
  1597. //
  1598. //
  1599. //
  1600. //
  1601. // if([modify_item valueForKey:@"value"]!=nil && ![[modify_item valueForKey:@"value"]isEqualToString:@""])
  1602. // [upparams setValue:[modify_item valueForKey:@"value"] forKey:[modify_item valueForKey:@"name"]];
  1603. // else
  1604. // {
  1605. // if([[modify_item valueForKey:@"required"] isEqualToString: @"true"] )
  1606. // self.cancommit = false;
  1607. // }
  1608. // }
  1609. //
  1610. //
  1611. //
  1612. // }
  1613. // }
  1614. // else
  1615. // {
  1616. // if([itemjson valueForKey:@"value"]!=nil && ![[itemjson valueForKey:@"value"]isEqualToString:@""])
  1617. // [upparams setValue:[itemjson valueForKey:@"value"] forKey:[itemjson valueForKey:@"name"]];
  1618. // else
  1619. // {
  1620. // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
  1621. // self.cancommit = false;
  1622. // }
  1623. // }
  1624. // upparams= [self subitem_param:itemjson addto:upparams ];
  1625. // }
  1626. // }
  1627. // if(self.cancommit==false)
  1628. // {
  1629. // [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
  1630. // self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
  1631. // //DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
  1632. // //[self.editorTable reloadData ];
  1633. // [self.editorTable reloadData];
  1634. // // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1635. // return;
  1636. // }
  1637. NSMutableDictionary* upparams = [self check_cancommit:true];
  1638. if(self.cancommit==false)
  1639. return;
  1640. if(upparams[@"shipping"]==nil)
  1641. goto commit_order;
  1642. if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
  1643. {
  1644. upparams[@"shipping"] = nil;
  1645. goto commit_order;
  1646. }
  1647. else if([upparams[@"shipping"] doubleValue]==0)
  1648. {
  1649. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Shipping is $0.00, continue submit?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  1650. //block代码块取代了delegate
  1651. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action)
  1652. {
  1653. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1654. if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
  1655. {
  1656. if(/*!self.have_tail*/ true)
  1657. {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  1658. [upparams setValue:@"false" forKey:@"isHold"];
  1659. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1660. NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
  1661. dispatch_async(dispatch_get_main_queue(), ^{
  1662. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1663. if([[editor_json valueForKey:@"result"] intValue]==2)
  1664. {
  1665. // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  1666. // debug aaa
  1667. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1668. NSString* company= appDelegate.customerInfo[@"customer_name"];
  1669. NSString* send_to =appDelegate.customerInfo[@"customer_email"];
  1670. // appDelegate.customerInfo = customerInfo;
  1671. // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  1672. // appDelegate.order_code = nil;
  1673. [appDelegate closeOrder];
  1674. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  1675. NSString* title=nil;
  1676. NSString* msg=nil;
  1677. #ifdef OFFLINE_MODE
  1678. if(appDelegate.offline_mode)
  1679. {
  1680. title=TITLE_OFFLINE_SUBMIT;
  1681. msg=MSG_OFFLINE_SUBMIT;
  1682. }
  1683. else
  1684. #endif
  1685. {
  1686. title=@"Order submitted sucessfully";
  1687. msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  1688. }
  1689. UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  1690. [alert show];
  1691. NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
  1692. NSString* email_content =[editor_json valueForKey:@"email_content"];
  1693. NSString* soid=[editor_json valueForKey:@"so#"];
  1694. // if(pdf_url.length>0)
  1695. // {
  1696. //
  1697. // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  1698. // //[self downloadpdf:pdf_url];
  1699. //
  1700. //
  1701. // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  1702. // {
  1703. // //bbb
  1704. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  1705. // }
  1706. //
  1707. // [self prepareReturn:nil];
  1708. //
  1709. // [self.navigationController popViewControllerAnimated:true];
  1710. //
  1711. // [appDelegate printPdf:pdf_url];
  1712. //// if(self.printPdfCallback)
  1713. //// self.printPdfCallback(pdf_url);
  1714. // }
  1715. // else
  1716. {
  1717. if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
  1718. {
  1719. //bbb
  1720. [((MainViewController*)appDelegate.main_vc) Loginout:false];
  1721. }
  1722. [self prepareReturn:nil];
  1723. [self.navigationController popViewControllerAnimated:true];
  1724. if(pdf_url.length>0)
  1725. {
  1726. [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  1727. [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
  1728. // [appDelegate printPdf:pdf_url];
  1729. }
  1730. }
  1731. }
  1732. else
  1733. {
  1734. [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  1735. }
  1736. });
  1737. });
  1738. }
  1739. else
  1740. {
  1741. UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Retain models", nil) message:NSLocalizedString(@"There are some models left in cart,do you want to keep them?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
  1742. alert.tag = KEEP_TAIL;
  1743. self.upparams = upparams;
  1744. [alert show];
  1745. }
  1746. }
  1747. else
  1748. { //USER_ROLE_CUSTOMER
  1749. // if(self.have_tail)
  1750. // [upparams setValue:@"true" forKey:@"isHold"];
  1751. // else
  1752. // [upparams setValue:@"false" forKey:@"isHold"];
  1753. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  1754. [upparams setValue:@"true" forKey:@"isHold"];
  1755. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1756. NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
  1757. dispatch_async(dispatch_get_main_queue(), ^{
  1758. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1759. if([[editor_json valueForKey:@"result"] intValue]==2)
  1760. {
  1761. // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  1762. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1763. // appDelegate.customerInfo = customerInfo;
  1764. // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
  1765. // appDelegate.order_code = orderCode;
  1766. // appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
  1767. [appDelegate closeOrder];
  1768. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  1769. NSString* title=nil;
  1770. NSString* msg=nil;
  1771. #ifdef OFFLINE_MODE
  1772. if(appDelegate.offline_mode)
  1773. {
  1774. title=TITLE_OFFLINE_SUBMIT;
  1775. msg=MSG_OFFLINE_SUBMIT;
  1776. }
  1777. else
  1778. #endif
  1779. {
  1780. title=@"Order submitted sucessfully";
  1781. msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  1782. }
  1783. UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  1784. [alert show];
  1785. // // self.labelContact.text=appDelegate.contact_name;
  1786. //
  1787. // NSDictionary * customerinfo = appDelegate.customerInfo;
  1788. [self prepareReturn:nil];
  1789. [self.navigationController popViewControllerAnimated:true];
  1790. // [self.navigationController dismissViewControllerAnimated:true completion:^{
  1791. //
  1792. //
  1793. // ;
  1794. // }];
  1795. }
  1796. else
  1797. {
  1798. [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  1799. }
  1800. });
  1801. });
  1802. }
  1803. }];
  1804. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  1805. //DebugLog(@"Cancel");
  1806. }];
  1807. [alertControl addAction:actionOne];
  1808. [alertControl addAction:alertthree];
  1809. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  1810. [self presentViewController:alertControl animated:YES completion:nil];
  1811. }
  1812. else
  1813. {
  1814. commit_order:
  1815. {
  1816. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1817. if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
  1818. {
  1819. if(/*!self.have_tail*/ true)
  1820. {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  1821. [upparams setValue:@"false" forKey:@"isHold"];
  1822. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1823. NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
  1824. dispatch_async(dispatch_get_main_queue(), ^{
  1825. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1826. if([[editor_json valueForKey:@"result"] intValue]==2)
  1827. {
  1828. //debug bbb
  1829. // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  1830. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1831. NSString* company= appDelegate.customerInfo[@"customer_name"];
  1832. NSString* send_to =appDelegate.customerInfo[@"customer_email"];
  1833. // appDelegate.customerInfo = customerInfo;
  1834. // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  1835. // appDelegate.order_code = nil;
  1836. [appDelegate closeOrder];
  1837. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  1838. NSString* title=nil;
  1839. NSString* msg=nil;
  1840. #ifdef OFFLINE_MODE
  1841. if(appDelegate.offline_mode)
  1842. {
  1843. title=TITLE_OFFLINE_SUBMIT;
  1844. msg=MSG_OFFLINE_SUBMIT;
  1845. }
  1846. else
  1847. #endif
  1848. {
  1849. title=@"Order submitted sucessfully";
  1850. msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  1851. }
  1852. UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  1853. [alert show];
  1854. NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
  1855. NSString* email_content =[editor_json valueForKey:@"email_content"];
  1856. NSString* soid=[editor_json valueForKey:@"so#"];
  1857. // if(pdf_url.length>0)
  1858. // {
  1859. //
  1860. // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  1861. //// [self downloadpdf:pdf_url];
  1862. //
  1863. //
  1864. // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  1865. // {
  1866. // //bbb
  1867. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  1868. // }
  1869. //
  1870. // [self prepareReturn:nil];
  1871. //
  1872. // [self.navigationController popViewControllerAnimated:true];
  1873. //
  1874. // [appDelegate printPdf:pdf_url];
  1875. //
  1876. //// if(self.printPdfCallback)
  1877. //// self.printPdfCallback(pdf_url);
  1878. // }
  1879. // else
  1880. {
  1881. if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
  1882. {
  1883. //bbb
  1884. [((MainViewController*)appDelegate.main_vc) Loginout:false];
  1885. }
  1886. [self prepareReturn:nil];
  1887. [self.navigationController popViewControllerAnimated:true];
  1888. if(pdf_url.length>0)
  1889. {
  1890. [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  1891. [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
  1892. }
  1893. }
  1894. // // self.labelContact.text=appDelegate.contact_name;
  1895. //
  1896. // NSDictionary * customerinfo = appDelegate.customerInfo;
  1897. }
  1898. else
  1899. {
  1900. [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  1901. }
  1902. });
  1903. });
  1904. }
  1905. else
  1906. {
  1907. UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Retain models", nil) message:NSLocalizedString(@"There are some models left in cart,do you want to keep them?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
  1908. alert.tag = KEEP_TAIL;
  1909. self.upparams = upparams;
  1910. [alert show];
  1911. }
  1912. }
  1913. else
  1914. { //USER_ROLE_CUSTOMER
  1915. // if(self.have_tail)
  1916. // [upparams setValue:@"true" forKey:@"isHold"];
  1917. // else
  1918. // [upparams setValue:@"false" forKey:@"isHold"];
  1919. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  1920. [upparams setValue:@"true" forKey:@"isHold"];
  1921. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1922. NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
  1923. dispatch_async(dispatch_get_main_queue(), ^{
  1924. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1925. if([[editor_json valueForKey:@"result"] intValue]==2)
  1926. {
  1927. // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  1928. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1929. // appDelegate.customerInfo = customerInfo;
  1930. // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
  1931. // appDelegate.order_code = orderCode;
  1932. // appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
  1933. [appDelegate closeOrder];
  1934. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  1935. NSString* title=nil;
  1936. NSString* msg=nil;
  1937. #ifdef OFFLINE_MODE
  1938. if(appDelegate.offline_mode)
  1939. {
  1940. title=TITLE_OFFLINE_SUBMIT;
  1941. msg=MSG_OFFLINE_SUBMIT;
  1942. }
  1943. else
  1944. #endif
  1945. {
  1946. title=@"Order submitted sucessfully";
  1947. msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  1948. }
  1949. UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  1950. [alert show];
  1951. // // self.labelContact.text=appDelegate.contact_name;
  1952. //
  1953. // NSDictionary * customerinfo = appDelegate.customerInfo;
  1954. [self prepareReturn:nil];
  1955. // [self.navigationController dismissViewControllerAnimated:true completion:^{
  1956. //
  1957. //
  1958. // ;
  1959. // }];
  1960. [self.navigationController popViewControllerAnimated:true];
  1961. }
  1962. else
  1963. {
  1964. [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  1965. }
  1966. });
  1967. });
  1968. }
  1969. }
  1970. }
  1971. }
  1972. // else if( alertView.tag == KEEP_TAIL)
  1973. // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Submit Order"];
  1974. // if(buttonIndex!=alertView.cancelButtonIndex)
  1975. // {//keep tail;
  1976. //
  1977. // [self.upparams setValue:@"true" forKey:@"isHold"];
  1978. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1979. //
  1980. // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:self.upparams];
  1981. //
  1982. // dispatch_async(dispatch_get_main_queue(), ^{
  1983. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1984. //
  1985. //
  1986. // if([[editor_json valueForKey:@"result"] intValue]==2)
  1987. // {
  1988. // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  1989. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Submit successful." message:[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  1990. //
  1991. // [alert show];
  1992. //
  1993. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1994. // appDelegate.customerInfo = customerInfo;
  1995. // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  1996. // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
  1997. // appDelegate.order_code = orderCode;
  1998. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  1999. // // // self.labelContact.text=appDelegate.contact_name;
  2000. // //
  2001. // // NSDictionary * customerinfo = appDelegate.customerInfo;
  2002. // [self prepareReturn:nil];
  2003. //// [self.navigationController dismissViewControllerAnimated:true completion:^{
  2004. ////
  2005. ////
  2006. //// ;
  2007. //// }];
  2008. // [self.navigationController popViewControllerAnimated:true];
  2009. //
  2010. // }
  2011. // else
  2012. // {
  2013. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Submit Order" controller:self] ;
  2014. // }
  2015. //
  2016. //
  2017. //
  2018. //
  2019. // });
  2020. // });
  2021. // }
  2022. // else
  2023. // {// not keep tail;
  2024. // [self.upparams setValue:@"false" forKey:@"isHold"];
  2025. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2026. //
  2027. // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:self.upparams];
  2028. //
  2029. // dispatch_async(dispatch_get_main_queue(), ^{
  2030. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  2031. //
  2032. //
  2033. // if([[editor_json valueForKey:@"result"] intValue]==2)
  2034. // {
  2035. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  2036. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Submit successful." message:[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  2037. //
  2038. // [alert show];
  2039. //
  2040. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2041. // // appDelegate.customerInfo = customerInfo;
  2042. // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  2043. // // appDelegate.order_code = nil;
  2044. // [appDelegate closeOrder];
  2045. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  2046. // // // self.labelContact.text=appDelegate.contact_name;
  2047. // //
  2048. // // NSDictionary * customerinfo = appDelegate.customerInfo;
  2049. // [self prepareReturn:nil];
  2050. //// [self.navigationController dismissViewControllerAnimated:true completion:^{
  2051. ////
  2052. ////
  2053. //// ;
  2054. //// }];
  2055. // [self.navigationController popViewControllerAnimated:true];
  2056. //
  2057. // }
  2058. // else
  2059. // {
  2060. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Submit Order" controller:self] ;
  2061. // }
  2062. //
  2063. //
  2064. //
  2065. //
  2066. // });
  2067. // });
  2068. // }
  2069. // }
  2070. else if(alertView.tag == CLOSE_ACTION)
  2071. {
  2072. if(buttonIndex==1)
  2073. {
  2074. [self.navigationController popViewControllerAnimated:true];
  2075. // back to cart;
  2076. // [self.navigationController dismissViewControllerAnimated:true completion:^{
  2077. // ;
  2078. // }];
  2079. // if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
  2080. // appDelegate.order_code = nil;
  2081. //
  2082. // }
  2083. }
  2084. if(buttonIndex==2)
  2085. {
  2086. [self.navigationController popViewControllerAnimated:false];
  2087. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2088. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  2089. [((MainViewController*)appDelegate.main_vc) switchToOrder];
  2090. // back to cart;
  2091. // [self.navigationController dismissViewControllerAnimated:true completion:^{
  2092. // ;
  2093. // }];
  2094. // if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
  2095. // appDelegate.order_code = nil;
  2096. //
  2097. // }
  2098. }
  2099. else if(buttonIndex==3)
  2100. {
  2101. // close order;
  2102. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2103. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Release Order"];
  2104. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2105. NSDictionary* order_json = [iSalesNetwork release_Order:appDelegate.order_code withScreen:nil];
  2106. dispatch_async(dispatch_get_main_queue(), ^{
  2107. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  2108. if([[order_json valueForKey:@"result"] intValue]==2)
  2109. {
  2110. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2111. // appDelegate.order_code = nil;
  2112. [appDelegate closeOrder];
  2113. [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  2114. [((MainViewController*)appDelegate.main_vc) switchToHome];
  2115. if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
  2116. {
  2117. [((MainViewController*)appDelegate.main_vc) Loginout:false];
  2118. }
  2119. [self prepareReturn:nil];
  2120. [self.navigationController popViewControllerAnimated:true];
  2121. // [self.navigationController dismissViewControllerAnimated:true completion:^{
  2122. // ;
  2123. // }];
  2124. }
  2125. else
  2126. {
  2127. [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order"controller:self] ;
  2128. }
  2129. });
  2130. });
  2131. //
  2132. // }
  2133. }
  2134. }
  2135. }
  2136. //
  2137. //
  2138. //-(void) downloadpdf:(NSString* )url
  2139. //{
  2140. // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Printing..."];
  2141. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2142. //
  2143. //
  2144. // NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60*5];
  2145. //
  2146. // //设置请求方式为get
  2147. //
  2148. // [request setHTTPMethod:@"GET"];
  2149. //
  2150. // //添加用户会话id
  2151. //
  2152. // [request addValue:@"text/html" forHTTPHeaderField:@"Content-Type"];
  2153. //
  2154. // //连接发送请求
  2155. //
  2156. //
  2157. // NSHTTPURLResponse* urlResponse = nil;
  2158. //
  2159. // NSError *error = [[NSError alloc] init];
  2160. //
  2161. // NSData* content= [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
  2162. //
  2163. // // self.filename = [urlResponse suggestedFilename];
  2164. //
  2165. //
  2166. // dispatch_async(dispatch_get_main_queue(), ^{
  2167. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  2168. // // self.navigationItem.title = self.save_name;
  2169. // // UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
  2170. // // self.content=nil;
  2171. // if(content!=nil&&content.length>0)
  2172. // {
  2173. //
  2174. //
  2175. // [self startAirPrintWithData:content];
  2176. //
  2177. //
  2178. // }
  2179. // else
  2180. // {
  2181. // [RAUtils message_alert:nil title:@"Open PDF Failed" controller:self];
  2182. // // self.content = [self.url dataUsingEncoding:NSUTF8StringEncoding];
  2183. // }
  2184. //
  2185. // ;
  2186. // // DebugLog(@"%@",[[NSString alloc] initWithData:self.content encoding:NSASCIIStringEncoding]);
  2187. // //
  2188. //
  2189. //
  2190. // // [self.webView loadData:self.content MIMEType:urlResponse.MIMEType textEncodingName:nil baseURL:nil];
  2191. //
  2192. //
  2193. //
  2194. //
  2195. // });
  2196. // });
  2197. //}
  2198. //
  2199. //- (void)startAirPrintWithData:(id )data
  2200. //{
  2201. //
  2202. //
  2203. //
  2204. //
  2205. // UIPrintInteractionController* airPrinterController=[UIPrintInteractionController sharedPrintController];
  2206. // UIPrintInfo *printInfo = [UIPrintInfo printInfo];
  2207. // printInfo.outputType = UIPrintInfoOutputGeneral;
  2208. // printInfo.orientation = UIPrintInfoOrientationPortrait;
  2209. // printInfo.jobName = @"CoolVisitAirPrint";
  2210. // airPrinterController.printInfo = printInfo;
  2211. // airPrinterController.printingItem = data;
  2212. // airPrinterController.delegate = self;
  2213. //
  2214. //
  2215. // airPrinterController.showsNumberOfCopies=true;
  2216. // airPrinterController.showsPageRange = true;
  2217. // airPrinterController.showsPaperSelectionForLoadedPapers=true;
  2218. //
  2219. // void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
  2220. // if(completed && error)
  2221. // DebugLog(@"Printing failed due to error in domain %@ with error code %lu. Localized description: %@, and failure reason: %@", error.domain, (long)error.code, error.localizedDescription, error.localizedFailureReason);
  2222. // };
  2223. //
  2224. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2225. //
  2226. // UIPrinter *airPrinter = [UIPrinter printerWithURL:[NSURL URLWithString:appDelegate.printerURL] ];///*self.printer;*/
  2227. //
  2228. //
  2229. //
  2230. //
  2231. // [[UIPrinter printerWithURL:[NSURL URLWithString:appDelegate.printerURL]] contactPrinter:^(BOOL available)
  2232. // {
  2233. // if (available&& appDelegate.printerURL.length>0)
  2234. // {
  2235. //
  2236. // [airPrinterController printToPrinter:airPrinter completionHandler:completionHandler];
  2237. // DebugLog(@"AIRPRINTER AVAILABLE");
  2238. // }
  2239. // else
  2240. // {
  2241. //
  2242. // // [airPrinterController presentFromRect:CGRectMake(0, 0, 300, 500) inView:self.view animated:YES completionHandler:
  2243. // //
  2244. // //
  2245. // //
  2246. // // // [printPicker presentAnimated:YES completionHandler:
  2247. // // ^(UIPrintInteractionController *printerController, BOOL userDidSelect, NSError *error)
  2248. // // {
  2249. // // if (userDidSelect)
  2250. // // {
  2251. // // NSString* sid= printerController.printInfo.printerID;
  2252. // // UIPrintPaper*paper= printerController.printPaper;
  2253. // //
  2254. // // }
  2255. // // }];
  2256. //
  2257. //
  2258. // DebugLog(@"AIRPRINTER NOT AVAILABLE");
  2259. //
  2260. //
  2261. //
  2262. // if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1)
  2263. // {
  2264. // UIPrinterPickerController *printPicker = [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:nil];
  2265. // // [printPicker presentFromBarButtonItem:self.btnSubmitOrder animated:yes completionHandler:
  2266. //
  2267. //
  2268. //
  2269. // [ printPicker presentFromBarButtonItem:self.btnSubmitOrder animated:YES completionHandler:
  2270. //
  2271. //
  2272. // // [printPicker presentFromRect:CGRectMake(0, 0, 300, 500) inView:self.view animated:YES completionHandler:
  2273. //
  2274. //
  2275. //
  2276. // // [printPicker presentAnimated:YES completionHandler:
  2277. // ^(UIPrinterPickerController *printerPicker, BOOL userDidSelect, NSError *error)
  2278. // {
  2279. // if (userDidSelect)
  2280. // {
  2281. // //User selected the item in the UIPrinterPickerController and got the printer details.
  2282. //
  2283. // [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:printerPicker.selectedPrinter];
  2284. //
  2285. // //Here you will get the printer and printer details.ie,
  2286. // // printerPicker.selectedPrinter, printerPicker.selectedPrinter.displayName, printerPicker.selectedPrinter.URL etc. So you can display the printer name in your label text or button title.
  2287. //
  2288. //
  2289. //
  2290. //
  2291. // appDelegate.printerURL =printerPicker.selectedPrinter.URL.absoluteString;
  2292. //
  2293. // [self startAirPrintWithData:data];
  2294. //
  2295. // }
  2296. // else
  2297. // {
  2298. //
  2299. //
  2300. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2301. // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  2302. // {
  2303. //
  2304. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  2305. // }
  2306. // [self prepareReturn:nil];
  2307. //
  2308. // [self.navigationController popViewControllerAnimated:true];
  2309. // }
  2310. // }];
  2311. // }
  2312. // }
  2313. // }];
  2314. //
  2315. //
  2316. //
  2317. //}
  2318. //
  2319. //#pragma mark - UIPrintInteractionControllerDelegate
  2320. //- (UIPrintPaper *)printInteractionController:(UIPrintInteractionController *)printInteractionController choosePaper:(NSArray<UIPrintPaper *> *)paperList
  2321. //{
  2322. //
  2323. // ;
  2324. //
  2325. // // (int) width = 29700
  2326. // // Printing description of (*( (int *)0x7caa3a40)):
  2327. // // (int) height = 42000
  2328. // //设置纸张大小
  2329. //
  2330. //
  2331. // for(UIPrintPaper* paper in paperList)
  2332. // {
  2333. // if (CGSizeEqualToSize(paper.paperSize, CGSizeMake(612, 792)))
  2334. // return paper;
  2335. //
  2336. // }
  2337. // CGSize paperSize = CGSizeMake(612, 792);
  2338. // UIPrintPaper * p=[UIPrintPaper bestPaperForPageSize:paperSize withPapersFromArray:paperList];
  2339. // return p;
  2340. //}
  2341. //- (void)printInteractionControllerWillPresentPrinterOptions:(UIPrintInteractionController *)printInteractionController
  2342. //{
  2343. //
  2344. //}
  2345. //- (void)printInteractionControllerDidPresentPrinterOptions:(UIPrintInteractionController *)printInteractionController
  2346. //{
  2347. //
  2348. //}
  2349. //- (void)printInteractionControllerWillDismissPrinterOptions:(UIPrintInteractionController *)printInteractionController
  2350. //{
  2351. //
  2352. //}
  2353. //- (void)printInteractionControllerDidDismissPrinterOptions:(UIPrintInteractionController *)printInteractionController
  2354. //{
  2355. //
  2356. //}
  2357. //
  2358. //- (void)printInteractionControllerWillStartJob:(UIPrintInteractionController *)printInteractionController
  2359. //{
  2360. //
  2361. //}
  2362. //- (void)printInteractionControllerDidFinishJob:(UIPrintInteractionController *)printInteractionController
  2363. //{
  2364. //
  2365. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2366. // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  2367. // {
  2368. //
  2369. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  2370. // }
  2371. //
  2372. // [self prepareReturn:nil];
  2373. //
  2374. // [self.navigationController popViewControllerAnimated:true];
  2375. //}
  2376. //
  2377. //- (NSString *)currentPriceTypeName {
  2378. // NSInteger priceType = [Singleton sharedInstance].npd_shop_price_type;
  2379. //
  2380. // NSString* pricename = nil;
  2381. // switch (priceType) {
  2382. // case 0:
  2383. // pricename=[Singleton sharedInstance].deliveryString;
  2384. // break;
  2385. // case 1:
  2386. // pricename=flat_price;
  2387. // break;
  2388. // case 2:
  2389. // pricename=given_price;
  2390. // break;
  2391. // default:
  2392. // break;
  2393. // }
  2394. // return pricename;
  2395. //}
  2396. - (void)releaseOrderAfterSave {
  2397. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2398. [iSalesNetwork release_Order:appDelegate.order_code withScreen:nil];
  2399. [appDelegate closeOrder];
  2400. [appDelegate SetSo:nil];
  2401. appDelegate.cart_count=0;
  2402. [appDelegate update_count_mark];
  2403. [((MainViewController*)appDelegate.main_vc) switchToOrder];
  2404. [self prepareReturn:nil];
  2405. [self.navigationController popToRootViewControllerAnimated:false];
  2406. }
  2407. @end