RAOrderPreviewController.m 145 KB

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