| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873 |
- //
- // CreateOrderViewController.m
- // RedAnt ERP Mobile
- //
- // Created by Ray on 8/24/15.
- // Copyright (c) 2015 United Software Applications, Inc. All rights reserved.
- //
- #import "CreateOrderViewController.h"
- #import "RANetwork.h"
- #import "MainViewController.h"
- #import "Singleton.h"
- #import "config.h"
- #import "CustomIOSAlertView.h"
- #import "AddressEditorViewController.h"
- #import "CreditCardEditorViewController.h"
- #import "JKTimerManager.h"
- #define SUBMIT_CONFIRM 123
- #define KEEP_TAIL 456
- #define CLOSE_ACTION 567
- @interface CreateOrderViewController ()
- // static const char associatedkey;
- @property (nonatomic,assign) BOOL isResume;///<恢复
- @property (nonatomic,assign) NSInteger userType;///<恢复使用
- @end
- @implementation CreateOrderViewController
- - (void)alertMessage:(NSString *)msg {
-
-
- if (notifyMe_switch) {
-
- if ([self.class_name isEqualToString:@"CreateOrderViewController"]) {
-
- NSString *err_msg = msg;
- UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Attention!!" message:err_msg preferredStyle:UIAlertControllerStyleAlert];
- __weak typeof(self) weakself = self;
- UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- [weakself.navigationController popViewControllerAnimated:YES];
-
- }];
- [alertVC addAction:action];
-
- [self presentViewController:alertVC animated:YES completion:nil];
-
- } else {
-
- [RAUtils message_alert:msg title:nil controller:self] ;
- }
-
- } else {
-
- [RAUtils message_alert:msg title:nil controller:self] ;
- }
- }
- -(void) commonAction:(NSString *)value index:(NSIndexPath*) indexPath data:(NSMutableDictionary*) item_json
- {
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- if([value isEqualToString:@"new_addr"])
- {
- AddressEditorViewController * addressVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"AddressEditorViewController"];
-
- addressVC.url_type = URL_REMOTE;
-
- addressVC.request_url=URL_ADDRESS_EDOTOR;
-
-
-
-
- NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
- // NSString * string = [checked componentsJoinedByString:@","];
- // [params setValue:string forKey:@"cart2Checkbox"];
-
-
-
-
- addressVC.params = params;
-
-
- addressVC.delegate = self;
-
- addressVC.from = indexPath;
- // orderinfoVC.params = params;
-
- [self.navigationController pushViewController:addressVC animated:true];
-
- }else if([value isEqualToString:@"credit_card"])
- {
- CreditCardEditorViewController * cardVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"CreditCardEditorViewController"];
-
-
- NSDictionary *data = [item_json objectForKey:@"data"];
-
- if(data!=nil)
- {
-
- cardVC.content_data_download = [data mutableCopy];
- cardVC.url_type = URL_NONE;
-
- cardVC.request_url=nil;
- }
- else
- {
- cardVC.url_type = URL_REMOTE;
-
- cardVC.request_url=URL_CREDITCARD_EDOTOR;
- }
- NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
-
- params[@"orderCode"]=appDelegate.order_code;
- cardVC.params = params;
-
- cardVC.delegate = self;
-
- cardVC.from = indexPath;
-
-
- // orderinfoVC.params = params;
-
- [self.navigationController pushViewController:cardVC animated:true];
-
- }
- else if([value isEqualToString:@"Sales_Order_Freight_Bill_To"])
- {
-
-
- ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- cvc.showNavibar = true;
- cvc.contact_type = value;
- __weak typeof(self) weakself = self;
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
-
-
- [self.navigationController pushViewController:cvc animated:true];
-
- }
- else if([value isEqualToString:@"Sales_Order_Ship_From"])
- {
-
-
- ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- cvc.showNavibar = true;
- cvc.contact_type = value;
- __weak typeof(self) weakself = self;
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
-
-
- [self.navigationController pushViewController:cvc animated:true];
-
- }
- else if([value isEqualToString:@"Sales_Order_Customer"])
- {
-
-
- ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
-
- cvc.contact_type = value;
- cvc.showNavibar = true;
- __weak typeof(self) weakself = self;
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
-
-
- [self.navigationController pushViewController:cvc animated:true];
-
- }
- else if([value isEqualToString:@"Sales_Order_Merchandise_Bill_To"])
- {
-
-
- ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- cvc.showNavibar = true;
- cvc.contact_type = value;
- __weak typeof(self) weakself = self;
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
-
-
- [self.navigationController pushViewController:cvc animated:true];
-
- }
- else if([value isEqualToString:@"Contact_Return_To"])
- {
-
-
- ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- cvc.showNavibar = true;
- cvc.contact_type = value;
- __weak typeof(self) weakself = self;
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
-
-
- [self.navigationController pushViewController:cvc animated:true];
-
- }
- else if([value isEqualToString:@"Sales_Order_Ship_To"])
- {
-
-
- ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- cvc.showNavibar = true;
- cvc.contact_type = value;
- __weak typeof(self) weakself = self;
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
-
-
- [self.navigationController pushViewController:cvc animated:true];
-
- }
-
- }
- - (void)dealloc {
-
- AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-
- [appDelegate.urgencyDic removeObjectForKey:[NSString stringWithFormat:@"level_%d",self.level]];
- [appDelegate.urgencyDic setValue:[NSNumber numberWithInteger:self.level] forKey:@"count"];
-
- if (self.isResume && self.userType == USER_ROLE_CUSTOMER) {
- [self releaseOrderAfterSave];
- }
-
- }
- -(void) viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
-
- [self start_urgency_timer];
-
- self.isResume = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_resume"] boolValue];
- self.userType = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_userType"] integerValue];
- BOOL canSubmit = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_submitOrder"] boolValue];
-
- // 检查权限
- NSMutableArray * items = [[NSMutableArray alloc]init];
-
-
- UIBarButtonItem *savebtn = nil;
-
- savebtn = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"save"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(onSaveClick:)];
-
- UIImage *submit_img = [[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic];
-
- #if defined(BUILD_NPD) || defined(BUILD_USAI)
- submit_img = [[UIImage imageNamed:@"submit_red"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
- #endif
-
- self.btnSubmitOrder = nil;
- self.btnSubmitOrder =[[UIBarButtonItem alloc] initWithImage:submit_img
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(onCommitOrderClick:)];
-
-
- UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
- fixedItem.width = 20.0f;
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
- {
- [items addObject:savebtn];
-
- [items addObject:fixedItem];
- }
-
- if (!self.isResume) {
- // 正常情况
- if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
- // customer的订单必须是Sales Order并且有提交权限才能提交
- if ([Singleton sharedInstance].currentOrderIsMerged && [Singleton sharedInstance].permissions_submit_order) {
-
- [items addObject:self.btnSubmitOrder];
- }
- } else {
- [items addObject:self.btnSubmitOrder];
- }
-
- } else {
- // 恢复
- if (self.userType == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
- // customer的订单必须是Sales Order并且有提交权限才能提交
- if (canSubmit) {
- [items addObject:self.btnSubmitOrder];
- }
- } else {
- [items addObject:self.btnSubmitOrder];
- }
- [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"urgency_resume"];
- [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"urgency_userType"];
- [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"urgency_submitOrder"];
- }
-
-
-
- // [items addObject:item2];
- self.navigationItem.rightBarButtonItems=items;
-
-
-
- if(appDelegate.can_submit_order)
- {
- [self.btnSubmitOrder setImage:submit_img];
-
- self.btnSubmitOrder.enabled = true;
- }
- else
- {
- [self.btnSubmitOrder setImage:nil];
- self.btnSubmitOrder.enabled = false;
- }
-
- self.navigationController.navigationBarHidden=false;
-
- }
- -(void) download_success
- {
- // 用于处理不同child,在成功去的数据后,需要附加的操作。
-
- self.have_tail=[[self.content_data_download valueForKey:@"has_reItem"] boolValue];
-
- NSString* order_customerid=[self getValue:@"customer_cid"];
-
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- appDelegate.order_customer_id = order_customerid;
-
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.editable = YES;
-
- UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"close"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(onCloseClick:)];
- //[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Close", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCloseClick:)];
- // closeButton.title = @"Close";
-
- self.navigationItem.leftBarButtonItem = closeButton;
-
- // self.navigationItem.backBarButtonItem = backButton;
-
-
- // Do any additional setup after loading the view.
- }
- - (void)onCommitOrderClick:(id)sender {
- // get customer info
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- // if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
- //
- // // 检查价格类型
- // // 提货价才能提交订单
- // /** 价格类型
- // * 0 提货价
- // * 1 统一价
- // * 2 计算价
- // */
- // NSInteger priceType = [Singleton sharedInstance].npd_shop_price_type;
- // if (priceType != 0) {
- //
- // NSString* pricename = nil;
- // switch (priceType) {
- // case 1:
- // pricename=flat_price;
- // break;
- // case 2:
- // pricename=given_price;
- // break;
- // default:
- // break;
- // }
- //
- // UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:[NSString stringWithFormat:@"Current price is %@, please change to %@ and try again.",pricename,[Singleton sharedInstance].deliveryString] preferredStyle:UIAlertControllerStyleAlert];
- //
- // UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- //
- // [alertVC dismissViewControllerAnimated:YES completion:nil];
- //
- // }];
- //
- //
- // [alertVC addAction:cancelAction];
- //
- // [self presentViewController:alertVC animated:YES completion:nil];
- //
- // return;
- // }
- // }
-
-
- NSString* msg;
- #ifdef OFFLINE_MODE
- if(appDelegate.offline_mode)
- {
- msg=@"Are you sure to mark offline order as ready for submit?";
- }
- else
- #endif
- {
- msg=@"Submit order now?";
-
- // if(appDelegate.user_type == USER_ROLE_CUSTOMER) {
- //
- // NSString *specialInstuction = [Singleton sharedInstance].specialInstruction;
- // NSString * deliverprice=[Singleton sharedInstance].deliveryString;
- // msg = [NSString stringWithFormat:@"Are you sure to submit order?\n\n1. Your price type is %@, Order will sent to NPD with this price.",deliverprice];
- // if (specialInstuction.length) {
- // msg = [msg stringByAppendingFormat:@"\n2. Special Instruction: %@.",specialInstuction];
- // }
- //
- // }
- }
-
-
- // 2017-03-20 修改
- //
- // CustomIOSAlertView *alertView = [[CustomIOSAlertView alloc] init];
- //
- //
- //
- //
- // // Add some custom content to the alert view
- // [alertView setContainerView:[self createDemoView:msg]];
- //
- // // Modify the parameters
- //
- //
- // NSArray *titleArr = [NSMutableArray arrayWithObjects:@"NO",@"YES", nil];
- // [alertView setButtonTitles:titleArr];
- // //[alertView setDelegate:self];
- //
- // // You may use a Block, rather than a delegate.
- // [alertView setOnButtonTouchUpInside:^(CustomIOSAlertView *alertView, int buttonIndex) {
- // // DebugLog(@"Block: Button at position %d is clicked on alertView %d.", buttonIndex, (int)[alertView tag]);
- // if(buttonIndex==0)
- // [alertView close];
- // else
- // {
- // // add params check here.
- // [self.lastedit endEditing:true];
- // [self.lasttextview endEditing:true];
- //
- //
- //
- // // self.cancommit=true;
- // // NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init];
- // // [upparams setValue:[self.params valueForKey:@"cart2Checkbox"] forKey:@"cart2Checkbox"];
- // // int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
- // // for(int i=0;i<section_count;i++)
- // // {
- // // NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
- // // int item_count = [[sectionjson valueForKey:@"count"] intValue];
- // // for(int j=0;j<item_count;j++)
- // // {
- // // NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
- // // NSString* key = [itemjson valueForKey:@"name"];
- // // if(key==nil || key.length==0)
- // // continue;
- // // if([[itemjson valueForKey:@"control"] isEqualToString:@"enum"])
- // // {
- // // NSString* single_select = [itemjson valueForKey:@"single_select"];
- // // if([single_select isEqualToString:@"true"])
- // // {
- // // NSDictionary* cadejson=[itemjson objectForKey:@"cadedate"];
- // // int count = [[cadejson valueForKey:@"count"] intValue];
- // // bool setvalue = false;
- // // for(int cc=0;cc<count;cc++)
- // // {
- // // NSDictionary* valjson=[cadejson objectForKey:[NSString stringWithFormat:@"val_%d",cc]];
- // // if([[valjson valueForKey:@"check"]intValue]==1)
- // // {
- // // [upparams setValue:[valjson valueForKey:@"value_id"] forKey:[itemjson valueForKey:@"name"]];
- // // setvalue=true;
- // // break;
- // // }
- // // }
- // // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
- // // {
- // // self.cancommit = false;
- // // }
- // // }
- // // else
- // // {
- // // //not support multi select for now;
- // // }
- // // /*
- // // upparams setValue:itemjson forKey:<#(NSString *)#>
- // //
- // // */
- // // }else
- // // if([[itemjson valueForKey:@"control"] isEqualToString:@"action"])
- // // {
- // // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"data"]==nil)
- // // self.cancommit = false;
- // // }
- // // else if([[itemjson valueForKey:@"control"] isEqualToString:@"signature"])
- // // {
- // // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"value"] ==nil)
- // // self.cancommit = false;
- // //
- // // NSString* valuestr = [itemjson valueForKey:@"value"];
- // // [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
- // // }
- // // else if([[itemjson valueForKey:@"control"] isEqualToString:@"switch"])
- // // {
- // // NSString* valuestr = [itemjson valueForKey:@"value"];
- // // [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
- // //
- // // NSString* value = [itemjson valueForKey:@"value"];
- // // NSMutableDictionary* boolitem=nil;
- // // NSMutableDictionary* subjson=nil;
- // // if([value isEqualToString:@"true"])
- // // {
- // // boolitem =[[itemjson objectForKey:@"true"] mutableCopy];
- // //
- // // }
- // // else
- // // {
- // // boolitem =[[itemjson objectForKey:@"false"] mutableCopy];
- // //
- // // }
- // // subjson=[[boolitem objectForKey:@"sub_item"] mutableCopy];
- // // if( subjson!=nil /*&& !active*/)
- // // {
- // // int sub_count = [[subjson valueForKey:@"count"] intValue];
- // // for(int l=0;l<sub_count;l++)
- // // {
- // // NSMutableDictionary * modify_item=[[subjson objectForKey:[NSString stringWithFormat:@"item_%d",l ]] mutableCopy];
- // //
- // //
- // //
- // //
- // // if([modify_item valueForKey:@"value"]!=nil && ![[modify_item valueForKey:@"value"]isEqualToString:@""])
- // // [upparams setValue:[modify_item valueForKey:@"value"] forKey:[modify_item valueForKey:@"name"]];
- // // else
- // // {
- // // if([[modify_item valueForKey:@"required"] isEqualToString: @"true"] )
- // // self.cancommit = false;
- // // }
- // // }
- // //
- // //
- // //
- // // }
- // // }
- // // else
- // // {
- // // if([itemjson valueForKey:@"value"]!=nil && ![[itemjson valueForKey:@"value"]isEqualToString:@""])
- // // [upparams setValue:[itemjson valueForKey:@"value"] forKey:[itemjson valueForKey:@"name"]];
- // // else
- // // {
- // // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
- // // self.cancommit = false;
- // // }
- // // }
- // // upparams= [self subitem_param:itemjson addto:upparams ];
- // // }
- // // }
- // // if(self.cancommit==false)
- // // {
- // // [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
- // // self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
- // // //DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
- // // //[self.editorTable reloadData ];
- // // [self.editorTable reloadData];
- // // // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- // // return;
- // // }
- //
- // NSMutableDictionary* upparams = [self check_cancommit:true];
- // if(self.cancommit==false)
- // return;
- //
- // if(upparams[@"shipping"]==nil)
- // goto commit_order;
- // if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
- // {
- // upparams[@"shipping"] = nil;
- // goto commit_order;
- // }
- // else if([upparams[@"shipping"] doubleValue]==0)
- // {
- //
- //
- // UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Shipping is $0.00, continue submit?" message:nil preferredStyle:UIAlertControllerStyleAlert];
- // //block代码块取代了delegate
- //
- //
- //
- // UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action)
- // {
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- //
- // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
- // {
- //
- // if(/*!self.have_tail*/ true)
- // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
- // [upparams setValue:@"false" forKey:@"isHold"];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- //
- // if([[editor_json valueForKey:@"result"] intValue]==2)
- // {
- // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
- //
- // // debug aaa
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // NSString* company= appDelegate.customerInfo[@"customer_name"];
- // NSString* send_to =appDelegate.customerInfo[@"customer_email"];
- //
- // // appDelegate.customerInfo = customerInfo;
- // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
- // // appDelegate.order_code = nil;
- // [appDelegate closeOrder];
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- //
- // NSString* title=nil;
- // NSString* msg=nil;
- // if(appDelegate.offline_mode)
- // {
- // title=TITLE_OFFLINE_SUBMIT;
- // msg=MSG_OFFLINE_SUBMIT;
- // }
- // else
- // {
- // title=@"Submit successful.";
- // msg=[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]];
- // }
- //
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- //
- // [alert show];
- //
- // NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
- // NSString* email_content =[editor_json valueForKey:@"email_content"];
- // NSString* soid=[editor_json valueForKey:@"so#"];
- // // if(pdf_url.length>0)
- // // {
- // //
- // // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
- // // //[self downloadpdf:pdf_url];
- // //
- // //
- // // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
- // // {
- // // //bbb
- // // [((MainViewController*)appDelegate.main_vc) Loginout:false];
- // // }
- // //
- // // [self prepareReturn:nil];
- // //
- // // [self.navigationController popViewControllerAnimated:true];
- // //
- // // [appDelegate printPdf:pdf_url];
- // //// if(self.printPdfCallback)
- // //// self.printPdfCallback(pdf_url);
- // // }
- // // else
- // {
- // if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
- // {
- // //bbb
- // [((MainViewController*)appDelegate.main_vc) Loginout:false];
- // }
- // [self prepareReturn:nil];
- //
- // [self.navigationController popViewControllerAnimated:true];
- //
- // if(pdf_url.length>0)
- // {
- //
- // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
- // [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
- // // [appDelegate printPdf:pdf_url];
- //
- // }
- // }
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- // }
- // else
- // {
- // 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];
- //
- //
- // alert.tag = KEEP_TAIL;
- //
- //
- // self.upparams = upparams;
- //
- // [alert show];
- // }
- //
- // }
- // else
- // { //USER_ROLE_CUSTOMER
- //
- // // if(self.have_tail)
- // // [upparams setValue:@"true" forKey:@"isHold"];
- // // else
- // // [upparams setValue:@"false" forKey:@"isHold"];
- // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
- //
- // [upparams setValue:@"true" forKey:@"isHold"];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- // if([[editor_json valueForKey:@"result"] intValue]==2)
- // {
- // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
- //
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // // appDelegate.customerInfo = customerInfo;
- //
- // // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
- // // appDelegate.order_code = orderCode;
- // // appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
- // [appDelegate closeOrder];
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- //
- // NSString* title=nil;
- // NSString* msg=nil;
- // if(appDelegate.offline_mode)
- // {
- // title=TITLE_OFFLINE_SUBMIT;
- // msg=MSG_OFFLINE_SUBMIT;
- // }
- // else
- // {
- // title=@"Submit successful.";
- // msg=[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]];
- // }
- //
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- //
- // [alert show];
- // // // self.labelContact.text=appDelegate.contact_name;
- // //
- // // NSDictionary * customerinfo = appDelegate.customerInfo;
- // [self prepareReturn:nil];
- // [self.navigationController popViewControllerAnimated:true];
- // // [self.navigationController dismissViewControllerAnimated:true completion:^{
- // //
- // //
- // // ;
- // // }];
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- //
- // }
- //
- //
- //
- // }];
- //
- // UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
- // //DebugLog(@"Cancel");
- //
- //
- // }];
- // [alertControl addAction:actionOne];
- //
- // [alertControl addAction:alertthree];
- //
- // //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
- //
- //
- //
- //
- // [self presentViewController:alertControl animated:YES completion:nil];
- //
- //
- //
- // }
- // else
- // {
- // commit_order:
- //
- // {
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- //
- // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
- // {
- //
- // if(/*!self.have_tail*/ true)
- // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
- // [upparams setValue:@"false" forKey:@"isHold"];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- //
- // if([[editor_json valueForKey:@"result"] intValue]==2)
- // {
- //
- // //debug bbb
- // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
- //
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // NSString* company= appDelegate.customerInfo[@"customer_name"];
- // NSString* send_to =appDelegate.customerInfo[@"customer_email"];
- // // appDelegate.customerInfo = customerInfo;
- // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
- // // appDelegate.order_code = nil;
- // [appDelegate closeOrder];
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- //
- // NSString* title=nil;
- // NSString* msg=nil;
- // if(appDelegate.offline_mode)
- // {
- // title=TITLE_OFFLINE_SUBMIT;
- // msg=MSG_OFFLINE_SUBMIT;
- // }
- // else
- // {
- // title=@"Submit successful.";
- // msg=[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]];
- // }
- //
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- //
- // [alert show];
- //
- // NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
- // NSString* email_content =[editor_json valueForKey:@"email_content"];
- // NSString* soid=[editor_json valueForKey:@"so#"];
- // // if(pdf_url.length>0)
- // // {
- // //
- // // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
- // //// [self downloadpdf:pdf_url];
- // //
- // //
- // // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
- // // {
- // // //bbb
- // // [((MainViewController*)appDelegate.main_vc) Loginout:false];
- // // }
- // //
- // // [self prepareReturn:nil];
- // //
- // // [self.navigationController popViewControllerAnimated:true];
- // //
- // // [appDelegate printPdf:pdf_url];
- // //
- // //// if(self.printPdfCallback)
- // //// self.printPdfCallback(pdf_url);
- // // }
- // // else
- // {
- // if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
- // {
- // //bbb
- // [((MainViewController*)appDelegate.main_vc) Loginout:false];
- // }
- // [self prepareReturn:nil];
- //
- // [self.navigationController popViewControllerAnimated:true];
- //
- //
- // if(pdf_url.length>0)
- // {
- //
- // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- // [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
- //
- //
- // }
- //
- //
- // }
- // // // self.labelContact.text=appDelegate.contact_name;
- // //
- // // NSDictionary * customerinfo = appDelegate.customerInfo;
- //
- //
- //
- //
- //
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- // }
- // else
- // {
- // 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];
- //
- //
- // alert.tag = KEEP_TAIL;
- //
- //
- // self.upparams = upparams;
- //
- // [alert show];
- // }
- //
- // }
- // else
- // { //USER_ROLE_CUSTOMER
- //
- // // if(self.have_tail)
- // // [upparams setValue:@"true" forKey:@"isHold"];
- // // else
- // // [upparams setValue:@"false" forKey:@"isHold"];
- // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
- //
- // [upparams setValue:@"true" forKey:@"isHold"];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:upparams];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- // if([[editor_json valueForKey:@"result"] intValue]==2)
- // {
- // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
- //
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // // appDelegate.customerInfo = customerInfo;
- //
- // // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
- // // appDelegate.order_code = orderCode;
- // // appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
- // [appDelegate closeOrder];
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- //
- // NSString* title=nil;
- // NSString* msg=nil;
- // if(appDelegate.offline_mode)
- // {
- // title=TITLE_OFFLINE_SUBMIT;
- // msg=MSG_OFFLINE_SUBMIT;
- // }
- // else
- // {
- // title=@"Submit successful.";
- // msg=[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]];
- // }
- //
- //
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- //
- // [alert show];
- // // // self.labelContact.text=appDelegate.contact_name;
- // //
- // // NSDictionary * customerinfo = appDelegate.customerInfo;
- // [self prepareReturn:nil];
- // // [self.navigationController dismissViewControllerAnimated:true completion:^{
- // //
- // //
- // // ;
- // // }];
- // [self.navigationController popViewControllerAnimated:true];
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- //
- // }
- // }
- //
- //
- //
- //
- // }
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- // }
- // }];
- //
- // // [alertView setUseMotionEffects:true];
- //
- //
- // // And launch the dialog
- //
- // [alertView sizeToFit];
- // [alertView show];
-
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Submit Confirm.", nil) message:NSLocalizedString(msg, nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
- //
- // alert.tag = SUBMIT_CONFIRM;
- // [alert show];
- //
-
- UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Order Submission" message:msg preferredStyle:UIAlertControllerStyleAlert];
-
- UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"YES" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
-
- {
- // add params check here.
- [self.lastedit endEditing:true];
- [self.lasttextview endEditing:true];
-
- NSMutableDictionary* upparams = [self check_cancommit:true];
- if(self.cancommit==false)
- return;
-
- // 2018-1-2 Modify
- if(appDelegate.user_type == USER_ROLE_CUSTOMER)
- {
- [self customer_commit_order:upparams];
- }
- else // USER_ROLE_EMPLOYEE
- {
- if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
- {
- upparams[@"shipping"] = nil;
-
- }
- if(upparams[@"shipping"]==nil || [upparams[@"shipping"] doubleValue]!=0)
- [self empolyee_commit_order:upparams];
- else
- {
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Shipping is $0.00, continue submit?" message:nil preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action)
- {
- //yes
- [self empolyee_commit_order:upparams];
-
- }];
- UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
- //DebugLog(@"Cancel");
-
-
- }];
-
- [alertControl addAction:actionOne];
- [alertControl addAction:alertthree];
-
- [self presentViewController:alertControl animated:YES completion:nil];
- }
-
- }
-
- // if(upparams[@"shipping"]==nil)
- // goto commit_order;
- // if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
- // {
- // upparams[@"shipping"] = nil;
- // goto commit_order;
- // }
- // else if([upparams[@"shipping"] doubleValue]==0)
- // {
- //
- //
- // UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Shipping is $0.00, continue submit?" message:nil preferredStyle:UIAlertControllerStyleAlert];
- // //block代码块取代了delegate
- //
- //
- //
- // UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action)
- // {
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- //
- // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
- // {
- //
- // if(/*!self.have_tail*/ true)
- // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
- // [upparams setValue:@"false" forKey:@"isHold"];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- //
- // if([[editor_json valueForKey:@"result"] intValue]==2)
- // {
- // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
- //
- // // debug aaa
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // NSString* company= appDelegate.customerInfo[@"customer_name"];
- // NSString* send_to =appDelegate.customerInfo[@"customer_email"];
- //
- // // appDelegate.customerInfo = customerInfo;
- // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
- // // appDelegate.order_code = nil;
- // [appDelegate closeOrder];
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- //
- // NSString* title=nil;
- // NSString* msg=nil;
- //#ifdef OFFLINE_MODE
- // if(appDelegate.offline_mode)
- // {
- // title=TITLE_OFFLINE_SUBMIT;
- // msg=MSG_OFFLINE_SUBMIT;
- // }
- // else
- //#endif
- // {
- // title=@"Order submitted sucessfully";
- // msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
- // }
- //
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- //
- // [alert show];
- //
- // NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
- // NSString* email_content =[editor_json valueForKey:@"email_content"];
- // NSString* soid=[editor_json valueForKey:@"so#"];
- // // if(pdf_url.length>0)
- // // {
- // //
- // // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
- // // //[self downloadpdf:pdf_url];
- // //
- // //
- // // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
- // // {
- // // //bbb
- // // [((MainViewController*)appDelegate.main_vc) Loginout:false];
- // // }
- // //
- // // [self prepareReturn:nil];
- // //
- // // [self.navigationController popViewControllerAnimated:true];
- // //
- // // [appDelegate printPdf:pdf_url];
- // //// if(self.printPdfCallback)
- // //// self.printPdfCallback(pdf_url);
- // // }
- // // else
- // {
- // if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
- // {
- // //bbb
- // [((MainViewController*)appDelegate.main_vc) Loginout:false];
- // }
- // [self prepareReturn:nil];
- //
- // [self.navigationController popViewControllerAnimated:true];
- //
- // if(pdf_url.length>0)
- // {
- //
- // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
- // [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
- // // [appDelegate printPdf:pdf_url];
- //
- // }
- // }
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- // }
- // else
- // {
- // 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];
- //
- //
- // alert.tag = KEEP_TAIL;
- //
- //
- // self.upparams = upparams;
- //
- // [alert show];
- // }
- //
- // }
- // else
- // { //USER_ROLE_CUSTOMER
- //
- // // if(self.have_tail)
- // // [upparams setValue:@"true" forKey:@"isHold"];
- // // else
- // // [upparams setValue:@"false" forKey:@"isHold"];
- // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
- //
- // [upparams setValue:@"true" forKey:@"isHold"];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- // if([[editor_json valueForKey:@"result"] intValue]==2)
- // {
- // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
- //
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // // appDelegate.customerInfo = customerInfo;
- //
- // // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
- // // appDelegate.order_code = orderCode;
- // // appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
- // [appDelegate closeOrder];
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- //
- // NSString* title=nil;
- // NSString* msg=nil;
- //#ifdef OFFLINE_MODE
- // if(appDelegate.offline_mode)
- // {
- // title=TITLE_OFFLINE_SUBMIT;
- // msg=MSG_OFFLINE_SUBMIT;
- // }
- // else
- //#endif
- // {
- // title=@"Order submitted sucessfully";
- // msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
- // }
- //
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- //
- // [alert show];
- // // // self.labelContact.text=appDelegate.contact_name;
- // //
- // // NSDictionary * customerinfo = appDelegate.customerInfo;
- // [self prepareReturn:nil];
- // [self.navigationController popViewControllerAnimated:true];
- // // [self.navigationController dismissViewControllerAnimated:true completion:^{
- // //
- // //
- // // ;
- // // }];
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- //
- // }
- //
- //
- //
- // }];
- //
- // UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
- // //DebugLog(@"Cancel");
- //
- //
- // }];
- // [alertControl addAction:actionOne];
- //
- // [alertControl addAction:alertthree];
- //
- // //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
- //
- //
- //
- //
- // [self presentViewController:alertControl animated:YES completion:nil];
- //
- //
- //
- // }
- // else
- // {
- // commit_order:
- //
- // {
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- //
- // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
- // {
- //
- // if(/*!self.have_tail*/ true)
- // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
- // [upparams setValue:@"false" forKey:@"isHold"];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- //
- // if([[editor_json valueForKey:@"result"] intValue]==2)
- // {
- //
- // //debug bbb
- // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
- //
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // NSString* company= appDelegate.customerInfo[@"customer_name"];
- // NSString* send_to =appDelegate.customerInfo[@"customer_email"];
- // // appDelegate.customerInfo = customerInfo;
- // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
- // // appDelegate.order_code = nil;
- // [appDelegate closeOrder];
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- //
- // NSString* title=nil;
- // NSString* msg=nil;
- //#ifdef OFFLINE_MODE
- // if(appDelegate.offline_mode)
- // {
- // title=TITLE_OFFLINE_SUBMIT;
- // msg=MSG_OFFLINE_SUBMIT;
- // }
- // else
- //#endif
- // {
- // title=@"Order submitted sucessfully";
- // msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
- // }
- //
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- //
- // [alert show];
- //
- // NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
- // NSString* email_content =[editor_json valueForKey:@"email_content"];
- // NSString* soid=[editor_json valueForKey:@"so#"];
- // // if(pdf_url.length>0)
- // // {
- // //
- // // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
- // //// [self downloadpdf:pdf_url];
- // //
- // //
- // // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
- // // {
- // // //bbb
- // // [((MainViewController*)appDelegate.main_vc) Loginout:false];
- // // }
- // //
- // // [self prepareReturn:nil];
- // //
- // // [self.navigationController popViewControllerAnimated:true];
- // //
- // // [appDelegate printPdf:pdf_url];
- // //
- // //// if(self.printPdfCallback)
- // //// self.printPdfCallback(pdf_url);
- // // }
- // // else
- // {
- // NSMutableDictionary* value=[[NSMutableDictionary alloc]init];
- // if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
- // {
- // //bbb
- // [((MainViewController*)appDelegate.main_vc) Loginout:false];
- // value[@"commitorder_logout"]=@"true";
- // }
- //
- //
- // value[@"is_subaction"] = self.params[@"is_subaction"];
- // value[@"subaction_tag"] = self.params[@"subaction_tag"];
- //
- // [self prepareReturn:value];
- //
- // [self.navigationController popViewControllerAnimated:true];
- //
- //
- // if(pdf_url.length>0)
- // {
- //
- // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- // [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
- //
- //
- // }
- //
- //
- // }
- // // // self.labelContact.text=appDelegate.contact_name;
- // //
- // // NSDictionary * customerinfo = appDelegate.customerInfo;
- //
- //
- //
- //
- //
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- // }
- // else
- // {
- // 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];
- //
- //
- // alert.tag = KEEP_TAIL;
- //
- //
- // self.upparams = upparams;
- //
- // [alert show];
- // }
- //
- // }
- // else
- // { //USER_ROLE_CUSTOMER
- //
- // // if(self.have_tail)
- // // [upparams setValue:@"true" forKey:@"isHold"];
- // // else
- // // [upparams setValue:@"false" forKey:@"isHold"];
- // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
- //
- // [upparams setValue:@"true" forKey:@"isHold"];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- // if([[editor_json valueForKey:@"result"] intValue]==2)
- // {
- // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
- //
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // // appDelegate.customerInfo = customerInfo;
- //
- // // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
- // // appDelegate.order_code = orderCode;
- // // appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
- // [appDelegate closeOrder];
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- //
- // NSString* title=nil;
- // NSString* msg=nil;
- //#ifdef OFFLINE_MODE
- // if(appDelegate.offline_mode)
- // {
- // title=TITLE_OFFLINE_SUBMIT;
- // msg=MSG_OFFLINE_SUBMIT;
- // }
- // else
- //#endif
- // {
- // title=@"Order submitted sucessfully";
- // msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
- // }
- //
- //
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- //
- // [alert show];
- // // // self.labelContact.text=appDelegate.contact_name;
- // //
- // // NSDictionary * customerinfo = appDelegate.customerInfo;
- // [self prepareReturn:nil];
- // // [self.navigationController dismissViewControllerAnimated:true completion:^{
- // //
- // //
- // // ;
- // // }];
- // [self.navigationController popViewControllerAnimated:true];
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- //
- // }
- // }
- //
- //
- //
- //
- // }
-
- }
-
- }];
-
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"NO" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
-
- [alertVC addAction:yesAction];
- [alertVC addAction:cancelAction];
-
- [self presentViewController:alertVC animated:yesAction completion:nil];
-
- }
- - (UIView *)createDemoView:(NSString*) msg
- {
- UIView *demoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 290, 200)];
-
- // UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 270, 180)];
- // [imageView setImage:[UIImage imageNamed:@"demo"]];
-
- UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 270, 10)];
- titleLabel.font = [UIFont boldSystemFontOfSize:20];
- titleLabel.text=@"Order Submission";
- titleLabel.numberOfLines = 0;
- titleLabel.lineBreakMode =NSLineBreakByWordWrapping;
- // titleLabel.textAlignment = NSTextAlignmentRight;
- titleLabel.textAlignment = NSTextAlignmentCenter;
- CGSize constraintkey = CGSizeMake(270, 20000.0f);//key label width is 40% cell width;
- CGSize sizetitle = [titleLabel.text=@"Order Submission" sizeWithFont:[UIFont systemFontOfSize:20.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
-
- //[titleLabel sizeToFit];
- // titleLabel.center.x = demoView.center.x;
- titleLabel.frame = CGRectMake(10, 10, 270, sizetitle.height);
- [demoView addSubview:titleLabel];
-
- UILabel *lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 260, 10)];
- lineLabel.font = [UIFont systemFontOfSize:17];
- lineLabel.text=msg;
- lineLabel.numberOfLines = 0;
- lineLabel.lineBreakMode =NSLineBreakByWordWrapping;
-
- CGSize sizemsg = [msg sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
-
- lineLabel.frame = CGRectMake(15, titleLabel.frame.origin.y+ titleLabel.frame.size.height+20, 260, sizemsg.height);
- //[lineLabel sizeToFit];
-
- [demoView addSubview:lineLabel];
- demoView.frame = CGRectMake(0, 0, 290, lineLabel.frame.origin.y+lineLabel.frame.size.height+25);
- return demoView;
- }
- - (void)onCloseClick:(UIButton *)sender {
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- if (self.resumeOrder) {
- [appDelegate.main_vc.navigationController popViewControllerAnimated:YES];
- return;
- }
-
-
- //
- // NSRange range = [tempStr rangeOfString:@")\">"];//判断字符串是否包含
- //
- // //if (range.location ==NSNotFound)//不包含
- // if (range.length >0)//包含
- // {
- //
- //
- //
- // }
- // else//不包含
- // {
- //
- // }
- UIAlertView * alert = nil;
- if(appDelegate.order_status==0)
- {
- 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];
-
- }
- else
- {
- 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];
-
- }
-
-
- alert.tag = CLOSE_ACTION;
- // alert.
- [alert show];
-
-
- // if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
- // appDelegate.order_code = nil;
- //
- // }
-
-
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (IBAction)onSaveClick:(id)sender {
- // id foo = nil;
- // [[NSMutableArray array] addObject:foo];
- // add params check here.
- [self.lastedit endEditing:true];
- [self.lasttextview endEditing:true];
- // self.cancommit=true;
- // NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init];
- // [upparams setValue:[self.params valueForKey:@"cart2Checkbox"] forKey:@"cart2Checkbox"];
- // int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
- // for(int i=0;i<section_count;i++)
- // {
- // NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
- // int item_count = [[sectionjson valueForKey:@"count"] intValue];
- // for(int j=0;j<item_count;j++)
- // {
- // NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
- // NSString* key = [itemjson valueForKey:@"name"];
- // if(key==nil || key.length==0)
- // continue;
- // if([[itemjson valueForKey:@"control"] isEqualToString:@"enum"])
- // {
- // NSString* single_select = [itemjson valueForKey:@"single_select"];
- // if([single_select isEqualToString:@"true"])
- // {
- // NSDictionary* cadejson=[itemjson objectForKey:@"cadedate"];
- // int count = [[cadejson valueForKey:@"count"] intValue];
- // bool setvalue = false;
- // for(int cc=0;cc<count;cc++)
- // {
- // NSDictionary* valjson=[cadejson objectForKey:[NSString stringWithFormat:@"val_%d",cc]];
- // if([[valjson valueForKey:@"check"]intValue]==1)
- // {
- // [upparams setValue:[valjson valueForKey:@"value_id"] forKey:[itemjson valueForKey:@"name"]];
- // setvalue=true;
- // break;
- // }
- // }
- // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
- // {
- // self.cancommit = false;
- // }
- // }
- // else
- // {
- // //not support multi select for now;
- // }
- // /*
- // upparams setValue:itemjson forKey:<#(NSString *)#>
- //
- // */
- // }else
- // if([[itemjson valueForKey:@"control"] isEqualToString:@"action"])
- // {
- // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"data"]==nil)
- // self.cancommit = false;
- // }
- // else if([[itemjson valueForKey:@"control"] isEqualToString:@"signature"])
- // {
- // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"value"]==nil)
- // self.cancommit = false;
- //
- // NSString* valuestr = [itemjson valueForKey:@"value"];
- // [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
- // }
- // else if([[itemjson valueForKey:@"control"] isEqualToString:@"switch"])
- // {
- // NSString* valuestr = [itemjson valueForKey:@"value"];
- // [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
- //
- // NSString* value = [itemjson valueForKey:@"value"];
- // NSMutableDictionary* boolitem=nil;
- // NSMutableDictionary* subjson=nil;
- // if([value isEqualToString:@"true"])
- // {
- // boolitem =[[itemjson objectForKey:@"true"] mutableCopy];
- //
- // }
- // else
- // {
- // boolitem =[[itemjson objectForKey:@"false"] mutableCopy];
- //
- // }
- // subjson=[[boolitem objectForKey:@"sub_item"] mutableCopy];
- // if( subjson!=nil /*&& !active*/)
- // {
- // int sub_count = [[subjson valueForKey:@"count"] intValue];
- // for(int l=0;l<sub_count;l++)
- // {
- // NSMutableDictionary * modify_item=[[subjson objectForKey:[NSString stringWithFormat:@"item_%d",l ]] mutableCopy];
- //
- //
- //
- //
- // if([modify_item valueForKey:@"value"]!=nil && ![[modify_item valueForKey:@"value"]isEqualToString:@""])
- // [upparams setValue:[modify_item valueForKey:@"value"] forKey:[modify_item valueForKey:@"name"]];
- // else
- // {
- // if([[modify_item valueForKey:@"required"] isEqualToString: @"true"] )
- // self.cancommit = false;
- // }
- // }
- //
- //
- //
- // }
- // }
- // else
- // {
- // if([itemjson valueForKey:@"value"]!=nil && ![[itemjson valueForKey:@"value"]isEqualToString:@""])
- // [upparams setValue:[itemjson valueForKey:@"value"] forKey:[itemjson valueForKey:@"name"]];
- // else
- // {
- // if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
- // self.cancommit = false;
- // }
- // }
- // upparams= [self subitem_param:itemjson addto:upparams ];
- // }
- // }
- // // save order 不检查必填项;
- // self.cancommit=true;
- // if(self.cancommit==false)
- // {
- // [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
- // self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
- // //DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
- // //[self.editorTable reloadData ];
- // [self.editorTable reloadData];
- // return;
- // }
-
- NSMutableDictionary* upparams = [self check_cancommit:false];
- // if(self.cancommit==false)
- // return;
-
- if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
- upparams[@"shipping"] = nil;
-
-
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Saving Order"];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* editor_json = [RANetwork save_Order:upparams];
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-
-
- if([[editor_json valueForKey:@"result"] intValue]==2)
- {
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
-
-
- NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
-
-
- if(appDelegate.user_type ==USER_ROLE_EMPLOYEE)
- {
- appDelegate.customerInfo = customerInfo;
- appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
- }
- NSString *msg = nil;
- if ([editor_json objectForKey:@"so#"]) {
- msg = [@"SO#:" stringByAppendingString:[editor_json objectForKey:@"so#"]];
- }
- [RAUtils message_alert:msg title:@"Order Saved" controller:self] ;
-
- if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.save_order_logout && appDelegate.user_type ==USER_ROLE_EMPLOYEE)
- {
- [((MainViewController*)appDelegate.main_vc) Loginout:false];
- [self prepareReturn:nil];
- [self.navigationController popViewControllerAnimated:true];
- }
-
- if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
-
- if (![Singleton sharedInstance].currentOrderIsMerged) {
- [self releaseOrderAfterSave];
- }
-
-
- }
-
-
- // if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
- // appDelegate.order_code = nil;
- //
- // }
- // // self.labelContact.text=appDelegate.contact_name;
- //
- // NSDictionary * customerinfo = appDelegate.customerInfo;
- // [self prepareReturn:nil];
- // [self.navigationController dismissViewControllerAnimated:true completion:^{
- //
- //
- // ;
- // }];
-
- }
- else
- {
- [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:self] ;
- }
-
-
-
-
- });
- });
-
- }
- - (void)textFieldDidEndEditing:(UITextField *)textField
- {
-
- [super textFieldDidEndEditing:textField];
-
- UITableViewCell *cell = (UITableViewCell *) textField.superview.superview;
- NSIndexPath * indexPath = [self.editorTable indexPathForCell:cell];
-
-
- NSMutableDictionary* section_json=nil;
-
-
- // DebugLog(@"endedit %d_%d",indexPath.section,indexPath.row);
- NSMutableDictionary* item_json =[((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row] mutableCopy];
-
-
- NSString* name = [item_json valueForKey:@"name"];
-
- if([name isEqualToString:@"shipping"]|| [name isEqualToString:@"handling_fee_value"]||[name isEqualToString:@"lift_gate_value"]||[name isEqualToString:@"tax_percentage"])
- {
- float shipping = [self getprice:@"shipping" section:indexPath.section];
- float paymentsAndCredits = [self getprice:@"paymentsAndCredits" section:indexPath.section];
- float handling_fee_value = [self getprice:@"handling_fee_value" section:indexPath.section];
- float lift_gate =[self getprice:@"lift_gate_value" section:indexPath.section];
- float tax = [self getprice:@"tax_percentage" section:indexPath.section]/100.0*paymentsAndCredits;
- float totalprice=shipping+paymentsAndCredits+handling_fee_value+lift_gate+tax;
-
- section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
- int count=0;
-
- count=[[section_json valueForKey:@"count"] intValue];
-
- int total_row_idx=-1;
-
- for(int i=0;i<count;i++)
- {
- NSDictionary * olditem=[[section_json objectForKey:[NSString stringWithFormat:@"item_%d",i ]] mutableCopy];
- if([[olditem valueForKey:@"name"] isEqualToString:@"totalPrice" ])
- {
- [olditem setValue:[NSString stringWithFormat:@"%.2f",totalprice] forKey:@"value"];
- [olditem setValue:@"true" forKey:@"dirty"];
- [section_json setObject:olditem forKey:[NSString stringWithFormat:@"item_%d",i ]];
-
- total_row_idx=i;
-
- }
-
- }
-
- [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
-
-
- self.content_data_control = [self translate_json:self.content_data_download changed: self.changed_data];
-
-
- if(total_row_idx>=0)
- {
-
-
-
- NSUInteger newIndex[] = {indexPath.section, total_row_idx};
- NSIndexPath *newPath = [[NSIndexPath alloc] initWithIndexes:newIndex length:2];
- // DebugLog(@"before refresh %@",NSStringFromCGSize(self.editorTable.contentSize));
- [self.editorTable reloadRowsAtIndexPaths:@[newPath]withRowAnimation:UITableViewRowAnimationMiddle];
-
- // DebugLog(@"after refresh %@",NSStringFromCGSize(self.editorTable.contentSize));
-
-
- // CGSize tablecontent =self.editorTable.contentSize;
- // tablecontent.height=tablecontent.height+self.keyboard_h;
- // self.editorTable.contentSize=tablecontent;
- //
- //
- // DebugLog(@"resize to %@",NSStringFromCGSize(self.editorTable.contentSize));
- }
-
- // self.content_data = [editor_json mutableCopy];
- // self.content_data = [self translate_json:editor_json];
-
- // NSMutableDictionary* content_data1 = [self translate_json:self.content_data];
-
- // [self.editorTable reloadData];
-
- }
- //
- // [item_json setValue:@"true" forKey:@"dirty"];
- // [item_json setValue:textField.text forKey:@"value"];
- }
- -(float) getprice:(NSString*) name section :(long) index
- {
- NSMutableDictionary* section_json=nil;
- section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",index ]] mutableCopy];
- int count=0;
-
- count=[[section_json valueForKey:@"count"] intValue];
-
- for(int i=0;i<count;i++)
- {
- NSDictionary * olditem=[[section_json objectForKey:[NSString stringWithFormat:@"item_%d",i ]] mutableCopy];
- if([[olditem valueForKey:@"name"] isEqualToString:name])
- {
- return [[olditem valueForKey:@"value"] floatValue];
-
- }
-
- }
-
- return 0;
- }
- /*
- #pragma mark - Navigation
-
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- #pragma mark - UIAlertViewDelegate
- // Called when a button is clicked. The view will be automatically dismissed after this call returns
- - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- {
-
- if(buttonIndex!=alertView.cancelButtonIndex && alertView.tag == SUBMIT_CONFIRM)
- {
- // // add params check here.
- // [self.lastedit endEditing:true];
- // [self.lasttextview endEditing:true];
- //
- //
- //
- //// self.cancommit=true;
- //// NSMutableDictionary* upparams=[[NSMutableDictionary alloc] init];
- //// [upparams setValue:[self.params valueForKey:@"cart2Checkbox"] forKey:@"cart2Checkbox"];
- //// int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
- //// for(int i=0;i<section_count;i++)
- //// {
- //// NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
- //// int item_count = [[sectionjson valueForKey:@"count"] intValue];
- //// for(int j=0;j<item_count;j++)
- //// {
- //// NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
- //// NSString* key = [itemjson valueForKey:@"name"];
- //// if(key==nil || key.length==0)
- //// continue;
- //// if([[itemjson valueForKey:@"control"] isEqualToString:@"enum"])
- //// {
- //// NSString* single_select = [itemjson valueForKey:@"single_select"];
- //// if([single_select isEqualToString:@"true"])
- //// {
- //// NSDictionary* cadejson=[itemjson objectForKey:@"cadedate"];
- //// int count = [[cadejson valueForKey:@"count"] intValue];
- //// bool setvalue = false;
- //// for(int cc=0;cc<count;cc++)
- //// {
- //// NSDictionary* valjson=[cadejson objectForKey:[NSString stringWithFormat:@"val_%d",cc]];
- //// if([[valjson valueForKey:@"check"]intValue]==1)
- //// {
- //// [upparams setValue:[valjson valueForKey:@"value_id"] forKey:[itemjson valueForKey:@"name"]];
- //// setvalue=true;
- //// break;
- //// }
- //// }
- //// if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && setvalue==false)
- //// {
- //// self.cancommit = false;
- //// }
- //// }
- //// else
- //// {
- //// //not support multi select for now;
- //// }
- //// /*
- //// upparams setValue:itemjson forKey:<#(NSString *)#>
- ////
- //// */
- //// }else
- //// if([[itemjson valueForKey:@"control"] isEqualToString:@"action"])
- //// {
- //// if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"data"]==nil)
- //// self.cancommit = false;
- //// }
- //// else if([[itemjson valueForKey:@"control"] isEqualToString:@"signature"])
- //// {
- //// if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] && [itemjson objectForKeyedSubscript:@"value"] ==nil)
- //// self.cancommit = false;
- ////
- //// NSString* valuestr = [itemjson valueForKey:@"value"];
- //// [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
- //// }
- //// else if([[itemjson valueForKey:@"control"] isEqualToString:@"switch"])
- //// {
- //// NSString* valuestr = [itemjson valueForKey:@"value"];
- //// [upparams setValue:valuestr forKey:[itemjson valueForKey:@"name"]];
- ////
- //// NSString* value = [itemjson valueForKey:@"value"];
- //// NSMutableDictionary* boolitem=nil;
- //// NSMutableDictionary* subjson=nil;
- //// if([value isEqualToString:@"true"])
- //// {
- //// boolitem =[[itemjson objectForKey:@"true"] mutableCopy];
- ////
- //// }
- //// else
- //// {
- //// boolitem =[[itemjson objectForKey:@"false"] mutableCopy];
- ////
- //// }
- //// subjson=[[boolitem objectForKey:@"sub_item"] mutableCopy];
- //// if( subjson!=nil /*&& !active*/)
- //// {
- //// int sub_count = [[subjson valueForKey:@"count"] intValue];
- //// for(int l=0;l<sub_count;l++)
- //// {
- //// NSMutableDictionary * modify_item=[[subjson objectForKey:[NSString stringWithFormat:@"item_%d",l ]] mutableCopy];
- ////
- ////
- ////
- ////
- //// if([modify_item valueForKey:@"value"]!=nil && ![[modify_item valueForKey:@"value"]isEqualToString:@""])
- //// [upparams setValue:[modify_item valueForKey:@"value"] forKey:[modify_item valueForKey:@"name"]];
- //// else
- //// {
- //// if([[modify_item valueForKey:@"required"] isEqualToString: @"true"] )
- //// self.cancommit = false;
- //// }
- //// }
- ////
- ////
- ////
- //// }
- //// }
- //// else
- //// {
- //// if([itemjson valueForKey:@"value"]!=nil && ![[itemjson valueForKey:@"value"]isEqualToString:@""])
- //// [upparams setValue:[itemjson valueForKey:@"value"] forKey:[itemjson valueForKey:@"name"]];
- //// else
- //// {
- //// if([[itemjson valueForKey:@"required"] isEqualToString: @"true"] )
- //// self.cancommit = false;
- //// }
- //// }
- //// upparams= [self subitem_param:itemjson addto:upparams ];
- //// }
- //// }
- //// if(self.cancommit==false)
- //// {
- //// [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
- //// self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
- //// //DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
- //// //[self.editorTable reloadData ];
- //// [self.editorTable reloadData];
- //// // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //// return;
- //// }
- //
- // NSMutableDictionary* upparams = [self check_cancommit:true];
- // if(self.cancommit==false)
- // return;
- //
- // if(upparams[@"shipping"]==nil)
- // goto commit_order;
- // if([upparams[@"shipping"] isEqualToString:@"Shipping To Be Quoted"]||[upparams[@"shipping"] isEqualToString:@"To Be Quoted"])
- // {
- // upparams[@"shipping"] = nil;
- // goto commit_order;
- // }
- // else if([upparams[@"shipping"] doubleValue]==0)
- // {
- //
- //
- // UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Shipping is $0.00, continue submit?" message:nil preferredStyle:UIAlertControllerStyleAlert];
- // //block代码块取代了delegate
- //
- //
- //
- // UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action)
- // {
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- //
- // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
- // {
- //
- // if(/*!self.have_tail*/ true)
- // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
- // [upparams setValue:@"false" forKey:@"isHold"];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- //
- // if([[editor_json valueForKey:@"result"] intValue]==2)
- // {
- // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
- //
- // // debug aaa
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // NSString* company= appDelegate.customerInfo[@"customer_name"];
- // NSString* send_to =appDelegate.customerInfo[@"customer_email"];
- //
- // // appDelegate.customerInfo = customerInfo;
- // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
- // // appDelegate.order_code = nil;
- // [appDelegate closeOrder];
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- //
- // NSString* title=nil;
- // NSString* msg=nil;
- //#ifdef OFFLINE_MODE
- // if(appDelegate.offline_mode)
- // {
- // title=TITLE_OFFLINE_SUBMIT;
- // msg=MSG_OFFLINE_SUBMIT;
- // }
- // else
- //#endif
- // {
- // title=@"Order submitted sucessfully";
- // msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
- // }
- //
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- //
- // [alert show];
- //
- // NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
- // NSString* email_content =[editor_json valueForKey:@"email_content"];
- // NSString* soid=[editor_json valueForKey:@"so#"];
- //// if(pdf_url.length>0)
- //// {
- ////
- //// [alert dismissWithClickedButtonIndex:0 animated:FALSE];
- //// //[self downloadpdf:pdf_url];
- ////
- ////
- //// if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
- //// {
- //// //bbb
- //// [((MainViewController*)appDelegate.main_vc) Loginout:false];
- //// }
- ////
- //// [self prepareReturn:nil];
- ////
- //// [self.navigationController popViewControllerAnimated:true];
- ////
- //// [appDelegate printPdf:pdf_url];
- ////// if(self.printPdfCallback)
- ////// self.printPdfCallback(pdf_url);
- //// }
- //// else
- // {
- // if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
- // {
- // //bbb
- // [((MainViewController*)appDelegate.main_vc) Loginout:false];
- // }
- // [self prepareReturn:nil];
- //
- // [self.navigationController popViewControllerAnimated:true];
- //
- // if(pdf_url.length>0)
- // {
- //
- // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
- // [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
- // // [appDelegate printPdf:pdf_url];
- //
- // }
- // }
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- // }
- // else
- // {
- // 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];
- //
- //
- // alert.tag = KEEP_TAIL;
- //
- //
- // self.upparams = upparams;
- //
- // [alert show];
- // }
- //
- // }
- // else
- // { //USER_ROLE_CUSTOMER
- //
- // // if(self.have_tail)
- // // [upparams setValue:@"true" forKey:@"isHold"];
- // // else
- // // [upparams setValue:@"false" forKey:@"isHold"];
- // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
- //
- // [upparams setValue:@"true" forKey:@"isHold"];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- // if([[editor_json valueForKey:@"result"] intValue]==2)
- // {
- // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
- //
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // // appDelegate.customerInfo = customerInfo;
- //
- //// NSString* orderCode = [editor_json valueForKey:@"orderCode"];
- //// appDelegate.order_code = orderCode;
- //// appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
- // [appDelegate closeOrder];
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- //
- // NSString* title=nil;
- // NSString* msg=nil;
- //#ifdef OFFLINE_MODE
- // if(appDelegate.offline_mode)
- // {
- // title=TITLE_OFFLINE_SUBMIT;
- // msg=MSG_OFFLINE_SUBMIT;
- // }
- // else
- //#endif
- // {
- // title=@"Order submitted sucessfully";
- // msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
- // }
- //
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- //
- // [alert show];
- // // // self.labelContact.text=appDelegate.contact_name;
- // //
- // // NSDictionary * customerinfo = appDelegate.customerInfo;
- // [self prepareReturn:nil];
- // [self.navigationController popViewControllerAnimated:true];
- // // [self.navigationController dismissViewControllerAnimated:true completion:^{
- // //
- // //
- // // ;
- // // }];
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- //
- // }
- //
- //
- //
- // }];
- //
- // UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
- // //DebugLog(@"Cancel");
- //
- //
- // }];
- // [alertControl addAction:actionOne];
- //
- // [alertControl addAction:alertthree];
- //
- // //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
- //
- //
- //
- //
- // [self presentViewController:alertControl animated:YES completion:nil];
- //
- //
- //
- // }
- // else
- // {
- // commit_order:
- //
- // {
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- //
- // if(appDelegate.user_type ==USER_ROLE_EMPLOYEE )
- // {
- //
- // if(/*!self.have_tail*/ true)
- // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
- // [upparams setValue:@"false" forKey:@"isHold"];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- //
- // if([[editor_json valueForKey:@"result"] intValue]==2)
- // {
- //
- // //debug bbb
- // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
- //
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // NSString* company= appDelegate.customerInfo[@"customer_name"];
- // NSString* send_to =appDelegate.customerInfo[@"customer_email"];
- // // appDelegate.customerInfo = customerInfo;
- // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
- // // appDelegate.order_code = nil;
- // [appDelegate closeOrder];
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- //
- // NSString* title=nil;
- // NSString* msg=nil;
- //#ifdef OFFLINE_MODE
- // if(appDelegate.offline_mode)
- // {
- // title=TITLE_OFFLINE_SUBMIT;
- // msg=MSG_OFFLINE_SUBMIT;
- // }
- // else
- //#endif
- // {
- // title=@"Order submitted sucessfully";
- // msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
- // }
- //
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- //
- // [alert show];
- //
- // NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
- // NSString* email_content =[editor_json valueForKey:@"email_content"];
- // NSString* soid=[editor_json valueForKey:@"so#"];
- //// if(pdf_url.length>0)
- //// {
- ////
- //// [alert dismissWithClickedButtonIndex:0 animated:FALSE];
- ////// [self downloadpdf:pdf_url];
- ////
- ////
- //// if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
- //// {
- //// //bbb
- //// [((MainViewController*)appDelegate.main_vc) Loginout:false];
- //// }
- ////
- //// [self prepareReturn:nil];
- ////
- //// [self.navigationController popViewControllerAnimated:true];
- ////
- //// [appDelegate printPdf:pdf_url];
- ////
- ////// if(self.printPdfCallback)
- ////// self.printPdfCallback(pdf_url);
- //// }
- //// else
- // {
- // if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
- // {
- // //bbb
- // [((MainViewController*)appDelegate.main_vc) Loginout:false];
- // }
- // [self prepareReturn:nil];
- //
- // [self.navigationController popViewControllerAnimated:true];
- //
- //
- // if(pdf_url.length>0)
- // {
- //
- // [alert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- // [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
- //
- //
- // }
- //
- //
- // }
- // // // self.labelContact.text=appDelegate.contact_name;
- // //
- // // NSDictionary * customerinfo = appDelegate.customerInfo;
- //
- //
- //
- //
- //
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- // }
- // else
- // {
- // 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];
- //
- //
- // alert.tag = KEEP_TAIL;
- //
- //
- // self.upparams = upparams;
- //
- // [alert show];
- // }
- //
- // }
- // else
- // { //USER_ROLE_CUSTOMER
- //
- // // if(self.have_tail)
- // // [upparams setValue:@"true" forKey:@"isHold"];
- // // else
- // // [upparams setValue:@"false" forKey:@"isHold"];
- // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
- //
- // [upparams setValue:@"true" forKey:@"isHold"];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- // if([[editor_json valueForKey:@"result"] intValue]==2)
- // {
- // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
- //
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // // appDelegate.customerInfo = customerInfo;
- //
- //// NSString* orderCode = [editor_json valueForKey:@"orderCode"];
- //// appDelegate.order_code = orderCode;
- //// appDelegate.order_status = [[editor_json valueForKey:@"orderStatus"] intValue];
- // [appDelegate closeOrder];
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- //
- // NSString* title=nil;
- // NSString* msg=nil;
- //#ifdef OFFLINE_MODE
- // if(appDelegate.offline_mode)
- // {
- // title=TITLE_OFFLINE_SUBMIT;
- // msg=MSG_OFFLINE_SUBMIT;
- // }
- // else
- //#endif
- // {
- // title=@"Order submitted sucessfully";
- // msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
- // }
- //
- //
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- //
- // [alert show];
- // // // self.labelContact.text=appDelegate.contact_name;
- // //
- // // NSDictionary * customerinfo = appDelegate.customerInfo;
- // [self prepareReturn:nil];
- // // [self.navigationController dismissViewControllerAnimated:true completion:^{
- // //
- // //
- // // ;
- // // }];
- // [self.navigationController popViewControllerAnimated:true];
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- //
- // }
- // }
- //
- //
- //
- //
- // }
- //
-
-
-
-
-
-
-
-
-
-
- }
-
- // else if( alertView.tag == KEEP_TAIL)
- // {UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Submit Order"];
- // if(buttonIndex!=alertView.cancelButtonIndex)
- // {//keep tail;
- //
- // [self.upparams setValue:@"true" forKey:@"isHold"];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:self.upparams];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- //
- // if([[editor_json valueForKey:@"result"] intValue]==2)
- // {
- // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Submit successful." message:[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- //
- // [alert show];
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // appDelegate.customerInfo = customerInfo;
- // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
- // NSString* orderCode = [editor_json valueForKey:@"orderCode"];
- // appDelegate.order_code = orderCode;
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- // // // self.labelContact.text=appDelegate.contact_name;
- // //
- // // NSDictionary * customerinfo = appDelegate.customerInfo;
- // [self prepareReturn:nil];
- //// [self.navigationController dismissViewControllerAnimated:true completion:^{
- ////
- ////
- //// ;
- //// }];
- // [self.navigationController popViewControllerAnimated:true];
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Submit Order" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- // }
- // else
- // {// not keep tail;
- // [self.upparams setValue:@"false" forKey:@"isHold"];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* editor_json = [iSalesNetwork saveandcommit_Order:self.upparams];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- //
- //
- // if([[editor_json valueForKey:@"result"] intValue]==2)
- // {
- // // NSMutableDictionary * customerInfo=[self create_cusromer_info_from_table];
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Submit successful." message:[NSString stringWithFormat:@"SO#: %@",[editor_json valueForKey:@"so#"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- //
- // [alert show];
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // // appDelegate.customerInfo = customerInfo;
- // // appDelegate.contact_id = [customerInfo valueForKey:@"customer_cid"];
- // // appDelegate.order_code = nil;
- // [appDelegate closeOrder];
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- // // // self.labelContact.text=appDelegate.contact_name;
- // //
- // // NSDictionary * customerinfo = appDelegate.customerInfo;
- // [self prepareReturn:nil];
- //// [self.navigationController dismissViewControllerAnimated:true completion:^{
- ////
- ////
- //// ;
- //// }];
- // [self.navigationController popViewControllerAnimated:true];
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Submit Order" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- // }
- // }
- else if(alertView.tag == CLOSE_ACTION)
- {
- if(buttonIndex==1)
- {
-
- [self.navigationController popViewControllerAnimated:true];
- // back to cart;
- // [self.navigationController dismissViewControllerAnimated:true completion:^{
- // ;
- // }];
- // if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
- // appDelegate.order_code = nil;
- //
- // }
- }
- if(buttonIndex==2)
- {
-
- [self.navigationController popViewControllerAnimated:false];
-
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- [((MainViewController*)appDelegate.main_vc) switchToOrder];
- // back to cart;
- // [self.navigationController dismissViewControllerAnimated:true completion:^{
- // ;
- // }];
- // if ([[upparams valueForKey:@"close_on_save"] boolValue]) {
- // appDelegate.order_code = nil;
- //
- // }
- }
- else if(buttonIndex==3)
- {
- // close order;
-
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Release Order"];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* order_json = [RANetwork release_Order:appDelegate.order_code withScreen:nil];
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- if([[order_json valueForKey:@"result"] intValue]==2)
- {
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // appDelegate.order_code = nil;
-
- [appDelegate closeOrder];
- [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- [((MainViewController*)appDelegate.main_vc) switchToHome];
-
- if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
- {
- [((MainViewController*)appDelegate.main_vc) Loginout:false];
- }
-
- [self prepareReturn:nil];
-
-
- [self.navigationController popViewControllerAnimated:true];
- // [self.navigationController dismissViewControllerAnimated:true completion:^{
- // ;
- // }];
-
- }
- else
- {
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order"controller:self] ;
- }
-
-
-
- });
- });
-
-
-
-
-
- //
- // }
- }
- }
- }
- //
- //
- //-(void) downloadpdf:(NSString* )url
- //{
- // UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Printing..."];
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- //
- // NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60*5];
- //
- // //设置请求方式为get
- //
- // [request setHTTPMethod:@"GET"];
- //
- // //添加用户会话id
- //
- // [request addValue:@"text/html" forHTTPHeaderField:@"Content-Type"];
- //
- // //连接发送请求
- //
- //
- // NSHTTPURLResponse* urlResponse = nil;
- //
- // NSError *error = [[NSError alloc] init];
- //
- // NSData* content= [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
- //
- // // self.filename = [urlResponse suggestedFilename];
- //
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- // // self.navigationItem.title = self.save_name;
- // // UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
- // // self.content=nil;
- // if(content!=nil&&content.length>0)
- // {
- //
- //
- // [self startAirPrintWithData:content];
- //
- //
- // }
- // else
- // {
- // [RAUtils message_alert:nil title:@"Open PDF Failed" controller:self];
- // // self.content = [self.url dataUsingEncoding:NSUTF8StringEncoding];
- // }
- //
- // ;
- // // DebugLog(@"%@",[[NSString alloc] initWithData:self.content encoding:NSASCIIStringEncoding]);
- // //
- //
- //
- // // [self.webView loadData:self.content MIMEType:urlResponse.MIMEType textEncodingName:nil baseURL:nil];
- //
- //
- //
- //
- // });
- // });
- //}
- //
- //- (void)startAirPrintWithData:(id )data
- //{
- //
- //
- //
- //
- // UIPrintInteractionController* airPrinterController=[UIPrintInteractionController sharedPrintController];
- // UIPrintInfo *printInfo = [UIPrintInfo printInfo];
- // printInfo.outputType = UIPrintInfoOutputGeneral;
- // printInfo.orientation = UIPrintInfoOrientationPortrait;
- // printInfo.jobName = @"CoolVisitAirPrint";
- // airPrinterController.printInfo = printInfo;
- // airPrinterController.printingItem = data;
- // airPrinterController.delegate = self;
- //
- //
- // airPrinterController.showsNumberOfCopies=true;
- // airPrinterController.showsPageRange = true;
- // airPrinterController.showsPaperSelectionForLoadedPapers=true;
- //
- // void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
- // if(completed && error)
- // 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);
- // };
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- //
- // UIPrinter *airPrinter = [UIPrinter printerWithURL:[NSURL URLWithString:appDelegate.printerURL] ];///*self.printer;*/
- //
- //
- //
- //
- // [[UIPrinter printerWithURL:[NSURL URLWithString:appDelegate.printerURL]] contactPrinter:^(BOOL available)
- // {
- // if (available&& appDelegate.printerURL.length>0)
- // {
- //
- // [airPrinterController printToPrinter:airPrinter completionHandler:completionHandler];
- // DebugLog(@"AIRPRINTER AVAILABLE");
- // }
- // else
- // {
- //
- // // [airPrinterController presentFromRect:CGRectMake(0, 0, 300, 500) inView:self.view animated:YES completionHandler:
- // //
- // //
- // //
- // // // [printPicker presentAnimated:YES completionHandler:
- // // ^(UIPrintInteractionController *printerController, BOOL userDidSelect, NSError *error)
- // // {
- // // if (userDidSelect)
- // // {
- // // NSString* sid= printerController.printInfo.printerID;
- // // UIPrintPaper*paper= printerController.printPaper;
- // //
- // // }
- // // }];
- //
- //
- // DebugLog(@"AIRPRINTER NOT AVAILABLE");
- //
- //
- //
- // if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1)
- // {
- // UIPrinterPickerController *printPicker = [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:nil];
- // // [printPicker presentFromBarButtonItem:self.btnSubmitOrder animated:yes completionHandler:
- //
- //
- //
- // [ printPicker presentFromBarButtonItem:self.btnSubmitOrder animated:YES completionHandler:
- //
- //
- // // [printPicker presentFromRect:CGRectMake(0, 0, 300, 500) inView:self.view animated:YES completionHandler:
- //
- //
- //
- // // [printPicker presentAnimated:YES completionHandler:
- // ^(UIPrinterPickerController *printerPicker, BOOL userDidSelect, NSError *error)
- // {
- // if (userDidSelect)
- // {
- // //User selected the item in the UIPrinterPickerController and got the printer details.
- //
- // [UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:printerPicker.selectedPrinter];
- //
- // //Here you will get the printer and printer details.ie,
- // // printerPicker.selectedPrinter, printerPicker.selectedPrinter.displayName, printerPicker.selectedPrinter.URL etc. So you can display the printer name in your label text or button title.
- //
- //
- //
- //
- // appDelegate.printerURL =printerPicker.selectedPrinter.URL.absoluteString;
- //
- // [self startAirPrintWithData:data];
- //
- // }
- // else
- // {
- //
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
- // {
- //
- // [((MainViewController*)appDelegate.main_vc) Loginout:false];
- // }
- // [self prepareReturn:nil];
- //
- // [self.navigationController popViewControllerAnimated:true];
- // }
- // }];
- // }
- // }
- // }];
- //
- //
- //
- //}
- //
- //#pragma mark - UIPrintInteractionControllerDelegate
- //- (UIPrintPaper *)printInteractionController:(UIPrintInteractionController *)printInteractionController choosePaper:(NSArray<UIPrintPaper *> *)paperList
- //{
- //
- // ;
- //
- // // (int) width = 29700
- // // Printing description of (*( (int *)0x7caa3a40)):
- // // (int) height = 42000
- // //设置纸张大小
- //
- //
- // for(UIPrintPaper* paper in paperList)
- // {
- // if (CGSizeEqualToSize(paper.paperSize, CGSizeMake(612, 792)))
- // return paper;
- //
- // }
- // CGSize paperSize = CGSizeMake(612, 792);
- // UIPrintPaper * p=[UIPrintPaper bestPaperForPageSize:paperSize withPapersFromArray:paperList];
- // return p;
- //}
- //- (void)printInteractionControllerWillPresentPrinterOptions:(UIPrintInteractionController *)printInteractionController
- //{
- //
- //}
- //- (void)printInteractionControllerDidPresentPrinterOptions:(UIPrintInteractionController *)printInteractionController
- //{
- //
- //}
- //- (void)printInteractionControllerWillDismissPrinterOptions:(UIPrintInteractionController *)printInteractionController
- //{
- //
- //}
- //- (void)printInteractionControllerDidDismissPrinterOptions:(UIPrintInteractionController *)printInteractionController
- //{
- //
- //}
- //
- //- (void)printInteractionControllerWillStartJob:(UIPrintInteractionController *)printInteractionController
- //{
- //
- //}
- //- (void)printInteractionControllerDidFinishJob:(UIPrintInteractionController *)printInteractionController
- //{
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // if([appDelegate.mode isEqualToString:@"Trade Show Mode"]&& appDelegate.submit_order_logout)
- // {
- //
- // [((MainViewController*)appDelegate.main_vc) Loginout:false];
- // }
- //
- // [self prepareReturn:nil];
- //
- // [self.navigationController popViewControllerAnimated:true];
- //}
- //
- //- (NSString *)currentPriceTypeName {
- // NSInteger priceType = [Singleton sharedInstance].npd_shop_price_type;
- //
- // NSString* pricename = nil;
- // switch (priceType) {
- // case 0:
- // pricename=[Singleton sharedInstance].deliveryString;
- // break;
- // case 1:
- // pricename=flat_price;
- // break;
- // case 2:
- // pricename=given_price;
- // break;
- // default:
- // break;
- // }
- // return pricename;
- //}
- - (void)releaseOrderAfterSave {
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- [RANetwork release_Order:appDelegate.order_code withScreen:nil];
- [appDelegate closeOrder];
- [appDelegate SetSo:nil];
- appDelegate.cart_count=0;
- [appDelegate update_count_mark];
- [((MainViewController*)appDelegate.main_vc) switchToOrder];
- [self prepareReturn:nil];
- [self.navigationController popToRootViewControllerAnimated:false];
-
- }
- -(NSString* )create_customer_ext:(NSDictionary*)customerinfo
- {
- NSString* ret=nil;
- NSString* customer_address1= [customerinfo valueForKey:@"customer_address1"];
- NSString* customer_address2= [customerinfo valueForKey:@"customer_address2"];
- NSString* customer_address3= [customerinfo valueForKey:@"customer_address3"];
- NSString* customer_address4= [customerinfo valueForKey:@"customer_address4"];
-
- NSMutableArray* arraddr = [[NSMutableArray alloc] init];
- if(customer_address1.length>0)
- [arraddr addObject:customer_address1];
- if(customer_address2.length>0)
- [arraddr addObject:customer_address2];
- if(customer_address3.length>0)
- [arraddr addObject:customer_address3];
- if(customer_address4.length>0)
- [arraddr addObject:customer_address4];
- NSString *addr_string = [arraddr componentsJoinedByString:@"\r\n"];
-
-
- NSString* customer_city= [customerinfo valueForKey:@"customer_city"];
- NSString* customer_country= [customerinfo valueForKey:@"customer_country"];
- NSString* customer_zipcode= [customerinfo valueForKey:@"customer_zipcode"];
- NSString* customer_state= [customerinfo valueForKey:@"customer_state"];
-
- NSMutableArray* arrcty = [[NSMutableArray alloc] init];
- if(customer_city.length>0)
- [arrcty addObject:customer_city];
- if(customer_state.length>0)
- [arrcty addObject:customer_state];
- if(customer_zipcode.length>0)
- [arrcty addObject:customer_zipcode];
- if(customer_country.length>0)
- [arrcty addObject:customer_country];
- NSString *cty_string = [arrcty componentsJoinedByString:@", "];
-
-
- // NSString* customer_phone= [customerinfo valueForKey:@"customer_phone"];
- // NSString* customer_fax= [customerinfo valueForKey:@"customer_fax"];
- //
- // NSMutableArray* arrpho = [[NSMutableArray alloc] init];
- // if(customer_phone.length>0)
- // {
- // customer_phone = [NSString stringWithFormat:@"TEL: %@",customer_phone];
- // [arrpho addObject:customer_phone];
- // }
- // if(customer_fax.length>0)
- // {
- // customer_fax = [NSString stringWithFormat:@"FAX: %@",customer_fax];
- // [arrpho addObject:customer_fax];
- // }
- // NSString *phone_string = [arrpho componentsJoinedByString:@", "];
- //
- //
- // NSString* customer_contact= [customerinfo valueForKey:@"customer_contact"];
- // if(customer_contact.length>0)
- // {
- // customer_contact = [NSString stringWithFormat:@"ATTN: %@",customer_contact];
- //
- // }
- // NSString *contact_string = customer_contact;
- //
- //
- // NSString* customer_email= [customerinfo valueForKey:@"customer_email"];
- // if(customer_email.length>0)
- // {
- // customer_email = [NSString stringWithFormat:@"Email: %@",customer_email];
- //
- // }
- // NSString *email_string = customer_email;
-
-
- NSMutableArray* arrext = [[NSMutableArray alloc] init];
- if(addr_string.length>0)
- [arrext addObject:addr_string];
- if(cty_string.length>0)
- [arrext addObject:cty_string];
- // if(phone_string.length>0)
- // [arrext addObject:phone_string];
- // if(contact_string.length>0)
- // [arrext addObject:contact_string];
- // if(email_string.length>0)
- // [arrext addObject:email_string];
-
- ret = [arrext componentsJoinedByString:@"\r\n"];
-
- // NSString *string = [array componentsJoinedByString:@" "];
-
- // NSString* customer_name= [customerinfo valueForKey:@"customer_name"];
-
-
- return ret;
- }
- -(NSMutableDictionary*)create_value_map:(NSDictionary*)key_map
- {
- NSMutableDictionary* ret= [[NSMutableDictionary alloc] init];
- NSArray *keys= [key_map allKeys];
- //遍历keys
- for(int i=0;i<[keys count];i++)
- {
- //得到当前key
- NSString *key=[keys objectAtIndex:i];
- //如果key不是pic,说明value是字符类型,比如name:Boris
- NSString* valuefrom = [key_map valueForKey:key];
-
- if(valuefrom.length==0)
- continue;
- NSString* value=[self getValue:valuefrom];
-
- [ret setValue:value forKey:valuefrom];
- }
- NSDictionary * customerinfo =[self create_cusromer_info_from_table];
- [ret setValue:[self create_customer_ext:customerinfo] forKey:@"customer_contact_ext"];
- [ret setValue:customerinfo[@"customer_first_name"] forKey:@"customer_first_name"];
- [ret setValue:customerinfo[@"customer_last_name"] forKey:@"customer_last_name"];
- return ret;
- }
- -(NSMutableDictionary*)create_cusromer_info_from_table
- {
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- NSMutableDictionary* ret= [appDelegate.customerInfo mutableCopy] ;
-
- [ret setValue:[self getValue:@"customer_country"] forKey:@"customer_country"];
- [ret setValue:[self getValue:@"customer_phone"] forKey:@"customer_phone"];
- [ret setValue:[self getValue:@"customer_email"] forKey:@"customer_email"];
- [ret setValue:[self getValue:@"customer_name"] forKey:@"customer_name"];
- [ret setValue:[self getValue:@"customer_address4"] forKey:@"customer_address4"];
- [ret setValue:[self getValue:@"customer_address3"] forKey:@"customer_address3"];
- [ret setValue:[self getValue:@"customer_address2"] forKey:@"customer_address2"];
- [ret setValue:[self getValue:@"customer_address1"] forKey:@"customer_address1"];
- [ret setValue:[self getValue:@"customer_zipcode"] forKey:@"customer_zipcode"];
- [ret setValue:[self getValue:@"customer_city"] forKey:@"customer_city"];
- [ret setValue:[self getValue:@"customer_state"] forKey:@"customer_state"];
- [ret setValue:[self getValue:@"customer_cid"] forKey:@"customer_cid"];
- [ret setValue:[self getValue:@"customer_state"] forKey:@"customer_state"];
- [ret setValue:[self getValue:@"customer_contact"] forKey:@"customer_contact"];
- [ret setValue:[self getValue:@"customer_fax"] forKey:@"customer_fax"];
-
- NSString * firstname =nil;
-
- NSString* lastname = nil;
- NSString* contact_name = [self getValue:@"customer_contact"];
- if(contact_name!=nil)
- {
- NSArray *_arr = [contact_name componentsSeparatedByString:NSLocalizedString(@" ", nil)];
-
-
-
- if(_arr.count>=1)
- {
- firstname =_arr[0];
- if(_arr.count>1)
- {
-
- lastname=[[_arr subarrayWithRange:NSMakeRange(1, _arr.count-1)] componentsJoinedByString:@" "];
- }
- }
- }
- [ret setValue:firstname forKey:@"customer_first_name"];
- [ret setValue:lastname forKey:@"customer_last_name"];
-
- // [ret setValue:[self create_customer_ext:ret] forKey:@"customer_contact_ext"];
-
- return ret;
- }
- #pragma mark - multi_action sub action clicked
- - (void)MActionClicked:(UIButton *)sender {
-
- UITableViewCell *cell = (UITableViewCell *) sender.superview.superview;
- NSIndexPath * indexPath = [self.editorTable indexPathForCell:cell];
- int refresh =0;
- NSMutableDictionary* section_json=nil;
-
- NSMutableDictionary* item_json =[((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row] mutableCopy];
- NSString* subid=[item_json valueForKey:@"subid"];
- NSString* refresh_trigger = [item_json valueForKey:@"name"];
- NSDictionary* sub_action = [item_json objectForKey:[NSString stringWithFormat:@"item_%ld",(long)sender.tag]];
- NSString* type = [sub_action valueForKey:@"type"];
- if([type isEqualToString:@"pull"])
- {
-
- [self.lastedit endEditing:true];
-
- refresh = [[sub_action valueForKey:@"refresh"] intValue];
- NSDictionary* keymap= [sub_action objectForKey:@"key_map"];
-
- NSMutableDictionary* value=[self create_value_map:keymap];
-
- if(subid==nil)
- {
- NSDictionary* jsonmap=[sub_action valueForKey:@"key_map"];
- section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
- int icount=[[section_json valueForKey:@"count"] intValue];
- for (int ic=0;ic<icount;ic++)
- {
- NSMutableDictionary* modify_item= [[section_json objectForKey:[NSString stringWithFormat:@"item_%d",ic ]] mutableCopy];
-
-
- NSString* mapto = [modify_item valueForKey:@"name"];
- if(mapto.length==0)
- continue;
- NSString* valuefrom= [jsonmap valueForKey:[modify_item valueForKey:@"name"]];
- if(valuefrom==nil)
- continue;
- NSString* valuestr=[value valueForKey:valuefrom];
-
-
-
-
-
- // valuestr = [self getValue:valuefrom];
- if(true)
- {
- if(valuestr.length>0)
- [modify_item setValue:valuestr forKey:@"value"];
- else
- [modify_item setValue:@"" forKey:@"value"];
- [modify_item setValue:@"true" forKey:@"dirty"];
- [section_json setObject:modify_item forKey:[NSString stringWithFormat:@"item_%d",ic ]];
- }
- }
- }
- else
- {
-
- NSArray* idarr=[subid componentsSeparatedByString:@"_"];
- int section = [(NSString*)idarr[0] intValue];
- int item=[(NSString*)idarr[1] intValue];
- NSDictionary* jsonmap=[sub_action valueForKey:@"key_map"];
-
- section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d", section]] mutableCopy];
- NSMutableDictionary * olditem=[[section_json objectForKey:[NSString stringWithFormat:@"item_%d",item ]] mutableCopy];
-
- NSString* control_type = [olditem valueForKey:@"control"];
- if([control_type isEqualToString:@"switch"])
- olditem= [self fill_switch_subitem:olditem subid:nil source:value mapping:jsonmap ];
- else if([control_type isEqualToString:@"enum"])
- {
- olditem= [self fill_enum_subitem:olditem subid:nil source:value mapping:jsonmap ];
-
- }
- else
- {
- [RAUtils alert_view:@"" title:@"not impl"];
- }
-
- [olditem setValue:@"true" forKey:@"dirty"];
- [section_json setObject:olditem forKey:[NSString stringWithFormat:@"item_%d",item ]];
-
- }
- [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
- self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
-
-
- if(refresh==1)
- {
-
- // if(restore_json!=nil)
- // {
- // int rc=[[restore_json valueForKey:@"count"] intValue];
- // for(int ir=0;ir<rc;ir++)
- // {
- // NSString* name = [restore_json valueForKey:[NSString stringWithFormat:@"item_%d",ir]];
- //
- //
- // int section_count=[[self.content_data_download valueForKey:@"section_count"] intValue];
- // for(int i=0;i<section_count;i++)
- // {
- // NSMutableDictionary * sectionjson = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
- // // NSMutableDictionary * to_sectionjson = [[to objectForKey:[NSString stringWithFormat:@"section_%d",i ]] mutableCopy];
- // int item_count = [[sectionjson valueForKey:@"count"] intValue];
- // for(int j=0;j<item_count;j++)
- // {
- // NSMutableDictionary * itemjson=[[sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
- // // NSMutableDictionary * to_itemjson=[[to_sectionjson objectForKey:[NSString stringWithFormat:@"item_%d",j ]] mutableCopy];
- //
- // if([[itemjson valueForKey:@"name"] isEqualToString:name])
- // {
- // [itemjson removeObjectForKey:@"dirty"];
- // [sectionjson setObject:itemjson forKey:[NSString stringWithFormat:@"item_%d",j ]];
- // }
- //
- // }
- // [self.content_data_download setObject:sectionjson forKey:[NSString stringWithFormat:@"section_%d",i ]];
- // }
- //
- //
- // }
- //
- // }
- [self refresh:refresh_trigger] ;
- return ;
- }
-
- // DebugLog(@"CONTENT translate:%@",[iSalesNetwork DataTOjsonString:self.content_data]);
- [self.editorTable reloadData ];
-
-
- }
- else
- {
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- NSDictionary * item_json = sub_action;
- NSString* value = [item_json valueForKey:@"value"];
- if([value isEqualToString:@"new_addr"])
- {
- AddressEditorViewController * addressVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"AddressEditorViewController"];
-
- addressVC.url_type = URL_REMOTE;
-
- addressVC.request_url=URL_ADDRESS_EDOTOR;
-
-
-
-
- NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
- // NSString * string = [checked componentsJoinedByString:@","];
- // [params setValue:string forKey:@"cart2Checkbox"];
-
-
- params[@"is_subaction"]=@"true";
- params[@"subaction_tag"]= [NSString stringWithFormat:@"%ld",(long)sender.tag];
- addressVC.params = params;
-
-
- addressVC.delegate = self;
-
- addressVC.from = indexPath;
- // orderinfoVC.params = params;
-
- [self.navigationController pushViewController:addressVC animated:true];
-
- }else if([value isEqualToString:@"credit_card"])
- {
- CreditCardEditorViewController * cardVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"CreditCardEditorViewController"];
-
-
- NSDictionary *data = [item_json objectForKey:@"data"];
-
- if(data!=nil)
- {
-
- cardVC.content_data_download = [data mutableCopy];
- cardVC.url_type = URL_NONE;
-
- cardVC.request_url=nil;
- }
- else
- {
- cardVC.url_type = URL_REMOTE;
-
- cardVC.request_url=URL_CREDITCARD_EDOTOR;
- }
- NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
-
- params[@"orderCode"]=appDelegate.order_code;
-
- params[@"is_subaction"]=@"true";
- params[@"subaction_tag"]= [NSString stringWithFormat:@"%ld",(long)sender.tag];
- cardVC.params = params;
-
- cardVC.delegate = self;
-
- cardVC.from = indexPath;
-
-
- // orderinfoVC.params = params;
-
- [self.navigationController pushViewController:cardVC animated:true];
-
- }
- else if([value isEqualToString:@"Sales_Order_Freight_Bill_To"])
- {
-
-
- ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- cvc.showNavibar = true;
- cvc.contact_type = value;
- cvc.is_subaction = @"true";
- cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
-
-
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
-
-
- [self.navigationController pushViewController:cvc animated:true];
-
- }
- else if([value isEqualToString:@"Sales_Order_Ship_From"])
- {
-
-
- ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- cvc.showNavibar = true;
- cvc.contact_type = value;
- cvc.is_subaction = @"true";
- cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
-
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
-
-
- [self.navigationController pushViewController:cvc animated:true];
-
- }
- else if([value isEqualToString:@"Sales_Order_Customer"])
- {
-
-
- ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- cvc.is_subaction = @"true";
- cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
- cvc.showNavibar = true;
- cvc.contact_type = value;
- __weak typeof(self) weakself = self;
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
-
-
- [self.navigationController pushViewController:cvc animated:true];
-
- }
- else if([value isEqualToString:@"Sales_Order_Merchandise_Bill_To"])
- {
-
-
- ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- cvc.showNavibar = true;
- cvc.contact_type = value;
- cvc.is_subaction = @"true";
- cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
- __weak typeof(self) weakself = self;
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
-
-
- [self.navigationController pushViewController:cvc animated:true];
-
- }
- else if([value isEqualToString:@"Contact_Return_To"])
- {
-
-
- ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- cvc.is_subaction = @"true";
- cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
- cvc.showNavibar = true;
- cvc.contact_type = value;
- __weak typeof(self) weakself = self;
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
-
-
- [self.navigationController pushViewController:cvc animated:true];
-
- }
- else if([value isEqualToString:@"Sales_Order_Ship_To"])
- {
-
-
- ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- cvc.is_subaction = @"true";
- cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
- cvc.showNavibar = true;
- cvc.contact_type = value;
- __weak typeof(self) weakself = self;
- cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
-
- [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
-
- //
- // if(self.returnValue)
- // self.returnValue(value);
- };
-
-
-
- [self.navigationController pushViewController:cvc animated:true];
-
- }
-
-
- }
- }
- #pragma mark - Urgency
- -(void) viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- [self cancel_urgency_timer];
- }
- - (void)start_urgency_timer {
-
- if (!self.editable) {
- return;
- }
-
- __weak typeof(self) weakSelf = self;
-
- AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
-
- [appDelegate.urgencyDic setValue:appDelegate.user forKey:@"user"];
- #ifdef OFFLINE_MODE
- [appDelegate.urgencyDic setValue:[NSNumber numberWithBool:appDelegate.offline_mode] forKey:@"offline_mode"];
- #endif
- [[JKTimerManager sharedTimerManager] scheduledDispatchTimerWithName:self.urgency_timer_name timeInterval:1 queue:nil repeats:YES action:^{
-
- NSMutableDictionary *urgencyDic = [NSMutableDictionary dictionary];
-
- // DebugLog(@"timer start....");
-
- [urgencyDic setValue:weakSelf.content_data_download forKey:[NSString stringWithFormat:@"%@_restored_data",self.class_name]];
-
- [urgencyDic setValue:weakSelf.class_name forKey:@"class_name"];
-
-
-
- if ([weakSelf.class_name isEqualToString:@"CreateOrderViewController"]) {
- // CreateOrderViewController
-
-
- [urgencyDic setValue:appDelegate.order_code forKey:@"order_code"];
- MainViewController *mainVC = (MainViewController *)appDelegate.main_vc;
- NSString *so = [mainVC.labelSo.text substringFromIndex:5];
- [urgencyDic setValue:so forKey:@"order_so"];
- [urgencyDic setValue:[NSNumber numberWithInt:appDelegate.order_status ] forKey:@"order_status"];
-
- [urgencyDic setValue:appDelegate.order_customer_id forKey:@"order_customer_id"];
-
- }
-
- [appDelegate.urgencyDic setValue:urgencyDic forKey:[NSString stringWithFormat:@"level_%d",weakSelf.level]];
- [appDelegate.urgencyDic setValue:[NSNumber numberWithInteger:weakSelf.level + 1] forKey:@"count"];
-
- }];
- }
- - (void)cancel_urgency_timer {
- [[JKTimerManager sharedTimerManager] cancelTimerWithName:self.urgency_timer_name];
- }
- #pragma mark - Submit Order
- - (void)customer_commit_order:(NSMutableDictionary *)upparams {
-
-
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
-
- [upparams setValue:@"true" forKey:@"isHold"];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-
- if([[editor_json valueForKey:@"result"] intValue]==2)
- {
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // appDelegate.customerInfo = customerInfo;
-
- [appDelegate closeOrder];
- [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-
- NSString* title=nil;
- NSString* msg=nil;
- #ifdef OFFLINE_MODE
- if(appDelegate.offline_mode)
- {
- title=TITLE_OFFLINE_SUBMIT;
- msg=MSG_OFFLINE_SUBMIT;
- }
- else
- #endif
- {
- title=@"Order submitted sucessfully";
- msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
- }
-
- UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-
- [alert show];
-
- [self prepareReturn:nil];
- [self.navigationController popToRootViewControllerAnimated:true];
-
-
- }
- else
- {
- [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
- }
- });
- });
- }
- - (void)empolyee_commit_order:(NSMutableDictionary *)upparams {
-
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Order Submission"];
- [upparams setValue:@"false" forKey:@"isHold"];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* editor_json = [RANetwork saveandcommit_Order:upparams];
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
-
-
- if([[editor_json valueForKey:@"result"] intValue]==2)
- {
-
- // debug aaa
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- NSString* company= appDelegate.customerInfo[@"customer_name"];
- NSString* send_to =appDelegate.customerInfo[@"customer_email"];
-
- [appDelegate closeOrder];
- [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-
- NSString* title=nil;
- NSString* msg=nil;
- #ifdef OFFLINE_MODE
- if(appDelegate.offline_mode)
- {
- title=TITLE_OFFLINE_SUBMIT;
- msg=MSG_OFFLINE_SUBMIT;
- }
- else
- #endif
- {
- title=@"Order submitted sucessfully";
- msg=[NSString stringWithFormat:@"Confirmation#: %@",[editor_json valueForKey:@"so#"]];
- }
-
- UIAlertView * alert = [[UIAlertView alloc] initWithTitle: title message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-
- [alert show];
-
- NSString* pdf_url = [editor_json valueForKey:@"pdf_url"];
- NSString* email_content =[editor_json valueForKey:@"email_content"];
- NSString* soid=[editor_json valueForKey:@"so#"];
- {
- NSMutableDictionary *value = [NSMutableDictionary dictionary];
- if([appDelegate.mode isEqualToString:@"TM"]&& appDelegate.submit_order_logout)
- {
- //bbb
- [((MainViewController*)appDelegate.main_vc) Loginout:false];
- value[@"commitorder_logout"]=@"true";
- }
- [self prepareReturn:value];
-
- [self.navigationController popToRootViewControllerAnimated:true];
-
- if(pdf_url.length>0)
- {
-
- [alert dismissWithClickedButtonIndex:0 animated:FALSE];
- [appDelegate printPdf:pdf_url company:company send_to:send_to soid:soid content:email_content];
- // [appDelegate printPdf:pdf_url];
-
- }
- }
-
- }
- else
- {
- [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Order Submission" controller:self] ;
- }
- });
- });
- }
- @end
|