CreateOrderViewController.m 194 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873
  1. //
  2. // CreateOrderViewController.m
  3. // RedAnt ERP Mobile
  4. //
  5. // Created by Ray on 8/24/15.
  6. // Copyright (c) 2015 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "CreateOrderViewController.h"
  9. #import "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. #define SUBMIT_CONFIRM 123
  18. #define KEEP_TAIL 456
  19. #define CLOSE_ACTION 567
  20. @interface CreateOrderViewController ()
  21. // static const char associatedkey;
  22. @property (nonatomic,assign) BOOL isResume;///<恢复
  23. @property (nonatomic,assign) NSInteger userType;///<恢复使用
  24. @end
  25. @implementation CreateOrderViewController
  26. - (void)alertMessage:(NSString *)msg {
  27. if (notifyMe_switch) {
  28. if ([self.class_name isEqualToString:@"CreateOrderViewController"]) {
  29. NSString *err_msg = msg;
  30. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Attention!!" message:err_msg preferredStyle:UIAlertControllerStyleAlert];
  31. __weak typeof(self) weakself = self;
  32. UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  33. [weakself.navigationController popViewControllerAnimated:YES];
  34. }];
  35. [alertVC addAction:action];
  36. [self presentViewController:alertVC animated:YES completion:nil];
  37. } else {
  38. [RAUtils message_alert:msg title:nil controller:self] ;
  39. }
  40. } else {
  41. [RAUtils message_alert:msg title:nil controller:self] ;
  42. }
  43. }
  44. -(void) commonAction:(NSString *)value index:(NSIndexPath*) indexPath data:(NSMutableDictionary*) item_json
  45. {
  46. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  47. if([value isEqualToString:@"new_addr"])
  48. {
  49. AddressEditorViewController * addressVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"AddressEditorViewController"];
  50. addressVC.url_type = URL_REMOTE;
  51. addressVC.request_url=URL_ADDRESS_EDOTOR;
  52. NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
  53. // NSString * string = [checked componentsJoinedByString:@","];
  54. // [params setValue:string forKey:@"cart2Checkbox"];
  55. addressVC.params = params;
  56. addressVC.delegate = self;
  57. addressVC.from = indexPath;
  58. // orderinfoVC.params = params;
  59. [self.navigationController pushViewController:addressVC animated:true];
  60. }else if([value isEqualToString:@"credit_card"])
  61. {
  62. CreditCardEditorViewController * cardVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"CreditCardEditorViewController"];
  63. NSDictionary *data = [item_json objectForKey:@"data"];
  64. if(data!=nil)
  65. {
  66. cardVC.content_data_download = [data mutableCopy];
  67. cardVC.url_type = URL_NONE;
  68. cardVC.request_url=nil;
  69. }
  70. else
  71. {
  72. cardVC.url_type = URL_REMOTE;
  73. cardVC.request_url=URL_CREDITCARD_EDOTOR;
  74. }
  75. NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
  76. params[@"orderCode"]=appDelegate.order_code;
  77. cardVC.params = params;
  78. cardVC.delegate = self;
  79. cardVC.from = indexPath;
  80. // orderinfoVC.params = params;
  81. [self.navigationController pushViewController:cardVC animated:true];
  82. }
  83. else if([value isEqualToString:@"Sales_Order_Freight_Bill_To"])
  84. {
  85. ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  86. cvc.showNavibar = true;
  87. cvc.contact_type = value;
  88. __weak typeof(self) weakself = self;
  89. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  90. [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  91. //
  92. // if(self.returnValue)
  93. // self.returnValue(value);
  94. };
  95. [self.navigationController pushViewController:cvc animated:true];
  96. }
  97. else if([value isEqualToString:@"Sales_Order_Ship_From"])
  98. {
  99. ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  100. cvc.showNavibar = true;
  101. cvc.contact_type = value;
  102. __weak typeof(self) weakself = self;
  103. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  104. [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  105. //
  106. // if(self.returnValue)
  107. // self.returnValue(value);
  108. };
  109. [self.navigationController pushViewController:cvc animated:true];
  110. }
  111. else if([value isEqualToString:@"Sales_Order_Customer"])
  112. {
  113. ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  114. cvc.contact_type = value;
  115. cvc.showNavibar = true;
  116. __weak typeof(self) weakself = self;
  117. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  118. [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  119. //
  120. // if(self.returnValue)
  121. // self.returnValue(value);
  122. };
  123. [self.navigationController pushViewController:cvc animated:true];
  124. }
  125. else if([value isEqualToString:@"Sales_Order_Merchandise_Bill_To"])
  126. {
  127. ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  128. cvc.showNavibar = true;
  129. cvc.contact_type = value;
  130. __weak typeof(self) weakself = self;
  131. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  132. [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  133. //
  134. // if(self.returnValue)
  135. // self.returnValue(value);
  136. };
  137. [self.navigationController pushViewController:cvc animated:true];
  138. }
  139. else if([value isEqualToString:@"Contact_Return_To"])
  140. {
  141. ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  142. cvc.showNavibar = true;
  143. cvc.contact_type = value;
  144. __weak typeof(self) weakself = self;
  145. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  146. [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  147. //
  148. // if(self.returnValue)
  149. // self.returnValue(value);
  150. };
  151. [self.navigationController pushViewController:cvc animated:true];
  152. }
  153. else if([value isEqualToString:@"Sales_Order_Ship_To"])
  154. {
  155. ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  156. cvc.showNavibar = true;
  157. cvc.contact_type = value;
  158. __weak typeof(self) weakself = self;
  159. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  160. [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  161. //
  162. // if(self.returnValue)
  163. // self.returnValue(value);
  164. };
  165. [self.navigationController pushViewController:cvc animated:true];
  166. }
  167. }
  168. - (void)dealloc {
  169. AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
  170. [appDelegate.urgencyDic removeObjectForKey:[NSString stringWithFormat:@"level_%d",self.level]];
  171. [appDelegate.urgencyDic setValue:[NSNumber numberWithInteger:self.level] forKey:@"count"];
  172. if (self.isResume && self.userType == USER_ROLE_CUSTOMER) {
  173. [self releaseOrderAfterSave];
  174. }
  175. }
  176. -(void) viewWillAppear:(BOOL)animated
  177. {
  178. [super viewWillAppear:animated];
  179. [self start_urgency_timer];
  180. self.isResume = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_resume"] boolValue];
  181. self.userType = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_userType"] integerValue];
  182. BOOL canSubmit = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_submitOrder"] boolValue];
  183. // 检查权限
  184. NSMutableArray * items = [[NSMutableArray alloc]init];
  185. UIBarButtonItem *savebtn = nil;
  186. savebtn = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"save"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  187. style:UIBarButtonItemStylePlain
  188. target:self
  189. action:@selector(onSaveClick:)];
  190. UIImage *submit_img = [[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic];
  191. #if defined(BUILD_NPD) || defined(BUILD_USAI) || defined(BUILD_UWAVER)
  192. submit_img = [[UIImage imageNamed:@"submit_red"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  193. #endif
  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. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  202. // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
  203. {
  204. [items addObject:savebtn];
  205. [items addObject:fixedItem];
  206. }
  207. if (!self.isResume) {
  208. // 正常情况
  209. if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
  210. // customer的订单必须是Sales Order并且有提交权限才能提交
  211. if ([Singleton sharedInstance].currentOrderIsMerged && [Singleton sharedInstance].permissions_submit_order) {
  212. [items addObject:self.btnSubmitOrder];
  213. }
  214. } else {
  215. [items addObject:self.btnSubmitOrder];
  216. }
  217. } else {
  218. // 恢复
  219. if (self.userType == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
  220. // customer的订单必须是Sales Order并且有提交权限才能提交
  221. if (canSubmit) {
  222. [items addObject:self.btnSubmitOrder];
  223. }
  224. } else {
  225. [items addObject:self.btnSubmitOrder];
  226. }
  227. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"urgency_resume"];
  228. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"urgency_userType"];
  229. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"urgency_submitOrder"];
  230. }
  231. // [items addObject:item2];
  232. self.navigationItem.rightBarButtonItems=items;
  233. if(appDelegate.can_submit_order)
  234. {
  235. [self.btnSubmitOrder setImage:submit_img];
  236. self.btnSubmitOrder.enabled = true;
  237. }
  238. else
  239. {
  240. [self.btnSubmitOrder setImage:nil];
  241. self.btnSubmitOrder.enabled = false;
  242. }
  243. self.navigationController.navigationBarHidden=false;
  244. }
  245. -(void) download_success
  246. {
  247. // 用于处理不同child,在成功去的数据后,需要附加的操作。
  248. self.have_tail=[[self.content_data_download valueForKey:@"has_reItem"] boolValue];
  249. NSString* order_customerid=[self getValue:@"customer_cid"];
  250. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  251. appDelegate.order_customer_id = order_customerid;
  252. }
  253. - (void)viewDidLoad {
  254. [super viewDidLoad];
  255. self.editable = YES;
  256. UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"close"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  257. style:UIBarButtonItemStylePlain
  258. target:self
  259. action:@selector(onCloseClick:)];
  260. //[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Close", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCloseClick:)];
  261. // closeButton.title = @"Close";
  262. self.navigationItem.leftBarButtonItem = closeButton;
  263. // self.navigationItem.backBarButtonItem = backButton;
  264. // Do any additional setup after loading the view.
  265. }
  266. - (void)onCommitOrderClick:(id)sender {
  267. // get customer info
  268. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  269. // if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
  270. //
  271. // // 检查价格类型
  272. // // 提货价才能提交订单
  273. // /** 价格类型
  274. // * 0 提货价
  275. // * 1 统一价
  276. // * 2 计算价
  277. // */
  278. // NSInteger priceType = [Singleton sharedInstance].npd_shop_price_type;
  279. // if (priceType != 0) {
  280. //
  281. // NSString* pricename = nil;
  282. // switch (priceType) {
  283. // case 1:
  284. // pricename=flat_price;
  285. // break;
  286. // case 2:
  287. // pricename=given_price;
  288. // break;
  289. // default:
  290. // break;
  291. // }
  292. //
  293. // UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:[NSString stringWithFormat:@"Current price is %@, please change to %@ and try again.",pricename,[Singleton sharedInstance].deliveryString] preferredStyle:UIAlertControllerStyleAlert];
  294. //
  295. // UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  296. //
  297. // [alertVC dismissViewControllerAnimated:YES completion:nil];
  298. //
  299. // }];
  300. //
  301. //
  302. // [alertVC addAction:cancelAction];
  303. //
  304. // [self presentViewController:alertVC animated:YES completion:nil];
  305. //
  306. // return;
  307. // }
  308. // }
  309. NSString* msg;
  310. #ifdef OFFLINE_MODE
  311. if(appDelegate.offline_mode)
  312. {
  313. msg=@"Are you sure to mark offline order as ready for submit?";
  314. }
  315. else
  316. #endif
  317. {
  318. msg=@"Submit order now?";
  319. // if(appDelegate.user_type == USER_ROLE_CUSTOMER) {
  320. //
  321. // NSString *specialInstuction = [Singleton sharedInstance].specialInstruction;
  322. // NSString * deliverprice=[Singleton sharedInstance].deliveryString;
  323. // msg = [NSString stringWithFormat:@"Are you sure to submit order?\n\n1. Your price type is %@, Order will sent to NPD with this price.",deliverprice];
  324. // if (specialInstuction.length) {
  325. // msg = [msg stringByAppendingFormat:@"\n2. Special Instruction: %@.",specialInstuction];
  326. // }
  327. //
  328. // }
  329. }
  330. // 2017-03-20 修改
  331. //
  332. // CustomIOSAlertView *alertView = [[CustomIOSAlertView alloc] init];
  333. //
  334. //
  335. //
  336. //
  337. // // Add some custom content to the alert view
  338. // [alertView setContainerView:[self createDemoView:msg]];
  339. //
  340. // // Modify the parameters
  341. //
  342. //
  343. // NSArray *titleArr = [NSMutableArray arrayWithObjects:@"NO",@"YES", nil];
  344. // [alertView setButtonTitles:titleArr];
  345. // //[alertView setDelegate:self];
  346. //
  347. // // You may use a Block, rather than a delegate.
  348. // [alertView setOnButtonTouchUpInside:^(CustomIOSAlertView *alertView, int buttonIndex) {
  349. // // DebugLog(@"Block: Button at position %d is clicked on alertView %d.", buttonIndex, (int)[alertView tag]);
  350. // if(buttonIndex==0)
  351. // [alertView close];
  352. // else
  353. // {
  354. // // add params check here.
  355. // [self.lastedit endEditing:true];
  356. // [self.lasttextview endEditing:true];
  357. //
  358. //
  359. //
  360. // // self.cancommit=true;
  361. // // NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init];
  362. // // [upparams setValue:[self.params valueForKey:@"cart2Checkbox"] forKey:@"cart2Checkbox"];
  363. // // int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
  364. // // for(int i=0;i<section_count;i++)
  365. // // {
  366. // // NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
  367. // // int item_count = [[sectionjson valueForKey:@"count"] intValue];
  368. // // for(int j=0;j<item_count;j++)
  369. // // {
  370. // // NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
  371. // // NSString* key = [itemjson valueForKey:@"name"];
  372. // // if(key==nil || key.length==0)
  373. // // continue;
  374. // // if([[itemjson valueForKey:@"control"] isEqualToString:@"enum"])
  375. // // {
  376. // // NSString* single_select = [itemjson valueForKey:@"single_select"];
  377. // // if([single_select isEqualToString:@"true"])
  378. // // {
  379. // // NSDictionary* cadejson=[itemjson objectForKey:@"cadedate"];
  380. // // int count = [[cadejson valueForKey:@"count"] intValue];
  381. // // bool setvalue = false;
  382. // // for(int cc=0;cc<count;cc++)
  383. // // {
  384. // // NSDictionary* valjson=[cadejson objectForKey:[NSString stringWithFormat:@"val_%d",cc]];
  385. // // if([[valjson valueForKey:@"check"]intValue]==1)
  386. // // {
  387. // // [upparams setValue:[valjson valueForKey:@"value_id"] forKey:[itemjson valueForKey:@"name"]];
  388. // // setvalue=true;
  389. // // break;
  390. // // }
  391. // // }
  392. // // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
  393. // // {
  394. // // self.cancommit = false;
  395. // // }
  396. // // }
  397. // // else
  398. // // {
  399. // // //not support multi select for now;
  400. // // }
  401. // // /*
  402. // // upparams setValue:itemjson forKey:<#(NSString *)#>
  403. // //
  404. // // */
  405. // // }else
  406. // // if([[itemjson valueForKey:@"control"] isEqualToString:@"action"])
  407. // // {
  408. // // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"data"]==nil)
  409. // // self.cancommit = false;
  410. // // }
  411. // // else if([[itemjson valueForKey:@"control"] isEqualToString:@"signature"])
  412. // // {
  413. // // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"value"] ==nil)
  414. // // self.cancommit = false;
  415. // //
  416. // // NSString* valuestr = [itemjson valueForKey:@"value"];
  417. // // [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
  418. // // }
  419. // // else if([[itemjson valueForKey:@"control"] isEqualToString:@"switch"])
  420. // // {
  421. // // NSString* valuestr = [itemjson valueForKey:@"value"];
  422. // // [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
  423. // //
  424. // // NSString* value = [itemjson valueForKey:@"value"];
  425. // // NSMutableDictionary* boolitem=nil;
  426. // // NSMutableDictionary* subjson=nil;
  427. // // if([value isEqualToString:@"true"])
  428. // // {
  429. // // boolitem =[[itemjson objectForKey:@"true"] mutableCopy];
  430. // //
  431. // // }
  432. // // else
  433. // // {
  434. // // boolitem =[[itemjson objectForKey:@"false"] mutableCopy];
  435. // //
  436. // // }
  437. // // subjson=[[boolitem objectForKey:@"sub_item"] mutableCopy];
  438. // // if( subjson!=nil /*&& !active*/)
  439. // // {
  440. // // int sub_count = [[subjson valueForKey:@"count"] intValue];
  441. // // for(int l=0;l<sub_count;l++)
  442. // // {
  443. // // NSMutableDictionary * modify_item=[[subjson objectForKey:[NSString stringWithFormat:@"item_%d",l ]] mutableCopy];
  444. // //
  445. // //
  446. // //
  447. // //
  448. // // if([modify_item valueForKey:@"value"]!=nil && ![[modify_item valueForKey:@"value"]isEqualToString:@""])
  449. // // [upparams setValue:[modify_item valueForKey:@"value"] forKey:[modify_item valueForKey:@"name"]];
  450. // // else
  451. // // {
  452. // // if([[modify_item valueForKey:@"required"] isEqualToString: @"true"] )
  453. // // self.cancommit = false;
  454. // // }
  455. // // }
  456. // //
  457. // //
  458. // //
  459. // // }
  460. // // }
  461. // // else
  462. // // {
  463. // // if([itemjson valueForKey:@"value"]!=nil && ![[itemjson valueForKey:@"value"]isEqualToString:@""])
  464. // // [upparams setValue:[itemjson valueForKey:@"value"] forKey:[itemjson valueForKey:@"name"]];
  465. // // else
  466. // // {
  467. // // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
  468. // // self.cancommit = false;
  469. // // }
  470. // // }
  471. // // upparams= [self subitem_param:itemjson addto:upparams ];
  472. // // }
  473. // // }
  474. // // if(self.cancommit==false)
  475. // // {
  476. // // [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
  477. // // self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
  478. // // //DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
  479. // // //[self.editorTable reloadData ];
  480. // // [self.editorTable reloadData];
  481. // // // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  482. // // return;
  483. // // }
  484. //
  485. // NSMutableDictionary* upparams = [self check_cancommit:true];
  486. // if(self.cancommit==false)
  487. // return;
  488. //
  489. // if(upparams[@"shipping"]==nil)
  490. // goto commit_order;
  491. // if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
  492. // {
  493. // upparams[@"shipping"] = nil;
  494. // goto commit_order;
  495. // }
  496. // else if([upparams[@"shipping"] doubleValue]==0)
  497. // {
  498. //
  499. //
  500. // UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Shipping is $0.00, continue submit?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  501. // //block代码块取代了delegate
  502. //
  503. //
  504. //
  505. // UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action)
  506. // {
  507. //
  508. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  509. //
  510. // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
  511. // {
  512. //
  513. // if(/*!self.have_tail*/ true)
  514. // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  515. // [upparams setValue:@"false" forKey:@"isHold"];
  516. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  517. //
  518. // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
  519. //
  520. // dispatch_async(dispatch_get_main_queue(), ^{
  521. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  522. //
  523. //
  524. // if([[editor_json valueForKey:@"result"] intValue]==2)
  525. // {
  526. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  527. //
  528. // // debug aaa
  529. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  530. // NSString* company= appDelegate.customerInfo[@"customer_name"];
  531. // NSString* send_to =appDelegate.customerInfo[@"customer_email"];
  532. //
  533. // // appDelegate.customerInfo = customerInfo;
  534. // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  535. // // appDelegate.order_code = nil;
  536. // [appDelegate closeOrder];
  537. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  538. //
  539. // NSString* title=nil;
  540. // NSString* msg=nil;
  541. // if(appDelegate.offline_mode)
  542. // {
  543. // title=TITLE_OFFLINE_SUBMIT;
  544. // msg=MSG_OFFLINE_SUBMIT;
  545. // }
  546. // else
  547. // {
  548. // title=@"Submit successful.";
  549. // msg=[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]];
  550. // }
  551. //
  552. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  553. //
  554. // [alert show];
  555. //
  556. // NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
  557. // NSString* email_content =[editor_json valueForKey:@"email_content"];
  558. // NSString* soid=[editor_json valueForKey:@"so#"];
  559. // // if(pdf_url.length>0)
  560. // // {
  561. // //
  562. // // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  563. // // //[self downloadpdf:pdf_url];
  564. // //
  565. // //
  566. // // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  567. // // {
  568. // // //bbb
  569. // // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  570. // // }
  571. // //
  572. // // [self prepareReturn:nil];
  573. // //
  574. // // [self.navigationController popViewControllerAnimated:true];
  575. // //
  576. // // [appDelegate printPdf:pdf_url];
  577. // //// if(self.printPdfCallback)
  578. // //// self.printPdfCallback(pdf_url);
  579. // // }
  580. // // else
  581. // {
  582. // if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
  583. // {
  584. // //bbb
  585. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  586. // }
  587. // [self prepareReturn:nil];
  588. //
  589. // [self.navigationController popViewControllerAnimated:true];
  590. //
  591. // if(pdf_url.length>0)
  592. // {
  593. //
  594. // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  595. // [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
  596. // // [appDelegate printPdf:pdf_url];
  597. //
  598. // }
  599. // }
  600. //
  601. // }
  602. // else
  603. // {
  604. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  605. // }
  606. //
  607. //
  608. //
  609. //
  610. // });
  611. // });
  612. // }
  613. // else
  614. // {
  615. // 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];
  616. //
  617. //
  618. // alert.tag = KEEP_TAIL;
  619. //
  620. //
  621. // self.upparams = upparams;
  622. //
  623. // [alert show];
  624. // }
  625. //
  626. // }
  627. // else
  628. // { //USER_ROLE_CUSTOMER
  629. //
  630. // // if(self.have_tail)
  631. // // [upparams setValue:@"true" forKey:@"isHold"];
  632. // // else
  633. // // [upparams setValue:@"false" forKey:@"isHold"];
  634. // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  635. //
  636. // [upparams setValue:@"true" forKey:@"isHold"];
  637. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  638. //
  639. // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
  640. //
  641. // dispatch_async(dispatch_get_main_queue(), ^{
  642. //
  643. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  644. //
  645. // if([[editor_json valueForKey:@"result"] intValue]==2)
  646. // {
  647. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  648. //
  649. //
  650. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  651. // // appDelegate.customerInfo = customerInfo;
  652. //
  653. // // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
  654. // // appDelegate.order_code = orderCode;
  655. // // appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
  656. // [appDelegate closeOrder];
  657. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  658. //
  659. // NSString* title=nil;
  660. // NSString* msg=nil;
  661. // if(appDelegate.offline_mode)
  662. // {
  663. // title=TITLE_OFFLINE_SUBMIT;
  664. // msg=MSG_OFFLINE_SUBMIT;
  665. // }
  666. // else
  667. // {
  668. // title=@"Submit successful.";
  669. // msg=[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]];
  670. // }
  671. //
  672. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  673. //
  674. // [alert show];
  675. // // // self.labelContact.text=appDelegate.contact_name;
  676. // //
  677. // // NSDictionary * customerinfo = appDelegate.customerInfo;
  678. // [self prepareReturn:nil];
  679. // [self.navigationController popViewControllerAnimated:true];
  680. // // [self.navigationController dismissViewControllerAnimated:true completion:^{
  681. // //
  682. // //
  683. // // ;
  684. // // }];
  685. //
  686. // }
  687. // else
  688. // {
  689. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  690. // }
  691. //
  692. //
  693. //
  694. //
  695. // });
  696. // });
  697. //
  698. // }
  699. //
  700. //
  701. //
  702. // }];
  703. //
  704. // UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  705. // //DebugLog(@"Cancel");
  706. //
  707. //
  708. // }];
  709. // [alertControl addAction:actionOne];
  710. //
  711. // [alertControl addAction:alertthree];
  712. //
  713. // //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  714. //
  715. //
  716. //
  717. //
  718. // [self presentViewController:alertControl animated:YES completion:nil];
  719. //
  720. //
  721. //
  722. // }
  723. // else
  724. // {
  725. // commit_order:
  726. //
  727. // {
  728. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  729. //
  730. // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
  731. // {
  732. //
  733. // if(/*!self.have_tail*/ true)
  734. // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  735. // [upparams setValue:@"false" forKey:@"isHold"];
  736. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  737. //
  738. // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
  739. //
  740. // dispatch_async(dispatch_get_main_queue(), ^{
  741. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  742. //
  743. //
  744. // if([[editor_json valueForKey:@"result"] intValue]==2)
  745. // {
  746. //
  747. // //debug bbb
  748. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  749. //
  750. //
  751. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  752. // NSString* company= appDelegate.customerInfo[@"customer_name"];
  753. // NSString* send_to =appDelegate.customerInfo[@"customer_email"];
  754. // // appDelegate.customerInfo = customerInfo;
  755. // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  756. // // appDelegate.order_code = nil;
  757. // [appDelegate closeOrder];
  758. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  759. //
  760. // NSString* title=nil;
  761. // NSString* msg=nil;
  762. // if(appDelegate.offline_mode)
  763. // {
  764. // title=TITLE_OFFLINE_SUBMIT;
  765. // msg=MSG_OFFLINE_SUBMIT;
  766. // }
  767. // else
  768. // {
  769. // title=@"Submit successful.";
  770. // msg=[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]];
  771. // }
  772. //
  773. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  774. //
  775. // [alert show];
  776. //
  777. // NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
  778. // NSString* email_content =[editor_json valueForKey:@"email_content"];
  779. // NSString* soid=[editor_json valueForKey:@"so#"];
  780. // // if(pdf_url.length>0)
  781. // // {
  782. // //
  783. // // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  784. // //// [self downloadpdf:pdf_url];
  785. // //
  786. // //
  787. // // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  788. // // {
  789. // // //bbb
  790. // // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  791. // // }
  792. // //
  793. // // [self prepareReturn:nil];
  794. // //
  795. // // [self.navigationController popViewControllerAnimated:true];
  796. // //
  797. // // [appDelegate printPdf:pdf_url];
  798. // //
  799. // //// if(self.printPdfCallback)
  800. // //// self.printPdfCallback(pdf_url);
  801. // // }
  802. // // else
  803. // {
  804. // if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
  805. // {
  806. // //bbb
  807. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  808. // }
  809. // [self prepareReturn:nil];
  810. //
  811. // [self.navigationController popViewControllerAnimated:true];
  812. //
  813. //
  814. // if(pdf_url.length>0)
  815. // {
  816. //
  817. // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  818. //
  819. // [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
  820. //
  821. //
  822. // }
  823. //
  824. //
  825. // }
  826. // // // self.labelContact.text=appDelegate.contact_name;
  827. // //
  828. // // NSDictionary * customerinfo = appDelegate.customerInfo;
  829. //
  830. //
  831. //
  832. //
  833. //
  834. //
  835. // }
  836. // else
  837. // {
  838. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  839. // }
  840. //
  841. //
  842. //
  843. //
  844. // });
  845. // });
  846. // }
  847. // else
  848. // {
  849. // 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];
  850. //
  851. //
  852. // alert.tag = KEEP_TAIL;
  853. //
  854. //
  855. // self.upparams = upparams;
  856. //
  857. // [alert show];
  858. // }
  859. //
  860. // }
  861. // else
  862. // { //USER_ROLE_CUSTOMER
  863. //
  864. // // if(self.have_tail)
  865. // // [upparams setValue:@"true" forKey:@"isHold"];
  866. // // else
  867. // // [upparams setValue:@"false" forKey:@"isHold"];
  868. // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  869. //
  870. // [upparams setValue:@"true" forKey:@"isHold"];
  871. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  872. //
  873. // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
  874. //
  875. // dispatch_async(dispatch_get_main_queue(), ^{
  876. //
  877. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  878. //
  879. // if([[editor_json valueForKey:@"result"] intValue]==2)
  880. // {
  881. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  882. //
  883. //
  884. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  885. // // appDelegate.customerInfo = customerInfo;
  886. //
  887. // // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
  888. // // appDelegate.order_code = orderCode;
  889. // // appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
  890. // [appDelegate closeOrder];
  891. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  892. //
  893. // NSString* title=nil;
  894. // NSString* msg=nil;
  895. // if(appDelegate.offline_mode)
  896. // {
  897. // title=TITLE_OFFLINE_SUBMIT;
  898. // msg=MSG_OFFLINE_SUBMIT;
  899. // }
  900. // else
  901. // {
  902. // title=@"Submit successful.";
  903. // msg=[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]];
  904. // }
  905. //
  906. //
  907. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  908. //
  909. // [alert show];
  910. // // // self.labelContact.text=appDelegate.contact_name;
  911. // //
  912. // // NSDictionary * customerinfo = appDelegate.customerInfo;
  913. // [self prepareReturn:nil];
  914. // // [self.navigationController dismissViewControllerAnimated:true completion:^{
  915. // //
  916. // //
  917. // // ;
  918. // // }];
  919. // [self.navigationController popViewControllerAnimated:true];
  920. //
  921. // }
  922. // else
  923. // {
  924. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  925. // }
  926. //
  927. //
  928. //
  929. //
  930. // });
  931. // });
  932. //
  933. // }
  934. // }
  935. //
  936. //
  937. //
  938. //
  939. // }
  940. //
  941. //
  942. //
  943. //
  944. //
  945. //
  946. //
  947. //
  948. //
  949. //
  950. //
  951. // }
  952. // }];
  953. //
  954. // // [alertView setUseMotionEffects:true];
  955. //
  956. //
  957. // // And launch the dialog
  958. //
  959. // [alertView sizeToFit];
  960. // [alertView show];
  961. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Submit Confirm.", nil) message:NSLocalizedString(msg, nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
  962. //
  963. // alert.tag = SUBMIT_CONFIRM;
  964. // [alert show];
  965. //
  966. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Order Submission" message:msg preferredStyle:UIAlertControllerStyleAlert];
  967. UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"YES" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  968. {
  969. // add params check here.
  970. [self.lastedit endEditing:true];
  971. [self.lasttextview endEditing:true];
  972. NSMutableDictionary* upparams = [self check_cancommit:true];
  973. if(self.cancommit==false)
  974. return;
  975. // 2018-1-2 Modify
  976. if(appDelegate.user_type == USER_ROLE_CUSTOMER)
  977. {
  978. [self customer_commit_order:upparams];
  979. }
  980. else // USER_ROLE_EMPLOYEE
  981. {
  982. if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
  983. {
  984. upparams[@"shipping"] = nil;
  985. }
  986. if(upparams[@"shipping"]==nil || [upparams[@"shipping"] doubleValue]!=0)
  987. [self empolyee_commit_order:upparams];
  988. else
  989. {
  990. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Shipping is $0.00, continue submit?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  991. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action)
  992. {
  993. //yes
  994. [self empolyee_commit_order:upparams];
  995. }];
  996. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  997. //DebugLog(@"Cancel");
  998. }];
  999. [alertControl addAction:actionOne];
  1000. [alertControl addAction:alertthree];
  1001. [self presentViewController:alertControl animated:YES completion:nil];
  1002. }
  1003. }
  1004. // if(upparams[@"shipping"]==nil)
  1005. // goto commit_order;
  1006. // if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
  1007. // {
  1008. // upparams[@"shipping"] = nil;
  1009. // goto commit_order;
  1010. // }
  1011. // else if([upparams[@"shipping"] doubleValue]==0)
  1012. // {
  1013. //
  1014. //
  1015. // UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Shipping is $0.00, continue submit?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  1016. // //block代码块取代了delegate
  1017. //
  1018. //
  1019. //
  1020. // UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action)
  1021. // {
  1022. //
  1023. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1024. //
  1025. // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
  1026. // {
  1027. //
  1028. // if(/*!self.have_tail*/ true)
  1029. // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  1030. // [upparams setValue:@"false" forKey:@"isHold"];
  1031. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1032. //
  1033. // NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
  1034. //
  1035. // dispatch_async(dispatch_get_main_queue(), ^{
  1036. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1037. //
  1038. //
  1039. // if([[editor_json valueForKey:@"result"] intValue]==2)
  1040. // {
  1041. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  1042. //
  1043. // // debug aaa
  1044. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1045. // NSString* company= appDelegate.customerInfo[@"customer_name"];
  1046. // NSString* send_to =appDelegate.customerInfo[@"customer_email"];
  1047. //
  1048. // // appDelegate.customerInfo = customerInfo;
  1049. // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  1050. // // appDelegate.order_code = nil;
  1051. // [appDelegate closeOrder];
  1052. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  1053. //
  1054. // NSString* title=nil;
  1055. // NSString* msg=nil;
  1056. //#ifdef OFFLINE_MODE
  1057. // if(appDelegate.offline_mode)
  1058. // {
  1059. // title=TITLE_OFFLINE_SUBMIT;
  1060. // msg=MSG_OFFLINE_SUBMIT;
  1061. // }
  1062. // else
  1063. //#endif
  1064. // {
  1065. // title=@"Order submitted sucessfully";
  1066. // msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  1067. // }
  1068. //
  1069. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  1070. //
  1071. // [alert show];
  1072. //
  1073. // NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
  1074. // NSString* email_content =[editor_json valueForKey:@"email_content"];
  1075. // NSString* soid=[editor_json valueForKey:@"so#"];
  1076. // // if(pdf_url.length>0)
  1077. // // {
  1078. // //
  1079. // // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  1080. // // //[self downloadpdf:pdf_url];
  1081. // //
  1082. // //
  1083. // // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  1084. // // {
  1085. // // //bbb
  1086. // // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  1087. // // }
  1088. // //
  1089. // // [self prepareReturn:nil];
  1090. // //
  1091. // // [self.navigationController popViewControllerAnimated:true];
  1092. // //
  1093. // // [appDelegate printPdf:pdf_url];
  1094. // //// if(self.printPdfCallback)
  1095. // //// self.printPdfCallback(pdf_url);
  1096. // // }
  1097. // // else
  1098. // {
  1099. // if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
  1100. // {
  1101. // //bbb
  1102. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  1103. // }
  1104. // [self prepareReturn:nil];
  1105. //
  1106. // [self.navigationController popViewControllerAnimated:true];
  1107. //
  1108. // if(pdf_url.length>0)
  1109. // {
  1110. //
  1111. // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  1112. // [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
  1113. // // [appDelegate printPdf:pdf_url];
  1114. //
  1115. // }
  1116. // }
  1117. //
  1118. // }
  1119. // else
  1120. // {
  1121. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  1122. // }
  1123. //
  1124. //
  1125. //
  1126. //
  1127. // });
  1128. // });
  1129. // }
  1130. // else
  1131. // {
  1132. // 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];
  1133. //
  1134. //
  1135. // alert.tag = KEEP_TAIL;
  1136. //
  1137. //
  1138. // self.upparams = upparams;
  1139. //
  1140. // [alert show];
  1141. // }
  1142. //
  1143. // }
  1144. // else
  1145. // { //USER_ROLE_CUSTOMER
  1146. //
  1147. // // if(self.have_tail)
  1148. // // [upparams setValue:@"true" forKey:@"isHold"];
  1149. // // else
  1150. // // [upparams setValue:@"false" forKey:@"isHold"];
  1151. // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  1152. //
  1153. // [upparams setValue:@"true" forKey:@"isHold"];
  1154. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1155. //
  1156. // NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
  1157. //
  1158. // dispatch_async(dispatch_get_main_queue(), ^{
  1159. //
  1160. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1161. //
  1162. // if([[editor_json valueForKey:@"result"] intValue]==2)
  1163. // {
  1164. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  1165. //
  1166. //
  1167. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1168. // // appDelegate.customerInfo = customerInfo;
  1169. //
  1170. // // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
  1171. // // appDelegate.order_code = orderCode;
  1172. // // appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
  1173. // [appDelegate closeOrder];
  1174. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  1175. //
  1176. // NSString* title=nil;
  1177. // NSString* msg=nil;
  1178. //#ifdef OFFLINE_MODE
  1179. // if(appDelegate.offline_mode)
  1180. // {
  1181. // title=TITLE_OFFLINE_SUBMIT;
  1182. // msg=MSG_OFFLINE_SUBMIT;
  1183. // }
  1184. // else
  1185. //#endif
  1186. // {
  1187. // title=@"Order submitted sucessfully";
  1188. // msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  1189. // }
  1190. //
  1191. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  1192. //
  1193. // [alert show];
  1194. // // // self.labelContact.text=appDelegate.contact_name;
  1195. // //
  1196. // // NSDictionary * customerinfo = appDelegate.customerInfo;
  1197. // [self prepareReturn:nil];
  1198. // [self.navigationController popViewControllerAnimated:true];
  1199. // // [self.navigationController dismissViewControllerAnimated:true completion:^{
  1200. // //
  1201. // //
  1202. // // ;
  1203. // // }];
  1204. //
  1205. // }
  1206. // else
  1207. // {
  1208. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  1209. // }
  1210. //
  1211. //
  1212. //
  1213. //
  1214. // });
  1215. // });
  1216. //
  1217. // }
  1218. //
  1219. //
  1220. //
  1221. // }];
  1222. //
  1223. // UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  1224. // //DebugLog(@"Cancel");
  1225. //
  1226. //
  1227. // }];
  1228. // [alertControl addAction:actionOne];
  1229. //
  1230. // [alertControl addAction:alertthree];
  1231. //
  1232. // //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  1233. //
  1234. //
  1235. //
  1236. //
  1237. // [self presentViewController:alertControl animated:YES completion:nil];
  1238. //
  1239. //
  1240. //
  1241. // }
  1242. // else
  1243. // {
  1244. // commit_order:
  1245. //
  1246. // {
  1247. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1248. //
  1249. // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
  1250. // {
  1251. //
  1252. // if(/*!self.have_tail*/ true)
  1253. // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  1254. // [upparams setValue:@"false" forKey:@"isHold"];
  1255. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1256. //
  1257. // NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
  1258. //
  1259. // dispatch_async(dispatch_get_main_queue(), ^{
  1260. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1261. //
  1262. //
  1263. // if([[editor_json valueForKey:@"result"] intValue]==2)
  1264. // {
  1265. //
  1266. // //debug bbb
  1267. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  1268. //
  1269. //
  1270. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1271. // NSString* company= appDelegate.customerInfo[@"customer_name"];
  1272. // NSString* send_to =appDelegate.customerInfo[@"customer_email"];
  1273. // // appDelegate.customerInfo = customerInfo;
  1274. // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  1275. // // appDelegate.order_code = nil;
  1276. // [appDelegate closeOrder];
  1277. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  1278. //
  1279. // NSString* title=nil;
  1280. // NSString* msg=nil;
  1281. //#ifdef OFFLINE_MODE
  1282. // if(appDelegate.offline_mode)
  1283. // {
  1284. // title=TITLE_OFFLINE_SUBMIT;
  1285. // msg=MSG_OFFLINE_SUBMIT;
  1286. // }
  1287. // else
  1288. //#endif
  1289. // {
  1290. // title=@"Order submitted sucessfully";
  1291. // msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  1292. // }
  1293. //
  1294. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  1295. //
  1296. // [alert show];
  1297. //
  1298. // NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
  1299. // NSString* email_content =[editor_json valueForKey:@"email_content"];
  1300. // NSString* soid=[editor_json valueForKey:@"so#"];
  1301. // // if(pdf_url.length>0)
  1302. // // {
  1303. // //
  1304. // // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  1305. // //// [self downloadpdf:pdf_url];
  1306. // //
  1307. // //
  1308. // // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  1309. // // {
  1310. // // //bbb
  1311. // // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  1312. // // }
  1313. // //
  1314. // // [self prepareReturn:nil];
  1315. // //
  1316. // // [self.navigationController popViewControllerAnimated:true];
  1317. // //
  1318. // // [appDelegate printPdf:pdf_url];
  1319. // //
  1320. // //// if(self.printPdfCallback)
  1321. // //// self.printPdfCallback(pdf_url);
  1322. // // }
  1323. // // else
  1324. // {
  1325. // NSMutableDictionary* value=[[NSMutableDictionary alloc]init];
  1326. // if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
  1327. // {
  1328. // //bbb
  1329. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  1330. // value[@"commitorder_logout"]=@"true";
  1331. // }
  1332. //
  1333. //
  1334. // value[@"is_subaction"] = self.params[@"is_subaction"];
  1335. // value[@"subaction_tag"] = self.params[@"subaction_tag"];
  1336. //
  1337. // [self prepareReturn:value];
  1338. //
  1339. // [self.navigationController popViewControllerAnimated:true];
  1340. //
  1341. //
  1342. // if(pdf_url.length>0)
  1343. // {
  1344. //
  1345. // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  1346. //
  1347. // [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
  1348. //
  1349. //
  1350. // }
  1351. //
  1352. //
  1353. // }
  1354. // // // self.labelContact.text=appDelegate.contact_name;
  1355. // //
  1356. // // NSDictionary * customerinfo = appDelegate.customerInfo;
  1357. //
  1358. //
  1359. //
  1360. //
  1361. //
  1362. //
  1363. // }
  1364. // else
  1365. // {
  1366. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  1367. // }
  1368. //
  1369. //
  1370. //
  1371. //
  1372. // });
  1373. // });
  1374. // }
  1375. // else
  1376. // {
  1377. // 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];
  1378. //
  1379. //
  1380. // alert.tag = KEEP_TAIL;
  1381. //
  1382. //
  1383. // self.upparams = upparams;
  1384. //
  1385. // [alert show];
  1386. // }
  1387. //
  1388. // }
  1389. // else
  1390. // { //USER_ROLE_CUSTOMER
  1391. //
  1392. // // if(self.have_tail)
  1393. // // [upparams setValue:@"true" forKey:@"isHold"];
  1394. // // else
  1395. // // [upparams setValue:@"false" forKey:@"isHold"];
  1396. // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  1397. //
  1398. // [upparams setValue:@"true" forKey:@"isHold"];
  1399. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1400. //
  1401. // NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
  1402. //
  1403. // dispatch_async(dispatch_get_main_queue(), ^{
  1404. //
  1405. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1406. //
  1407. // if([[editor_json valueForKey:@"result"] intValue]==2)
  1408. // {
  1409. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  1410. //
  1411. //
  1412. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1413. // // appDelegate.customerInfo = customerInfo;
  1414. //
  1415. // // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
  1416. // // appDelegate.order_code = orderCode;
  1417. // // appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
  1418. // [appDelegate closeOrder];
  1419. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  1420. //
  1421. // NSString* title=nil;
  1422. // NSString* msg=nil;
  1423. //#ifdef OFFLINE_MODE
  1424. // if(appDelegate.offline_mode)
  1425. // {
  1426. // title=TITLE_OFFLINE_SUBMIT;
  1427. // msg=MSG_OFFLINE_SUBMIT;
  1428. // }
  1429. // else
  1430. //#endif
  1431. // {
  1432. // title=@"Order submitted sucessfully";
  1433. // msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  1434. // }
  1435. //
  1436. //
  1437. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  1438. //
  1439. // [alert show];
  1440. // // // self.labelContact.text=appDelegate.contact_name;
  1441. // //
  1442. // // NSDictionary * customerinfo = appDelegate.customerInfo;
  1443. // [self prepareReturn:nil];
  1444. // // [self.navigationController dismissViewControllerAnimated:true completion:^{
  1445. // //
  1446. // //
  1447. // // ;
  1448. // // }];
  1449. // [self.navigationController popViewControllerAnimated:true];
  1450. //
  1451. // }
  1452. // else
  1453. // {
  1454. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  1455. // }
  1456. //
  1457. //
  1458. //
  1459. //
  1460. // });
  1461. // });
  1462. //
  1463. // }
  1464. // }
  1465. //
  1466. //
  1467. //
  1468. //
  1469. // }
  1470. }
  1471. }];
  1472. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"NO" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  1473. }];
  1474. [alertVC addAction:yesAction];
  1475. [alertVC addAction:cancelAction];
  1476. [self presentViewController:alertVC animated:yesAction completion:nil];
  1477. }
  1478. - (UIView *)createDemoView:(NSString*) msg
  1479. {
  1480. UIView *demoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 290, 200)];
  1481. // UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 270, 180)];
  1482. // [imageView setImage:[UIImage imageNamed:@"demo"]];
  1483. UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 270, 10)];
  1484. titleLabel.font = [UIFont boldSystemFontOfSize:20];
  1485. titleLabel.text=@"Order Submission";
  1486. titleLabel.numberOfLines = 0;
  1487. titleLabel.lineBreakMode =NSLineBreakByWordWrapping;
  1488. // titleLabel.textAlignment = NSTextAlignmentRight;
  1489. titleLabel.textAlignment = NSTextAlignmentCenter;
  1490. CGSize constraintkey = CGSizeMake(270, 20000.0f);//key label width is 40% cell width;
  1491. CGSize sizetitle = [titleLabel.text=@"Order Submission" sizeWithFont:[UIFont systemFontOfSize:20.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
  1492. //[titleLabel sizeToFit];
  1493. // titleLabel.center.x = demoView.center.x;
  1494. titleLabel.frame = CGRectMake(10, 10, 270, sizetitle.height);
  1495. [demoView addSubview:titleLabel];
  1496. UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 260, 10)];
  1497. lineLabel.font = [UIFont systemFontOfSize:17];
  1498. lineLabel.text=msg;
  1499. lineLabel.numberOfLines = 0;
  1500. lineLabel.lineBreakMode =NSLineBreakByWordWrapping;
  1501. CGSize sizemsg = [msg sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
  1502. lineLabel.frame = CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 260, sizemsg.height);
  1503. //[lineLabel sizeToFit];
  1504. [demoView addSubview:lineLabel];
  1505. demoView.frame = CGRectMake(0, 0, 290, lineLabel.frame.origin.y+lineLabel.frame.size.height+25);
  1506. return demoView;
  1507. }
  1508. - (void)onCloseClick:(UIButton *)sender {
  1509. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1510. if (self.resumeOrder) {
  1511. [appDelegate.main_vc.navigationController popViewControllerAnimated:YES];
  1512. return;
  1513. }
  1514. //
  1515. // NSRange range = [tempStr rangeOfString:@")\">"];//判断字符串是否包含
  1516. //
  1517. // //if (range.location ==NSNotFound)//不包含
  1518. // if (range.length >0)//包含
  1519. // {
  1520. //
  1521. //
  1522. //
  1523. // }
  1524. // else//不包含
  1525. // {
  1526. //
  1527. // }
  1528. UIAlertView * alert = nil;
  1529. if(appDelegate.order_status==0)
  1530. {
  1531. alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Choose your action", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Switch to cart", nil),@"Switch to order history",NSLocalizedString(@"Close and cancel order", nil), nil];
  1532. }
  1533. else
  1534. {
  1535. alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Choose your action", nil) message:NSLocalizedString(@"", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", nil) otherButtonTitles:NSLocalizedString(@"Switch to cart", nil),@"Switch to order history",NSLocalizedString(@"Close and release order", nil), nil];
  1536. }
  1537. alert.tag = CLOSE_ACTION;
  1538. // alert.
  1539. [alert show];
  1540. // if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
  1541. // appDelegate.order_code = nil;
  1542. //
  1543. // }
  1544. }
  1545. - (void)didReceiveMemoryWarning {
  1546. [super didReceiveMemoryWarning];
  1547. // Dispose of any resources that can be recreated.
  1548. }
  1549. - (IBAction)onSaveClick:(id)sender {
  1550. // id foo = nil;
  1551. // [[NSMutableArray array] addObject:foo];
  1552. // add params check here.
  1553. [self.lastedit endEditing:true];
  1554. [self.lasttextview endEditing:true];
  1555. // self.cancommit=true;
  1556. // NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init];
  1557. // [upparams setValue:[self.params valueForKey:@"cart2Checkbox"] forKey:@"cart2Checkbox"];
  1558. // int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
  1559. // for(int i=0;i<section_count;i++)
  1560. // {
  1561. // NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
  1562. // int item_count = [[sectionjson valueForKey:@"count"] intValue];
  1563. // for(int j=0;j<item_count;j++)
  1564. // {
  1565. // NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
  1566. // NSString* key = [itemjson valueForKey:@"name"];
  1567. // if(key==nil || key.length==0)
  1568. // continue;
  1569. // if([[itemjson valueForKey:@"control"] isEqualToString:@"enum"])
  1570. // {
  1571. // NSString* single_select = [itemjson valueForKey:@"single_select"];
  1572. // if([single_select isEqualToString:@"true"])
  1573. // {
  1574. // NSDictionary* cadejson=[itemjson objectForKey:@"cadedate"];
  1575. // int count = [[cadejson valueForKey:@"count"] intValue];
  1576. // bool setvalue = false;
  1577. // for(int cc=0;cc<count;cc++)
  1578. // {
  1579. // NSDictionary* valjson=[cadejson objectForKey:[NSString stringWithFormat:@"val_%d",cc]];
  1580. // if([[valjson valueForKey:@"check"]intValue]==1)
  1581. // {
  1582. // [upparams setValue:[valjson valueForKey:@"value_id"] forKey:[itemjson valueForKey:@"name"]];
  1583. // setvalue=true;
  1584. // break;
  1585. // }
  1586. // }
  1587. // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
  1588. // {
  1589. // self.cancommit = false;
  1590. // }
  1591. // }
  1592. // else
  1593. // {
  1594. // //not support multi select for now;
  1595. // }
  1596. // /*
  1597. // upparams setValue:itemjson forKey:<#(NSString *)#>
  1598. //
  1599. // */
  1600. // }else
  1601. // if([[itemjson valueForKey:@"control"] isEqualToString:@"action"])
  1602. // {
  1603. // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"data"]==nil)
  1604. // self.cancommit = false;
  1605. // }
  1606. // else if([[itemjson valueForKey:@"control"] isEqualToString:@"signature"])
  1607. // {
  1608. // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"value"]==nil)
  1609. // self.cancommit = false;
  1610. //
  1611. // NSString* valuestr = [itemjson valueForKey:@"value"];
  1612. // [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
  1613. // }
  1614. // else if([[itemjson valueForKey:@"control"] isEqualToString:@"switch"])
  1615. // {
  1616. // NSString* valuestr = [itemjson valueForKey:@"value"];
  1617. // [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
  1618. //
  1619. // NSString* value = [itemjson valueForKey:@"value"];
  1620. // NSMutableDictionary* boolitem=nil;
  1621. // NSMutableDictionary* subjson=nil;
  1622. // if([value isEqualToString:@"true"])
  1623. // {
  1624. // boolitem =[[itemjson objectForKey:@"true"] mutableCopy];
  1625. //
  1626. // }
  1627. // else
  1628. // {
  1629. // boolitem =[[itemjson objectForKey:@"false"] mutableCopy];
  1630. //
  1631. // }
  1632. // subjson=[[boolitem objectForKey:@"sub_item"] mutableCopy];
  1633. // if( subjson!=nil /*&& !active*/)
  1634. // {
  1635. // int sub_count = [[subjson valueForKey:@"count"] intValue];
  1636. // for(int l=0;l<sub_count;l++)
  1637. // {
  1638. // NSMutableDictionary * modify_item=[[subjson objectForKey:[NSString stringWithFormat:@"item_%d",l ]] mutableCopy];
  1639. //
  1640. //
  1641. //
  1642. //
  1643. // if([modify_item valueForKey:@"value"]!=nil && ![[modify_item valueForKey:@"value"]isEqualToString:@""])
  1644. // [upparams setValue:[modify_item valueForKey:@"value"] forKey:[modify_item valueForKey:@"name"]];
  1645. // else
  1646. // {
  1647. // if([[modify_item valueForKey:@"required"] isEqualToString: @"true"] )
  1648. // self.cancommit = false;
  1649. // }
  1650. // }
  1651. //
  1652. //
  1653. //
  1654. // }
  1655. // }
  1656. // else
  1657. // {
  1658. // if([itemjson valueForKey:@"value"]!=nil && ![[itemjson valueForKey:@"value"]isEqualToString:@""])
  1659. // [upparams setValue:[itemjson valueForKey:@"value"] forKey:[itemjson valueForKey:@"name"]];
  1660. // else
  1661. // {
  1662. // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
  1663. // self.cancommit = false;
  1664. // }
  1665. // }
  1666. // upparams= [self subitem_param:itemjson addto:upparams ];
  1667. // }
  1668. // }
  1669. // // save order 不检查必填项;
  1670. // self.cancommit=true;
  1671. // if(self.cancommit==false)
  1672. // {
  1673. // [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
  1674. // self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
  1675. // //DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
  1676. // //[self.editorTable reloadData ];
  1677. // [self.editorTable reloadData];
  1678. // return;
  1679. // }
  1680. NSMutableDictionary* upparams = [self check_cancommit:false];
  1681. // if(self.cancommit==false)
  1682. // return;
  1683. if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
  1684. upparams[@"shipping"] = nil;
  1685. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Saving Order"];
  1686. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1687. NSDictionary* editor_json = [RANetwork save_Order:upparams];
  1688. dispatch_async(dispatch_get_main_queue(), ^{
  1689. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1690. if([[editor_json valueForKey:@"result"] intValue]==2)
  1691. {
  1692. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1693. NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  1694. if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
  1695. {
  1696. appDelegate.customerInfo = customerInfo;
  1697. appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  1698. }
  1699. NSString *msg = nil;
  1700. if ([editor_json objectForKey:@"so#"]) {
  1701. msg = [@"SO#:" stringByAppendingString:[editor_json objectForKey:@"so#"]];
  1702. }
  1703. [RAUtils message_alert:msg title:@"Order Saved" controller:self] ;
  1704. if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.save_order_logout && appDelegate.user_type ==USER_ROLE_EMPLOYEE)
  1705. {
  1706. [((MainViewController*)appDelegate.main_vc) Loginout:false];
  1707. [self prepareReturn:nil];
  1708. [self.navigationController popViewControllerAnimated:true];
  1709. }
  1710. if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
  1711. if (![Singleton sharedInstance].currentOrderIsMerged) {
  1712. [self releaseOrderAfterSave];
  1713. }
  1714. }
  1715. // if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
  1716. // appDelegate.order_code = nil;
  1717. //
  1718. // }
  1719. // // self.labelContact.text=appDelegate.contact_name;
  1720. //
  1721. // NSDictionary * customerinfo = appDelegate.customerInfo;
  1722. // [self prepareReturn:nil];
  1723. // [self.navigationController dismissViewControllerAnimated:true completion:^{
  1724. //
  1725. //
  1726. // ;
  1727. // }];
  1728. }
  1729. else
  1730. {
  1731. [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:self] ;
  1732. }
  1733. });
  1734. });
  1735. }
  1736. - (void)textFieldDidEndEditing:(UITextField *)textField
  1737. {
  1738. [super textFieldDidEndEditing:textField];
  1739. UITableViewCell *cell = (UITableViewCell *) textField.superview.superview;
  1740. NSIndexPath * indexPath = [self.editorTable indexPathForCell:cell];
  1741. NSMutableDictionary* section_json=nil;
  1742. // DebugLog(@"endedit %d_%d",indexPath.section,indexPath.row);
  1743. NSMutableDictionary* item_json =[((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row] mutableCopy];
  1744. NSString* name = [item_json valueForKey:@"name"];
  1745. if([name isEqualToString:@"shipping"]|| [name isEqualToString:@"handling_fee_value"]||[name isEqualToString:@"lift_gate_value"]||[name isEqualToString:@"tax_percentage"])
  1746. {
  1747. float shipping = [self getprice:@"shipping" section:indexPath.section];
  1748. float paymentsAndCredits = [self getprice:@"paymentsAndCredits" section:indexPath.section];
  1749. float handling_fee_value = [self getprice:@"handling_fee_value" section:indexPath.section];
  1750. float lift_gate =[self getprice:@"lift_gate_value" section:indexPath.section];
  1751. float tax = [self getprice:@"tax_percentage" section:indexPath.section]/100.0*paymentsAndCredits;
  1752. float totalprice=shipping+paymentsAndCredits+handling_fee_value+lift_gate+tax;
  1753. section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
  1754. int count=0;
  1755. count=[[section_json valueForKey:@"count"] intValue];
  1756. int total_row_idx=-1;
  1757. for(int i=0;i<count;i++)
  1758. {
  1759. NSDictionary * olditem=[[section_json objectForKey:[NSString stringWithFormat:@"item_%d",i ]] mutableCopy];
  1760. if([[olditem valueForKey:@"name"] isEqualToString:@"totalPrice" ])
  1761. {
  1762. [olditem setValue:[NSString stringWithFormat:@"%.2f",totalprice] forKey:@"value"];
  1763. [olditem setValue:@"true" forKey:@"dirty"];
  1764. [section_json setObject:olditem forKey:[NSString stringWithFormat:@"item_%d",i ]];
  1765. total_row_idx=i;
  1766. }
  1767. }
  1768. [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
  1769. self.content_data_control = [self translate_json:self.content_data_download changed: self.changed_data];
  1770. if(total_row_idx>=0)
  1771. {
  1772. NSUInteger newIndex[] = {indexPath.section, total_row_idx};
  1773. NSIndexPath *newPath = [[NSIndexPath alloc] initWithIndexes:newIndex length:2];
  1774. // DebugLog(@"before refresh %@",NSStringFromCGSize(self.editorTable.contentSize));
  1775. [self.editorTable reloadRowsAtIndexPaths:@[newPath]withRowAnimation:UITableViewRowAnimationMiddle];
  1776. // DebugLog(@"after refresh %@",NSStringFromCGSize(self.editorTable.contentSize));
  1777. // CGSize tablecontent =self.editorTable.contentSize;
  1778. // tablecontent.height=tablecontent.height+self.keyboard_h;
  1779. // self.editorTable.contentSize=tablecontent;
  1780. //
  1781. //
  1782. // DebugLog(@"resize to %@",NSStringFromCGSize(self.editorTable.contentSize));
  1783. }
  1784. // self.content_data = [editor_json mutableCopy];
  1785. // self.content_data = [self translate_json:editor_json];
  1786. // NSMutableDictionary* content_data1 = [self translate_json:self.content_data];
  1787. // [self.editorTable reloadData];
  1788. }
  1789. //
  1790. // [item_json setValue:@"true" forKey:@"dirty"];
  1791. // [item_json setValue:textField.text forKey:@"value"];
  1792. }
  1793. -(float) getprice:(NSString*) name section :(long) index
  1794. {
  1795. NSMutableDictionary* section_json=nil;
  1796. section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",index ]] mutableCopy];
  1797. int count=0;
  1798. count=[[section_json valueForKey:@"count"] intValue];
  1799. for(int i=0;i<count;i++)
  1800. {
  1801. NSDictionary * olditem=[[section_json objectForKey:[NSString stringWithFormat:@"item_%d",i ]] mutableCopy];
  1802. if([[olditem valueForKey:@"name"] isEqualToString:name])
  1803. {
  1804. return [[olditem valueForKey:@"value"] floatValue];
  1805. }
  1806. }
  1807. return 0;
  1808. }
  1809. /*
  1810. #pragma mark - Navigation
  1811. // In a storyboard-based application, you will often want to do a little preparation before navigation
  1812. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  1813. // Get the new view controller using [segue destinationViewController].
  1814. // Pass the selected object to the new view controller.
  1815. }
  1816. */
  1817. #pragma mark - UIAlertViewDelegate
  1818. // Called when a button is clicked. The view will be automatically dismissed after this call returns
  1819. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  1820. {
  1821. if(buttonIndex!=alertView.cancelButtonIndex && alertView.tag == SUBMIT_CONFIRM)
  1822. {
  1823. // // add params check here.
  1824. // [self.lastedit endEditing:true];
  1825. // [self.lasttextview endEditing:true];
  1826. //
  1827. //
  1828. //
  1829. //// self.cancommit=true;
  1830. //// NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init];
  1831. //// [upparams setValue:[self.params valueForKey:@"cart2Checkbox"] forKey:@"cart2Checkbox"];
  1832. //// int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
  1833. //// for(int i=0;i<section_count;i++)
  1834. //// {
  1835. //// NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
  1836. //// int item_count = [[sectionjson valueForKey:@"count"] intValue];
  1837. //// for(int j=0;j<item_count;j++)
  1838. //// {
  1839. //// NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
  1840. //// NSString* key = [itemjson valueForKey:@"name"];
  1841. //// if(key==nil || key.length==0)
  1842. //// continue;
  1843. //// if([[itemjson valueForKey:@"control"] isEqualToString:@"enum"])
  1844. //// {
  1845. //// NSString* single_select = [itemjson valueForKey:@"single_select"];
  1846. //// if([single_select isEqualToString:@"true"])
  1847. //// {
  1848. //// NSDictionary* cadejson=[itemjson objectForKey:@"cadedate"];
  1849. //// int count = [[cadejson valueForKey:@"count"] intValue];
  1850. //// bool setvalue = false;
  1851. //// for(int cc=0;cc<count;cc++)
  1852. //// {
  1853. //// NSDictionary* valjson=[cadejson objectForKey:[NSString stringWithFormat:@"val_%d",cc]];
  1854. //// if([[valjson valueForKey:@"check"]intValue]==1)
  1855. //// {
  1856. //// [upparams setValue:[valjson valueForKey:@"value_id"] forKey:[itemjson valueForKey:@"name"]];
  1857. //// setvalue=true;
  1858. //// break;
  1859. //// }
  1860. //// }
  1861. //// if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
  1862. //// {
  1863. //// self.cancommit = false;
  1864. //// }
  1865. //// }
  1866. //// else
  1867. //// {
  1868. //// //not support multi select for now;
  1869. //// }
  1870. //// /*
  1871. //// upparams setValue:itemjson forKey:<#(NSString *)#>
  1872. ////
  1873. //// */
  1874. //// }else
  1875. //// if([[itemjson valueForKey:@"control"] isEqualToString:@"action"])
  1876. //// {
  1877. //// if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"data"]==nil)
  1878. //// self.cancommit = false;
  1879. //// }
  1880. //// else if([[itemjson valueForKey:@"control"] isEqualToString:@"signature"])
  1881. //// {
  1882. //// if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"value"] ==nil)
  1883. //// self.cancommit = false;
  1884. ////
  1885. //// NSString* valuestr = [itemjson valueForKey:@"value"];
  1886. //// [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
  1887. //// }
  1888. //// else if([[itemjson valueForKey:@"control"] isEqualToString:@"switch"])
  1889. //// {
  1890. //// NSString* valuestr = [itemjson valueForKey:@"value"];
  1891. //// [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
  1892. ////
  1893. //// NSString* value = [itemjson valueForKey:@"value"];
  1894. //// NSMutableDictionary* boolitem=nil;
  1895. //// NSMutableDictionary* subjson=nil;
  1896. //// if([value isEqualToString:@"true"])
  1897. //// {
  1898. //// boolitem =[[itemjson objectForKey:@"true"] mutableCopy];
  1899. ////
  1900. //// }
  1901. //// else
  1902. //// {
  1903. //// boolitem =[[itemjson objectForKey:@"false"] mutableCopy];
  1904. ////
  1905. //// }
  1906. //// subjson=[[boolitem objectForKey:@"sub_item"] mutableCopy];
  1907. //// if( subjson!=nil /*&& !active*/)
  1908. //// {
  1909. //// int sub_count = [[subjson valueForKey:@"count"] intValue];
  1910. //// for(int l=0;l<sub_count;l++)
  1911. //// {
  1912. //// NSMutableDictionary * modify_item=[[subjson objectForKey:[NSString stringWithFormat:@"item_%d",l ]] mutableCopy];
  1913. ////
  1914. ////
  1915. ////
  1916. ////
  1917. //// if([modify_item valueForKey:@"value"]!=nil && ![[modify_item valueForKey:@"value"]isEqualToString:@""])
  1918. //// [upparams setValue:[modify_item valueForKey:@"value"] forKey:[modify_item valueForKey:@"name"]];
  1919. //// else
  1920. //// {
  1921. //// if([[modify_item valueForKey:@"required"] isEqualToString: @"true"] )
  1922. //// self.cancommit = false;
  1923. //// }
  1924. //// }
  1925. ////
  1926. ////
  1927. ////
  1928. //// }
  1929. //// }
  1930. //// else
  1931. //// {
  1932. //// if([itemjson valueForKey:@"value"]!=nil && ![[itemjson valueForKey:@"value"]isEqualToString:@""])
  1933. //// [upparams setValue:[itemjson valueForKey:@"value"] forKey:[itemjson valueForKey:@"name"]];
  1934. //// else
  1935. //// {
  1936. //// if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
  1937. //// self.cancommit = false;
  1938. //// }
  1939. //// }
  1940. //// upparams= [self subitem_param:itemjson addto:upparams ];
  1941. //// }
  1942. //// }
  1943. //// if(self.cancommit==false)
  1944. //// {
  1945. //// [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
  1946. //// self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
  1947. //// //DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
  1948. //// //[self.editorTable reloadData ];
  1949. //// [self.editorTable reloadData];
  1950. //// // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1951. //// return;
  1952. //// }
  1953. //
  1954. // NSMutableDictionary* upparams = [self check_cancommit:true];
  1955. // if(self.cancommit==false)
  1956. // return;
  1957. //
  1958. // if(upparams[@"shipping"]==nil)
  1959. // goto commit_order;
  1960. // if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
  1961. // {
  1962. // upparams[@"shipping"] = nil;
  1963. // goto commit_order;
  1964. // }
  1965. // else if([upparams[@"shipping"] doubleValue]==0)
  1966. // {
  1967. //
  1968. //
  1969. // UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Shipping is $0.00, continue submit?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  1970. // //block代码块取代了delegate
  1971. //
  1972. //
  1973. //
  1974. // UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action)
  1975. // {
  1976. //
  1977. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1978. //
  1979. // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
  1980. // {
  1981. //
  1982. // if(/*!self.have_tail*/ true)
  1983. // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  1984. // [upparams setValue:@"false" forKey:@"isHold"];
  1985. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  1986. //
  1987. // NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
  1988. //
  1989. // dispatch_async(dispatch_get_main_queue(), ^{
  1990. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  1991. //
  1992. //
  1993. // if([[editor_json valueForKey:@"result"] intValue]==2)
  1994. // {
  1995. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  1996. //
  1997. // // debug aaa
  1998. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1999. // NSString* company= appDelegate.customerInfo[@"customer_name"];
  2000. // NSString* send_to =appDelegate.customerInfo[@"customer_email"];
  2001. //
  2002. // // appDelegate.customerInfo = customerInfo;
  2003. // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  2004. // // appDelegate.order_code = nil;
  2005. // [appDelegate closeOrder];
  2006. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  2007. //
  2008. // NSString* title=nil;
  2009. // NSString* msg=nil;
  2010. //#ifdef OFFLINE_MODE
  2011. // if(appDelegate.offline_mode)
  2012. // {
  2013. // title=TITLE_OFFLINE_SUBMIT;
  2014. // msg=MSG_OFFLINE_SUBMIT;
  2015. // }
  2016. // else
  2017. //#endif
  2018. // {
  2019. // title=@"Order submitted sucessfully";
  2020. // msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  2021. // }
  2022. //
  2023. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  2024. //
  2025. // [alert show];
  2026. //
  2027. // NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
  2028. // NSString* email_content =[editor_json valueForKey:@"email_content"];
  2029. // NSString* soid=[editor_json valueForKey:@"so#"];
  2030. //// if(pdf_url.length>0)
  2031. //// {
  2032. ////
  2033. //// [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  2034. //// //[self downloadpdf:pdf_url];
  2035. ////
  2036. ////
  2037. //// if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  2038. //// {
  2039. //// //bbb
  2040. //// [((MainViewController*)appDelegate.main_vc) Loginout:false];
  2041. //// }
  2042. ////
  2043. //// [self prepareReturn:nil];
  2044. ////
  2045. //// [self.navigationController popViewControllerAnimated:true];
  2046. ////
  2047. //// [appDelegate printPdf:pdf_url];
  2048. ////// if(self.printPdfCallback)
  2049. ////// self.printPdfCallback(pdf_url);
  2050. //// }
  2051. //// else
  2052. // {
  2053. // if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
  2054. // {
  2055. // //bbb
  2056. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  2057. // }
  2058. // [self prepareReturn:nil];
  2059. //
  2060. // [self.navigationController popViewControllerAnimated:true];
  2061. //
  2062. // if(pdf_url.length>0)
  2063. // {
  2064. //
  2065. // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  2066. // [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
  2067. // // [appDelegate printPdf:pdf_url];
  2068. //
  2069. // }
  2070. // }
  2071. //
  2072. // }
  2073. // else
  2074. // {
  2075. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  2076. // }
  2077. //
  2078. //
  2079. //
  2080. //
  2081. // });
  2082. // });
  2083. // }
  2084. // else
  2085. // {
  2086. // 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];
  2087. //
  2088. //
  2089. // alert.tag = KEEP_TAIL;
  2090. //
  2091. //
  2092. // self.upparams = upparams;
  2093. //
  2094. // [alert show];
  2095. // }
  2096. //
  2097. // }
  2098. // else
  2099. // { //USER_ROLE_CUSTOMER
  2100. //
  2101. // // if(self.have_tail)
  2102. // // [upparams setValue:@"true" forKey:@"isHold"];
  2103. // // else
  2104. // // [upparams setValue:@"false" forKey:@"isHold"];
  2105. // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  2106. //
  2107. // [upparams setValue:@"true" forKey:@"isHold"];
  2108. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2109. //
  2110. // NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
  2111. //
  2112. // dispatch_async(dispatch_get_main_queue(), ^{
  2113. //
  2114. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  2115. //
  2116. // if([[editor_json valueForKey:@"result"] intValue]==2)
  2117. // {
  2118. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  2119. //
  2120. //
  2121. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2122. // // appDelegate.customerInfo = customerInfo;
  2123. //
  2124. //// NSString* orderCode = [editor_json valueForKey:@"orderCode"];
  2125. //// appDelegate.order_code = orderCode;
  2126. //// appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
  2127. // [appDelegate closeOrder];
  2128. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  2129. //
  2130. // NSString* title=nil;
  2131. // NSString* msg=nil;
  2132. //#ifdef OFFLINE_MODE
  2133. // if(appDelegate.offline_mode)
  2134. // {
  2135. // title=TITLE_OFFLINE_SUBMIT;
  2136. // msg=MSG_OFFLINE_SUBMIT;
  2137. // }
  2138. // else
  2139. //#endif
  2140. // {
  2141. // title=@"Order submitted sucessfully";
  2142. // msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  2143. // }
  2144. //
  2145. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  2146. //
  2147. // [alert show];
  2148. // // // self.labelContact.text=appDelegate.contact_name;
  2149. // //
  2150. // // NSDictionary * customerinfo = appDelegate.customerInfo;
  2151. // [self prepareReturn:nil];
  2152. // [self.navigationController popViewControllerAnimated:true];
  2153. // // [self.navigationController dismissViewControllerAnimated:true completion:^{
  2154. // //
  2155. // //
  2156. // // ;
  2157. // // }];
  2158. //
  2159. // }
  2160. // else
  2161. // {
  2162. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  2163. // }
  2164. //
  2165. //
  2166. //
  2167. //
  2168. // });
  2169. // });
  2170. //
  2171. // }
  2172. //
  2173. //
  2174. //
  2175. // }];
  2176. //
  2177. // UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  2178. // //DebugLog(@"Cancel");
  2179. //
  2180. //
  2181. // }];
  2182. // [alertControl addAction:actionOne];
  2183. //
  2184. // [alertControl addAction:alertthree];
  2185. //
  2186. // //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  2187. //
  2188. //
  2189. //
  2190. //
  2191. // [self presentViewController:alertControl animated:YES completion:nil];
  2192. //
  2193. //
  2194. //
  2195. // }
  2196. // else
  2197. // {
  2198. // commit_order:
  2199. //
  2200. // {
  2201. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2202. //
  2203. // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
  2204. // {
  2205. //
  2206. // if(/*!self.have_tail*/ true)
  2207. // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  2208. // [upparams setValue:@"false" forKey:@"isHold"];
  2209. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2210. //
  2211. // NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
  2212. //
  2213. // dispatch_async(dispatch_get_main_queue(), ^{
  2214. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  2215. //
  2216. //
  2217. // if([[editor_json valueForKey:@"result"] intValue]==2)
  2218. // {
  2219. //
  2220. // //debug bbb
  2221. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  2222. //
  2223. //
  2224. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2225. // NSString* company= appDelegate.customerInfo[@"customer_name"];
  2226. // NSString* send_to =appDelegate.customerInfo[@"customer_email"];
  2227. // // appDelegate.customerInfo = customerInfo;
  2228. // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  2229. // // appDelegate.order_code = nil;
  2230. // [appDelegate closeOrder];
  2231. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  2232. //
  2233. // NSString* title=nil;
  2234. // NSString* msg=nil;
  2235. //#ifdef OFFLINE_MODE
  2236. // if(appDelegate.offline_mode)
  2237. // {
  2238. // title=TITLE_OFFLINE_SUBMIT;
  2239. // msg=MSG_OFFLINE_SUBMIT;
  2240. // }
  2241. // else
  2242. //#endif
  2243. // {
  2244. // title=@"Order submitted sucessfully";
  2245. // msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  2246. // }
  2247. //
  2248. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  2249. //
  2250. // [alert show];
  2251. //
  2252. // NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
  2253. // NSString* email_content =[editor_json valueForKey:@"email_content"];
  2254. // NSString* soid=[editor_json valueForKey:@"so#"];
  2255. //// if(pdf_url.length>0)
  2256. //// {
  2257. ////
  2258. //// [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  2259. ////// [self downloadpdf:pdf_url];
  2260. ////
  2261. ////
  2262. //// if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  2263. //// {
  2264. //// //bbb
  2265. //// [((MainViewController*)appDelegate.main_vc) Loginout:false];
  2266. //// }
  2267. ////
  2268. //// [self prepareReturn:nil];
  2269. ////
  2270. //// [self.navigationController popViewControllerAnimated:true];
  2271. ////
  2272. //// [appDelegate printPdf:pdf_url];
  2273. ////
  2274. ////// if(self.printPdfCallback)
  2275. ////// self.printPdfCallback(pdf_url);
  2276. //// }
  2277. //// else
  2278. // {
  2279. // if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
  2280. // {
  2281. // //bbb
  2282. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  2283. // }
  2284. // [self prepareReturn:nil];
  2285. //
  2286. // [self.navigationController popViewControllerAnimated:true];
  2287. //
  2288. //
  2289. // if(pdf_url.length>0)
  2290. // {
  2291. //
  2292. // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  2293. //
  2294. // [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
  2295. //
  2296. //
  2297. // }
  2298. //
  2299. //
  2300. // }
  2301. // // // self.labelContact.text=appDelegate.contact_name;
  2302. // //
  2303. // // NSDictionary * customerinfo = appDelegate.customerInfo;
  2304. //
  2305. //
  2306. //
  2307. //
  2308. //
  2309. //
  2310. // }
  2311. // else
  2312. // {
  2313. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  2314. // }
  2315. //
  2316. //
  2317. //
  2318. //
  2319. // });
  2320. // });
  2321. // }
  2322. // else
  2323. // {
  2324. // 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];
  2325. //
  2326. //
  2327. // alert.tag = KEEP_TAIL;
  2328. //
  2329. //
  2330. // self.upparams = upparams;
  2331. //
  2332. // [alert show];
  2333. // }
  2334. //
  2335. // }
  2336. // else
  2337. // { //USER_ROLE_CUSTOMER
  2338. //
  2339. // // if(self.have_tail)
  2340. // // [upparams setValue:@"true" forKey:@"isHold"];
  2341. // // else
  2342. // // [upparams setValue:@"false" forKey:@"isHold"];
  2343. // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  2344. //
  2345. // [upparams setValue:@"true" forKey:@"isHold"];
  2346. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2347. //
  2348. // NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
  2349. //
  2350. // dispatch_async(dispatch_get_main_queue(), ^{
  2351. //
  2352. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  2353. //
  2354. // if([[editor_json valueForKey:@"result"] intValue]==2)
  2355. // {
  2356. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  2357. //
  2358. //
  2359. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2360. // // appDelegate.customerInfo = customerInfo;
  2361. //
  2362. //// NSString* orderCode = [editor_json valueForKey:@"orderCode"];
  2363. //// appDelegate.order_code = orderCode;
  2364. //// appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
  2365. // [appDelegate closeOrder];
  2366. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  2367. //
  2368. // NSString* title=nil;
  2369. // NSString* msg=nil;
  2370. //#ifdef OFFLINE_MODE
  2371. // if(appDelegate.offline_mode)
  2372. // {
  2373. // title=TITLE_OFFLINE_SUBMIT;
  2374. // msg=MSG_OFFLINE_SUBMIT;
  2375. // }
  2376. // else
  2377. //#endif
  2378. // {
  2379. // title=@"Order submitted sucessfully";
  2380. // msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  2381. // }
  2382. //
  2383. //
  2384. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  2385. //
  2386. // [alert show];
  2387. // // // self.labelContact.text=appDelegate.contact_name;
  2388. // //
  2389. // // NSDictionary * customerinfo = appDelegate.customerInfo;
  2390. // [self prepareReturn:nil];
  2391. // // [self.navigationController dismissViewControllerAnimated:true completion:^{
  2392. // //
  2393. // //
  2394. // // ;
  2395. // // }];
  2396. // [self.navigationController popViewControllerAnimated:true];
  2397. //
  2398. // }
  2399. // else
  2400. // {
  2401. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  2402. // }
  2403. //
  2404. //
  2405. //
  2406. //
  2407. // });
  2408. // });
  2409. //
  2410. // }
  2411. // }
  2412. //
  2413. //
  2414. //
  2415. //
  2416. // }
  2417. //
  2418. }
  2419. // else if( alertView.tag == KEEP_TAIL)
  2420. // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Submit Order"];
  2421. // if(buttonIndex!=alertView.cancelButtonIndex)
  2422. // {//keep tail;
  2423. //
  2424. // [self.upparams setValue:@"true" forKey:@"isHold"];
  2425. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2426. //
  2427. // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:self.upparams];
  2428. //
  2429. // dispatch_async(dispatch_get_main_queue(), ^{
  2430. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  2431. //
  2432. //
  2433. // if([[editor_json valueForKey:@"result"] intValue]==2)
  2434. // {
  2435. // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  2436. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Submit successful." message:[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  2437. //
  2438. // [alert show];
  2439. //
  2440. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2441. // appDelegate.customerInfo = customerInfo;
  2442. // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  2443. // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
  2444. // appDelegate.order_code = orderCode;
  2445. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  2446. // // // self.labelContact.text=appDelegate.contact_name;
  2447. // //
  2448. // // NSDictionary * customerinfo = appDelegate.customerInfo;
  2449. // [self prepareReturn:nil];
  2450. //// [self.navigationController dismissViewControllerAnimated:true completion:^{
  2451. ////
  2452. ////
  2453. //// ;
  2454. //// }];
  2455. // [self.navigationController popViewControllerAnimated:true];
  2456. //
  2457. // }
  2458. // else
  2459. // {
  2460. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Submit Order" controller:self] ;
  2461. // }
  2462. //
  2463. //
  2464. //
  2465. //
  2466. // });
  2467. // });
  2468. // }
  2469. // else
  2470. // {// not keep tail;
  2471. // [self.upparams setValue:@"false" forKey:@"isHold"];
  2472. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2473. //
  2474. // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:self.upparams];
  2475. //
  2476. // dispatch_async(dispatch_get_main_queue(), ^{
  2477. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  2478. //
  2479. //
  2480. // if([[editor_json valueForKey:@"result"] intValue]==2)
  2481. // {
  2482. // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
  2483. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Submit successful." message:[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  2484. //
  2485. // [alert show];
  2486. //
  2487. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2488. // // appDelegate.customerInfo = customerInfo;
  2489. // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
  2490. // // appDelegate.order_code = nil;
  2491. // [appDelegate closeOrder];
  2492. // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  2493. // // // self.labelContact.text=appDelegate.contact_name;
  2494. // //
  2495. // // NSDictionary * customerinfo = appDelegate.customerInfo;
  2496. // [self prepareReturn:nil];
  2497. //// [self.navigationController dismissViewControllerAnimated:true completion:^{
  2498. ////
  2499. ////
  2500. //// ;
  2501. //// }];
  2502. // [self.navigationController popViewControllerAnimated:true];
  2503. //
  2504. // }
  2505. // else
  2506. // {
  2507. // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Submit Order" controller:self] ;
  2508. // }
  2509. //
  2510. //
  2511. //
  2512. //
  2513. // });
  2514. // });
  2515. // }
  2516. // }
  2517. else if(alertView.tag == CLOSE_ACTION)
  2518. {
  2519. if(buttonIndex==1)
  2520. {
  2521. [self.navigationController popViewControllerAnimated:true];
  2522. // back to cart;
  2523. // [self.navigationController dismissViewControllerAnimated:true completion:^{
  2524. // ;
  2525. // }];
  2526. // if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
  2527. // appDelegate.order_code = nil;
  2528. //
  2529. // }
  2530. }
  2531. if(buttonIndex==2)
  2532. {
  2533. [self.navigationController popViewControllerAnimated:false];
  2534. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2535. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  2536. [((MainViewController*)appDelegate.main_vc) switchToOrder];
  2537. // back to cart;
  2538. // [self.navigationController dismissViewControllerAnimated:true completion:^{
  2539. // ;
  2540. // }];
  2541. // if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
  2542. // appDelegate.order_code = nil;
  2543. //
  2544. // }
  2545. }
  2546. else if(buttonIndex==3)
  2547. {
  2548. // close order;
  2549. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2550. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Release Order"];
  2551. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2552. NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:nil];
  2553. dispatch_async(dispatch_get_main_queue(), ^{
  2554. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  2555. if([[order_json valueForKey:@"result"] intValue]==2)
  2556. {
  2557. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2558. // appDelegate.order_code = nil;
  2559. [appDelegate closeOrder];
  2560. [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
  2561. [((MainViewController*)appDelegate.main_vc) switchToHome];
  2562. if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
  2563. {
  2564. [((MainViewController*)appDelegate.main_vc) Loginout:false];
  2565. }
  2566. [self prepareReturn:nil];
  2567. [self.navigationController popViewControllerAnimated:true];
  2568. // [self.navigationController dismissViewControllerAnimated:true completion:^{
  2569. // ;
  2570. // }];
  2571. }
  2572. else
  2573. {
  2574. [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order"controller:self] ;
  2575. }
  2576. });
  2577. });
  2578. //
  2579. // }
  2580. }
  2581. }
  2582. }
  2583. //
  2584. //
  2585. //-(void) downloadpdf:(NSString* )url
  2586. //{
  2587. // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Printing..."];
  2588. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  2589. //
  2590. //
  2591. // NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60*5];
  2592. //
  2593. // //设置请求方式为get
  2594. //
  2595. // [request setHTTPMethod:@"GET"];
  2596. //
  2597. // //添加用户会话id
  2598. //
  2599. // [request addValue:@"text/html" forHTTPHeaderField:@"Content-Type"];
  2600. //
  2601. // //连接发送请求
  2602. //
  2603. //
  2604. // NSHTTPURLResponse* urlResponse = nil;
  2605. //
  2606. // NSError *error = [[NSError alloc] init];
  2607. //
  2608. // NSData* content= [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
  2609. //
  2610. // // self.filename = [urlResponse suggestedFilename];
  2611. //
  2612. //
  2613. // dispatch_async(dispatch_get_main_queue(), ^{
  2614. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  2615. // // self.navigationItem.title = self.save_name;
  2616. // // UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
  2617. // // self.content=nil;
  2618. // if(content!=nil&&content.length>0)
  2619. // {
  2620. //
  2621. //
  2622. // [self startAirPrintWithData:content];
  2623. //
  2624. //
  2625. // }
  2626. // else
  2627. // {
  2628. // [RAUtils message_alert:nil title:@"Open PDF Failed" controller:self];
  2629. // // self.content = [self.url dataUsingEncoding:NSUTF8StringEncoding];
  2630. // }
  2631. //
  2632. // ;
  2633. // // DebugLog(@"%@",[[NSString alloc] initWithData:self.content encoding:NSASCIIStringEncoding]);
  2634. // //
  2635. //
  2636. //
  2637. // // [self.webView loadData:self.content MIMEType:urlResponse.MIMEType textEncodingName:nil baseURL:nil];
  2638. //
  2639. //
  2640. //
  2641. //
  2642. // });
  2643. // });
  2644. //}
  2645. //
  2646. //- (void)startAirPrintWithData:(id )data
  2647. //{
  2648. //
  2649. //
  2650. //
  2651. //
  2652. // UIPrintInteractionController* airPrinterController=[UIPrintInteractionController sharedPrintController];
  2653. // UIPrintInfo *printInfo = [UIPrintInfo printInfo];
  2654. // printInfo.outputType = UIPrintInfoOutputGeneral;
  2655. // printInfo.orientation = UIPrintInfoOrientationPortrait;
  2656. // printInfo.jobName = @"CoolVisitAirPrint";
  2657. // airPrinterController.printInfo = printInfo;
  2658. // airPrinterController.printingItem = data;
  2659. // airPrinterController.delegate = self;
  2660. //
  2661. //
  2662. // airPrinterController.showsNumberOfCopies=true;
  2663. // airPrinterController.showsPageRange = true;
  2664. // airPrinterController.showsPaperSelectionForLoadedPapers=true;
  2665. //
  2666. // void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
  2667. // if(completed && error)
  2668. // DebugLog(@"Printing failed due to error in domain %@ with error code %lu. Localized description: %@, and failure reason: %@", error.domain, (long)error.code, error.localizedDescription, error.localizedFailureReason);
  2669. // };
  2670. //
  2671. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2672. //
  2673. // UIPrinter *airPrinter = [UIPrinter printerWithURL:[NSURL URLWithString:appDelegate.printerURL] ];///*self.printer;*/
  2674. //
  2675. //
  2676. //
  2677. //
  2678. // [[UIPrinter printerWithURL:[NSURL URLWithString:appDelegate.printerURL]] contactPrinter:^(BOOL available)
  2679. // {
  2680. // if (available&& appDelegate.printerURL.length>0)
  2681. // {
  2682. //
  2683. // [airPrinterController printToPrinter:airPrinter completionHandler:completionHandler];
  2684. // DebugLog(@"AIRPRINTER AVAILABLE");
  2685. // }
  2686. // else
  2687. // {
  2688. //
  2689. // // [airPrinterController presentFromRect:CGRectMake(0, 0, 300, 500) inView:self.view animated:YES completionHandler:
  2690. // //
  2691. // //
  2692. // //
  2693. // // // [printPicker presentAnimated:YES completionHandler:
  2694. // // ^(UIPrintInteractionController *printerController, BOOL userDidSelect, NSError *error)
  2695. // // {
  2696. // // if (userDidSelect)
  2697. // // {
  2698. // // NSString* sid= printerController.printInfo.printerID;
  2699. // // UIPrintPaper*paper= printerController.printPaper;
  2700. // //
  2701. // // }
  2702. // // }];
  2703. //
  2704. //
  2705. // DebugLog(@"AIRPRINTER NOT AVAILABLE");
  2706. //
  2707. //
  2708. //
  2709. // if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1)
  2710. // {
  2711. // UIPrinterPickerController *printPicker = [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:nil];
  2712. // // [printPicker presentFromBarButtonItem:self.btnSubmitOrder animated:yes completionHandler:
  2713. //
  2714. //
  2715. //
  2716. // [ printPicker presentFromBarButtonItem:self.btnSubmitOrder animated:YES completionHandler:
  2717. //
  2718. //
  2719. // // [printPicker presentFromRect:CGRectMake(0, 0, 300, 500) inView:self.view animated:YES completionHandler:
  2720. //
  2721. //
  2722. //
  2723. // // [printPicker presentAnimated:YES completionHandler:
  2724. // ^(UIPrinterPickerController *printerPicker, BOOL userDidSelect, NSError *error)
  2725. // {
  2726. // if (userDidSelect)
  2727. // {
  2728. // //User selected the item in the UIPrinterPickerController and got the printer details.
  2729. //
  2730. // [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:printerPicker.selectedPrinter];
  2731. //
  2732. // //Here you will get the printer and printer details.ie,
  2733. // // printerPicker.selectedPrinter, printerPicker.selectedPrinter.displayName, printerPicker.selectedPrinter.URL etc. So you can display the printer name in your label text or button title.
  2734. //
  2735. //
  2736. //
  2737. //
  2738. // appDelegate.printerURL =printerPicker.selectedPrinter.URL.absoluteString;
  2739. //
  2740. // [self startAirPrintWithData:data];
  2741. //
  2742. // }
  2743. // else
  2744. // {
  2745. //
  2746. //
  2747. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2748. // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  2749. // {
  2750. //
  2751. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  2752. // }
  2753. // [self prepareReturn:nil];
  2754. //
  2755. // [self.navigationController popViewControllerAnimated:true];
  2756. // }
  2757. // }];
  2758. // }
  2759. // }
  2760. // }];
  2761. //
  2762. //
  2763. //
  2764. //}
  2765. //
  2766. //#pragma mark - UIPrintInteractionControllerDelegate
  2767. //- (UIPrintPaper *)printInteractionController:(UIPrintInteractionController *)printInteractionController choosePaper:(NSArray<UIPrintPaper *> *)paperList
  2768. //{
  2769. //
  2770. // ;
  2771. //
  2772. // // (int) width = 29700
  2773. // // Printing description of (*( (int *)0x7caa3a40)):
  2774. // // (int) height = 42000
  2775. // //设置纸张大小
  2776. //
  2777. //
  2778. // for(UIPrintPaper* paper in paperList)
  2779. // {
  2780. // if (CGSizeEqualToSize(paper.paperSize, CGSizeMake(612, 792)))
  2781. // return paper;
  2782. //
  2783. // }
  2784. // CGSize paperSize = CGSizeMake(612, 792);
  2785. // UIPrintPaper * p=[UIPrintPaper bestPaperForPageSize:paperSize withPapersFromArray:paperList];
  2786. // return p;
  2787. //}
  2788. //- (void)printInteractionControllerWillPresentPrinterOptions:(UIPrintInteractionController *)printInteractionController
  2789. //{
  2790. //
  2791. //}
  2792. //- (void)printInteractionControllerDidPresentPrinterOptions:(UIPrintInteractionController *)printInteractionController
  2793. //{
  2794. //
  2795. //}
  2796. //- (void)printInteractionControllerWillDismissPrinterOptions:(UIPrintInteractionController *)printInteractionController
  2797. //{
  2798. //
  2799. //}
  2800. //- (void)printInteractionControllerDidDismissPrinterOptions:(UIPrintInteractionController *)printInteractionController
  2801. //{
  2802. //
  2803. //}
  2804. //
  2805. //- (void)printInteractionControllerWillStartJob:(UIPrintInteractionController *)printInteractionController
  2806. //{
  2807. //
  2808. //}
  2809. //- (void)printInteractionControllerDidFinishJob:(UIPrintInteractionController *)printInteractionController
  2810. //{
  2811. //
  2812. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2813. // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
  2814. // {
  2815. //
  2816. // [((MainViewController*)appDelegate.main_vc) Loginout:false];
  2817. // }
  2818. //
  2819. // [self prepareReturn:nil];
  2820. //
  2821. // [self.navigationController popViewControllerAnimated:true];
  2822. //}
  2823. //
  2824. //- (NSString *)currentPriceTypeName {
  2825. // NSInteger priceType = [Singleton sharedInstance].npd_shop_price_type;
  2826. //
  2827. // NSString* pricename = nil;
  2828. // switch (priceType) {
  2829. // case 0:
  2830. // pricename=[Singleton sharedInstance].deliveryString;
  2831. // break;
  2832. // case 1:
  2833. // pricename=flat_price;
  2834. // break;
  2835. // case 2:
  2836. // pricename=given_price;
  2837. // break;
  2838. // default:
  2839. // break;
  2840. // }
  2841. // return pricename;
  2842. //}
  2843. - (void)releaseOrderAfterSave {
  2844. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2845. [RANetwork release_Order:appDelegate.order_code withScreen:nil];
  2846. [appDelegate closeOrder];
  2847. [appDelegate SetSo:nil];
  2848. appDelegate.cart_count=0;
  2849. [appDelegate update_count_mark];
  2850. [((MainViewController*)appDelegate.main_vc) switchToOrder];
  2851. [self prepareReturn:nil];
  2852. [self.navigationController popToRootViewControllerAnimated:false];
  2853. }
  2854. -(NSString* )create_customer_ext:(NSDictionary*)customerinfo
  2855. {
  2856. NSString* ret=nil;
  2857. NSString* customer_address1= [customerinfo valueForKey:@"customer_address1"];
  2858. NSString* customer_address2= [customerinfo valueForKey:@"customer_address2"];
  2859. NSString* customer_address3= [customerinfo valueForKey:@"customer_address3"];
  2860. NSString* customer_address4= [customerinfo valueForKey:@"customer_address4"];
  2861. NSMutableArray* arraddr = [[NSMutableArray alloc] init];
  2862. if(customer_address1.length>0)
  2863. [arraddr addObject:customer_address1];
  2864. if(customer_address2.length>0)
  2865. [arraddr addObject:customer_address2];
  2866. if(customer_address3.length>0)
  2867. [arraddr addObject:customer_address3];
  2868. if(customer_address4.length>0)
  2869. [arraddr addObject:customer_address4];
  2870. NSString *addr_string = [arraddr componentsJoinedByString:@"\r\n"];
  2871. NSString* customer_city= [customerinfo valueForKey:@"customer_city"];
  2872. NSString* customer_country= [customerinfo valueForKey:@"customer_country"];
  2873. NSString* customer_zipcode= [customerinfo valueForKey:@"customer_zipcode"];
  2874. NSString* customer_state= [customerinfo valueForKey:@"customer_state"];
  2875. NSMutableArray* arrcty = [[NSMutableArray alloc] init];
  2876. if(customer_city.length>0)
  2877. [arrcty addObject:customer_city];
  2878. if(customer_state.length>0)
  2879. [arrcty addObject:customer_state];
  2880. if(customer_zipcode.length>0)
  2881. [arrcty addObject:customer_zipcode];
  2882. if(customer_country.length>0)
  2883. [arrcty addObject:customer_country];
  2884. NSString *cty_string = [arrcty componentsJoinedByString:@", "];
  2885. // NSString* customer_phone= [customerinfo valueForKey:@"customer_phone"];
  2886. // NSString* customer_fax= [customerinfo valueForKey:@"customer_fax"];
  2887. //
  2888. // NSMutableArray* arrpho = [[NSMutableArray alloc] init];
  2889. // if(customer_phone.length>0)
  2890. // {
  2891. // customer_phone = [NSString stringWithFormat:@"TEL: %@",customer_phone];
  2892. // [arrpho addObject:customer_phone];
  2893. // }
  2894. // if(customer_fax.length>0)
  2895. // {
  2896. // customer_fax = [NSString stringWithFormat:@"FAX: %@",customer_fax];
  2897. // [arrpho addObject:customer_fax];
  2898. // }
  2899. // NSString *phone_string = [arrpho componentsJoinedByString:@", "];
  2900. //
  2901. //
  2902. // NSString* customer_contact= [customerinfo valueForKey:@"customer_contact"];
  2903. // if(customer_contact.length>0)
  2904. // {
  2905. // customer_contact = [NSString stringWithFormat:@"ATTN: %@",customer_contact];
  2906. //
  2907. // }
  2908. // NSString *contact_string = customer_contact;
  2909. //
  2910. //
  2911. // NSString* customer_email= [customerinfo valueForKey:@"customer_email"];
  2912. // if(customer_email.length>0)
  2913. // {
  2914. // customer_email = [NSString stringWithFormat:@"Email: %@",customer_email];
  2915. //
  2916. // }
  2917. // NSString *email_string = customer_email;
  2918. NSMutableArray* arrext = [[NSMutableArray alloc] init];
  2919. if(addr_string.length>0)
  2920. [arrext addObject:addr_string];
  2921. if(cty_string.length>0)
  2922. [arrext addObject:cty_string];
  2923. // if(phone_string.length>0)
  2924. // [arrext addObject:phone_string];
  2925. // if(contact_string.length>0)
  2926. // [arrext addObject:contact_string];
  2927. // if(email_string.length>0)
  2928. // [arrext addObject:email_string];
  2929. ret = [arrext componentsJoinedByString:@"\r\n"];
  2930. // NSString *string = [array componentsJoinedByString:@" "];
  2931. // NSString* customer_name= [customerinfo valueForKey:@"customer_name"];
  2932. return ret;
  2933. }
  2934. -(NSMutableDictionary*)create_value_map:(NSDictionary*)key_map
  2935. {
  2936. NSMutableDictionary* ret= [[NSMutableDictionary alloc] init];
  2937. NSArray *keys= [key_map allKeys];
  2938. //遍历keys
  2939. for(int i=0;i<[keys count];i++)
  2940. {
  2941. //得到当前key
  2942. NSString *key=[keys objectAtIndex:i];
  2943. //如果key不是pic,说明value是字符类型,比如name:Boris
  2944. NSString* valuefrom = [key_map valueForKey:key];
  2945. if(valuefrom.length==0)
  2946. continue;
  2947. NSString* value=[self getValue:valuefrom];
  2948. [ret setValue:value forKey:valuefrom];
  2949. }
  2950. NSDictionary * customerinfo =[self create_cusromer_info_from_table];
  2951. [ret setValue:[self create_customer_ext:customerinfo] forKey:@"customer_contact_ext"];
  2952. [ret setValue:customerinfo[@"customer_first_name"] forKey:@"customer_first_name"];
  2953. [ret setValue:customerinfo[@"customer_last_name"] forKey:@"customer_last_name"];
  2954. return ret;
  2955. }
  2956. -(NSMutableDictionary*)create_cusromer_info_from_table
  2957. {
  2958. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  2959. NSMutableDictionary* ret= [appDelegate.customerInfo mutableCopy] ;
  2960. [ret setValue:[self getValue:@"customer_country"] forKey:@"customer_country"];
  2961. [ret setValue:[self getValue:@"customer_phone"] forKey:@"customer_phone"];
  2962. [ret setValue:[self getValue:@"customer_email"] forKey:@"customer_email"];
  2963. [ret setValue:[self getValue:@"customer_name"] forKey:@"customer_name"];
  2964. [ret setValue:[self getValue:@"customer_address4"] forKey:@"customer_address4"];
  2965. [ret setValue:[self getValue:@"customer_address3"] forKey:@"customer_address3"];
  2966. [ret setValue:[self getValue:@"customer_address2"] forKey:@"customer_address2"];
  2967. [ret setValue:[self getValue:@"customer_address1"] forKey:@"customer_address1"];
  2968. [ret setValue:[self getValue:@"customer_zipcode"] forKey:@"customer_zipcode"];
  2969. [ret setValue:[self getValue:@"customer_city"] forKey:@"customer_city"];
  2970. [ret setValue:[self getValue:@"customer_state"] forKey:@"customer_state"];
  2971. [ret setValue:[self getValue:@"customer_cid"] forKey:@"customer_cid"];
  2972. [ret setValue:[self getValue:@"customer_state"] forKey:@"customer_state"];
  2973. [ret setValue:[self getValue:@"customer_contact"] forKey:@"customer_contact"];
  2974. [ret setValue:[self getValue:@"customer_fax"] forKey:@"customer_fax"];
  2975. NSString * firstname =nil;
  2976. NSString* lastname = nil;
  2977. NSString* contact_name = [self getValue:@"customer_contact"];
  2978. if(contact_name!=nil)
  2979. {
  2980. NSArray *_arr = [contact_name componentsSeparatedByString:NSLocalizedString(@" ", nil)];
  2981. if(_arr.count>=1)
  2982. {
  2983. firstname =_arr[0];
  2984. if(_arr.count>1)
  2985. {
  2986. lastname=[[_arr subarrayWithRange:NSMakeRange(1, _arr.count-1)] componentsJoinedByString:@" "];
  2987. }
  2988. }
  2989. }
  2990. [ret setValue:firstname forKey:@"customer_first_name"];
  2991. [ret setValue:lastname forKey:@"customer_last_name"];
  2992. // [ret setValue:[self create_customer_ext:ret] forKey:@"customer_contact_ext"];
  2993. return ret;
  2994. }
  2995. #pragma mark - multi_action sub action clicked
  2996. - (void)MActionClicked:(UIButton *)sender {
  2997. UITableViewCell *cell = (UITableViewCell *) sender.superview.superview;
  2998. NSIndexPath * indexPath = [self.editorTable indexPathForCell:cell];
  2999. int refresh =0;
  3000. NSMutableDictionary* section_json=nil;
  3001. NSMutableDictionary* item_json =[((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row] mutableCopy];
  3002. NSString* subid=[item_json valueForKey:@"subid"];
  3003. NSString* refresh_trigger = [item_json valueForKey:@"name"];
  3004. NSDictionary* sub_action = [item_json objectForKey:[NSString stringWithFormat:@"item_%ld",(long)sender.tag]];
  3005. NSString* type = [sub_action valueForKey:@"type"];
  3006. if([type isEqualToString:@"pull"])
  3007. {
  3008. [self.lastedit endEditing:true];
  3009. refresh = [[sub_action valueForKey:@"refresh"] intValue];
  3010. NSDictionary* keymap= [sub_action objectForKey:@"key_map"];
  3011. NSMutableDictionary* value=[self create_value_map:keymap];
  3012. if(subid==nil)
  3013. {
  3014. NSDictionary* jsonmap=[sub_action valueForKey:@"key_map"];
  3015. section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
  3016. int icount=[[section_json valueForKey:@"count"] intValue];
  3017. for (int ic=0;ic<icount;ic++)
  3018. {
  3019. NSMutableDictionary* modify_item= [[section_json objectForKey:[NSString stringWithFormat:@"item_%d",ic ]] mutableCopy];
  3020. NSString* mapto = [modify_item valueForKey:@"name"];
  3021. if(mapto.length==0)
  3022. continue;
  3023. NSString* valuefrom= [jsonmap valueForKey:[modify_item valueForKey:@"name"]];
  3024. if(valuefrom==nil)
  3025. continue;
  3026. NSString* valuestr=[value valueForKey:valuefrom];
  3027. // valuestr = [self getValue:valuefrom];
  3028. if(true)
  3029. {
  3030. if(valuestr.length>0)
  3031. [modify_item setValue:valuestr forKey:@"value"];
  3032. else
  3033. [modify_item setValue:@"" forKey:@"value"];
  3034. [modify_item setValue:@"true" forKey:@"dirty"];
  3035. [section_json setObject:modify_item forKey:[NSString stringWithFormat:@"item_%d",ic ]];
  3036. }
  3037. }
  3038. }
  3039. else
  3040. {
  3041. NSArray* idarr=[subid componentsSeparatedByString:@"_"];
  3042. int section = [(NSString*)idarr[0] intValue];
  3043. int item=[(NSString*)idarr[1] intValue];
  3044. NSDictionary* jsonmap=[sub_action valueForKey:@"key_map"];
  3045. section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d", section]] mutableCopy];
  3046. NSMutableDictionary * olditem=[[section_json objectForKey:[NSString stringWithFormat:@"item_%d",item ]] mutableCopy];
  3047. NSString* control_type = [olditem valueForKey:@"control"];
  3048. if([control_type isEqualToString:@"switch"])
  3049. olditem= [self fill_switch_subitem:olditem subid:nil source:value mapping:jsonmap ];
  3050. else if([control_type isEqualToString:@"enum"])
  3051. {
  3052. olditem= [self fill_enum_subitem:olditem subid:nil source:value mapping:jsonmap ];
  3053. }
  3054. else
  3055. {
  3056. [RAUtils alert_view:@"" title:@"not impl"];
  3057. }
  3058. [olditem setValue:@"true" forKey:@"dirty"];
  3059. [section_json setObject:olditem forKey:[NSString stringWithFormat:@"item_%d",item ]];
  3060. }
  3061. [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
  3062. self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
  3063. if(refresh==1)
  3064. {
  3065. // if(restore_json!=nil)
  3066. // {
  3067. // int rc=[[restore_json valueForKey:@"count"] intValue];
  3068. // for(int ir=0;ir<rc;ir++)
  3069. // {
  3070. // NSString* name = [restore_json valueForKey:[NSString stringWithFormat:@"item_%d",ir]];
  3071. //
  3072. //
  3073. // int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
  3074. // for(int i=0;i<section_count;i++)
  3075. // {
  3076. // NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
  3077. // // NSMutableDictionary * to_sectionjson = [[to objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
  3078. // int item_count = [[sectionjson valueForKey:@"count"] intValue];
  3079. // for(int j=0;j<item_count;j++)
  3080. // {
  3081. // NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
  3082. // // NSMutableDictionary * to_itemjson=[[to_sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
  3083. //
  3084. // if([[itemjson valueForKey:@"name"] isEqualToString:name])
  3085. // {
  3086. // [itemjson removeObjectForKey:@"dirty"];
  3087. // [sectionjson setObject:itemjson forKey:[NSString stringWithFormat:@"item_%d",j ]];
  3088. // }
  3089. //
  3090. // }
  3091. // [self.content_data_download setObject:sectionjson forKey:[NSString stringWithFormat:@"section_%d",i ]];
  3092. // }
  3093. //
  3094. //
  3095. // }
  3096. //
  3097. // }
  3098. [self refresh:refresh_trigger] ;
  3099. return ;
  3100. }
  3101. // DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
  3102. [self.editorTable reloadData ];
  3103. }
  3104. else
  3105. {
  3106. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3107. NSDictionary * item_json = sub_action;
  3108. NSString* value = [item_json valueForKey:@"value"];
  3109. if([value isEqualToString:@"new_addr"])
  3110. {
  3111. AddressEditorViewController * addressVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"AddressEditorViewController"];
  3112. addressVC.url_type = URL_REMOTE;
  3113. addressVC.request_url=URL_ADDRESS_EDOTOR;
  3114. NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
  3115. // NSString * string = [checked componentsJoinedByString:@","];
  3116. // [params setValue:string forKey:@"cart2Checkbox"];
  3117. params[@"is_subaction"]=@"true";
  3118. params[@"subaction_tag"]= [NSString stringWithFormat:@"%ld",(long)sender.tag];
  3119. addressVC.params = params;
  3120. addressVC.delegate = self;
  3121. addressVC.from = indexPath;
  3122. // orderinfoVC.params = params;
  3123. [self.navigationController pushViewController:addressVC animated:true];
  3124. }else if([value isEqualToString:@"credit_card"])
  3125. {
  3126. CreditCardEditorViewController * cardVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"CreditCardEditorViewController"];
  3127. NSDictionary *data = [item_json objectForKey:@"data"];
  3128. if(data!=nil)
  3129. {
  3130. cardVC.content_data_download = [data mutableCopy];
  3131. cardVC.url_type = URL_NONE;
  3132. cardVC.request_url=nil;
  3133. }
  3134. else
  3135. {
  3136. cardVC.url_type = URL_REMOTE;
  3137. cardVC.request_url=URL_CREDITCARD_EDOTOR;
  3138. }
  3139. NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
  3140. params[@"orderCode"]=appDelegate.order_code;
  3141. params[@"is_subaction"]=@"true";
  3142. params[@"subaction_tag"]= [NSString stringWithFormat:@"%ld",(long)sender.tag];
  3143. cardVC.params = params;
  3144. cardVC.delegate = self;
  3145. cardVC.from = indexPath;
  3146. // orderinfoVC.params = params;
  3147. [self.navigationController pushViewController:cardVC animated:true];
  3148. }
  3149. else if([value isEqualToString:@"Sales_Order_Freight_Bill_To"])
  3150. {
  3151. ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  3152. cvc.showNavibar = true;
  3153. cvc.contact_type = value;
  3154. cvc.is_subaction = @"true";
  3155. cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
  3156. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  3157. [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  3158. //
  3159. // if(self.returnValue)
  3160. // self.returnValue(value);
  3161. };
  3162. [self.navigationController pushViewController:cvc animated:true];
  3163. }
  3164. else if([value isEqualToString:@"Sales_Order_Ship_From"])
  3165. {
  3166. ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  3167. cvc.showNavibar = true;
  3168. cvc.contact_type = value;
  3169. cvc.is_subaction = @"true";
  3170. cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
  3171. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  3172. [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  3173. //
  3174. // if(self.returnValue)
  3175. // self.returnValue(value);
  3176. };
  3177. [self.navigationController pushViewController:cvc animated:true];
  3178. }
  3179. else if([value isEqualToString:@"Sales_Order_Customer"])
  3180. {
  3181. ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  3182. cvc.is_subaction = @"true";
  3183. cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
  3184. cvc.showNavibar = true;
  3185. cvc.contact_type = value;
  3186. __weak typeof(self) weakself = self;
  3187. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  3188. [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  3189. //
  3190. // if(self.returnValue)
  3191. // self.returnValue(value);
  3192. };
  3193. [self.navigationController pushViewController:cvc animated:true];
  3194. }
  3195. else if([value isEqualToString:@"Sales_Order_Merchandise_Bill_To"])
  3196. {
  3197. ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  3198. cvc.showNavibar = true;
  3199. cvc.contact_type = value;
  3200. cvc.is_subaction = @"true";
  3201. cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
  3202. __weak typeof(self) weakself = self;
  3203. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  3204. [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  3205. //
  3206. // if(self.returnValue)
  3207. // self.returnValue(value);
  3208. };
  3209. [self.navigationController pushViewController:cvc animated:true];
  3210. }
  3211. else if([value isEqualToString:@"Contact_Return_To"])
  3212. {
  3213. ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  3214. cvc.is_subaction = @"true";
  3215. cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
  3216. cvc.showNavibar = true;
  3217. cvc.contact_type = value;
  3218. __weak typeof(self) weakself = self;
  3219. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  3220. [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  3221. //
  3222. // if(self.returnValue)
  3223. // self.returnValue(value);
  3224. };
  3225. [self.navigationController pushViewController:cvc animated:true];
  3226. }
  3227. else if([value isEqualToString:@"Sales_Order_Ship_To"])
  3228. {
  3229. ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  3230. cvc.is_subaction = @"true";
  3231. cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
  3232. cvc.showNavibar = true;
  3233. cvc.contact_type = value;
  3234. __weak typeof(self) weakself = self;
  3235. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  3236. [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  3237. //
  3238. // if(self.returnValue)
  3239. // self.returnValue(value);
  3240. };
  3241. [self.navigationController pushViewController:cvc animated:true];
  3242. }
  3243. }
  3244. }
  3245. #pragma mark - Urgency
  3246. -(void) viewWillDisappear:(BOOL)animated
  3247. {
  3248. [super viewWillDisappear:animated];
  3249. [self cancel_urgency_timer];
  3250. }
  3251. - (void)start_urgency_timer {
  3252. if (!self.editable) {
  3253. return;
  3254. }
  3255. __weak typeof(self) weakSelf = self;
  3256. AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
  3257. [appDelegate.urgencyDic setValue:appDelegate.user forKey:@"user"];
  3258. #ifdef OFFLINE_MODE
  3259. [appDelegate.urgencyDic setValue:[NSNumber numberWithBool:appDelegate.offline_mode] forKey:@"offline_mode"];
  3260. #endif
  3261. [[JKTimerManager sharedTimerManager] scheduledDispatchTimerWithName:self.urgency_timer_name timeInterval:1 queue:nil repeats:YES action:^{
  3262. NSMutableDictionary *urgencyDic = [NSMutableDictionary dictionary];
  3263. // DebugLog(@"timer start....");
  3264. [urgencyDic setValue:weakSelf.content_data_download forKey:[NSString stringWithFormat:@"%@_restored_data",self.class_name]];
  3265. [urgencyDic setValue:weakSelf.class_name forKey:@"class_name"];
  3266. if ([weakSelf.class_name isEqualToString:@"CreateOrderViewController"]) {
  3267. // CreateOrderViewController
  3268. [urgencyDic setValue:appDelegate.order_code forKey:@"order_code"];
  3269. MainViewController *mainVC = (MainViewController *)appDelegate.main_vc;
  3270. NSString *so = [mainVC.labelSo.text substringFromIndex:5];
  3271. [urgencyDic setValue:so forKey:@"order_so"];
  3272. [urgencyDic setValue:[NSNumber numberWithInt:appDelegate.order_status ] forKey:@"order_status"];
  3273. [urgencyDic setValue:appDelegate.order_customer_id forKey:@"order_customer_id"];
  3274. }
  3275. [appDelegate.urgencyDic setValue:urgencyDic forKey:[NSString stringWithFormat:@"level_%d",weakSelf.level]];
  3276. [appDelegate.urgencyDic setValue:[NSNumber numberWithInteger:weakSelf.level + 1] forKey:@"count"];
  3277. }];
  3278. }
  3279. - (void)cancel_urgency_timer {
  3280. [[JKTimerManager sharedTimerManager] cancelTimerWithName:self.urgency_timer_name];
  3281. }
  3282. #pragma mark - Submit Order
  3283. - (void)customer_commit_order:(NSMutableDictionary *)upparams {
  3284. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  3285. [upparams setValue:@"true" forKey:@"isHold"];
  3286. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  3287. NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
  3288. dispatch_async(dispatch_get_main_queue(), ^{
  3289. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  3290. if([[editor_json valueForKey:@"result"] intValue]==2)
  3291. {
  3292. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3293. // appDelegate.customerInfo = customerInfo;
  3294. [appDelegate closeOrder];
  3295. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  3296. NSString* title=nil;
  3297. NSString* msg=nil;
  3298. #ifdef OFFLINE_MODE
  3299. if(appDelegate.offline_mode)
  3300. {
  3301. title=TITLE_OFFLINE_SUBMIT;
  3302. msg=MSG_OFFLINE_SUBMIT;
  3303. }
  3304. else
  3305. #endif
  3306. {
  3307. title=@"Order submitted sucessfully";
  3308. msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  3309. }
  3310. UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  3311. [alert show];
  3312. [self prepareReturn:nil];
  3313. [self.navigationController popToRootViewControllerAnimated:true];
  3314. }
  3315. else
  3316. {
  3317. [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  3318. }
  3319. });
  3320. });
  3321. }
  3322. - (void)empolyee_commit_order:(NSMutableDictionary *)upparams {
  3323. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
  3324. [upparams setValue:@"false" forKey:@"isHold"];
  3325. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  3326. NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
  3327. dispatch_async(dispatch_get_main_queue(), ^{
  3328. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  3329. if([[editor_json valueForKey:@"result"] intValue]==2)
  3330. {
  3331. // debug aaa
  3332. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  3333. NSString* company= appDelegate.customerInfo[@"customer_name"];
  3334. NSString* send_to =appDelegate.customerInfo[@"customer_email"];
  3335. [appDelegate closeOrder];
  3336. [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
  3337. NSString* title=nil;
  3338. NSString* msg=nil;
  3339. #ifdef OFFLINE_MODE
  3340. if(appDelegate.offline_mode)
  3341. {
  3342. title=TITLE_OFFLINE_SUBMIT;
  3343. msg=MSG_OFFLINE_SUBMIT;
  3344. }
  3345. else
  3346. #endif
  3347. {
  3348. title=@"Order submitted sucessfully";
  3349. msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
  3350. }
  3351. UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  3352. [alert show];
  3353. NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
  3354. NSString* email_content =[editor_json valueForKey:@"email_content"];
  3355. NSString* soid=[editor_json valueForKey:@"so#"];
  3356. {
  3357. NSMutableDictionary *value = [NSMutableDictionary dictionary];
  3358. if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
  3359. {
  3360. //bbb
  3361. [((MainViewController*)appDelegate.main_vc) Loginout:false];
  3362. value[@"commitorder_logout"]=@"true";
  3363. }
  3364. [self prepareReturn:value];
  3365. [self.navigationController popToRootViewControllerAnimated:true];
  3366. if(pdf_url.length>0)
  3367. {
  3368. [alert dismissWithClickedButtonIndex:0 animated:FALSE];
  3369. [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
  3370. // [appDelegate printPdf:pdf_url];
  3371. }
  3372. }
  3373. }
  3374. else
  3375. {
  3376. [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
  3377. }
  3378. });
  3379. });
  3380. }
  3381. @end