| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055 |
- //
- // OrderDetailViewController.m
- // RedAnt ERP Mobile
- //
- // Created by Ray on 8/28/15.
- // Copyright (c) 2015 United Software Applications, Inc. All rights reserved.
- //
- #import "OrderDetailViewController.h"
- #import "OrderDetailInfoCell.h"
- #import "OrderDetailHtmlCell.h"
- #import "OrderDetailModelCell.h"
- #import "OrderDetailPriceCell.h"
- #import "OrderDetailSignatureCell.h"
- #import "iSalesNetwork.h"
- #import "RTLabel.h"
- #import "DetailViewController.h"
- #import "PDFViewController.h"
- #import "SignatureViewController.h"
- #import "MainViewController.h"
- #import "AFHTTPSessionManager.h"
- #import "DefaultAppearance.h"
- #import "DefaultTableHeaderView.h"
- #import "OLDataProvider.h"
- #define DEF_CELL_HEIGHT 44
- #define DEF_TABLE_HEIGHT 44
- #define LINE_WIDTH 0
- #define CELL_MARGIN 0
- #define LABEL_MARGIN 15
- @interface OrderDetailViewController ()
- @property (nonatomic,assign) BOOL showModels;
- @end
- @implementation OrderDetailViewController
- - (void)saleOrderWithPath:(NSString *)path {
-
- PDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
-
- ViewController.url = path;
- ViewController.canSave = false;
- ViewController.isLocalfile=YES;
- NSString* subject;
-
- NSString* cur_time =[RAUtils current_date];
- subject =@"Sales Order";
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- NSString* customer_email= [appDelegate.customerInfo valueForKey:@"customer_email"];
-
-
- NSMutableArray* send_to = [[NSMutableArray alloc]init];
- if(customer_email.length>0)
- {
- send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
- }
- ViewController.mail_to = send_to;
- ViewController.attachment_name = [NSString stringWithFormat:@"NPD_Product_List %@.pdf",cur_time];
- ViewController.mail_subject = subject;
-
- ViewController.hidenavi = false;
- [self.navigationController pushViewController:ViewController animated:YES];
-
- }
- -(void) reload_container_getdata:(bool) update_data
- {
-
- [super reload_container_getdata:update_data];
- if(update_data)
- [self reload_data];
- else
- {
- [self.detailTable reloadData];
-
- }
- }
- - (void)onBackClick:(UIButton *)sender {
-
-
- [self.navigationController popViewControllerAnimated:FALSE];
- }
- -(void)manually_refresh
- {
- UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
-
- if(self.isrefreshing)
- {
- [reF endRefreshing];
- return;
- }
- reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Refreshing"];
-
-
- if ([self respondsToSelector:@selector(reload_data)])
- [self performSelector:@selector(reload_data) withObject:nil afterDelay:1];
- // DebugLog(@"refresh!!!!!!!!");
-
- }
- -(void) reload_data
- {
-
- UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
-
- [reF endRefreshing];
-
- reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
-
- [self loaddata];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
-
-
- self.label_net_err.layer.borderColor = [UIColor darkGrayColor].CGColor;
- self.label_net_err.layer.borderWidth = 2.0;
- self.label_net_err.layer.cornerRadius=15;
- self.label_net_err.layer.masksToBounds=true;
-
- self.showModels = YES;
-
-
-
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(refresh_btn_click:)];
- // tap.minimumPressDuration = 0.8; //定义按的时间
- [self.label_net_err addGestureRecognizer:tap];
-
-
-
- UIRefreshControl *ref = [[UIRefreshControl alloc]init];
- ref.tag = 200 ;
- ref.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
- ref.tintColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
- // ref.hidden = true;
- [ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged];
- [self.detailTable addSubview:ref];
-
-
- NSMutableArray * items = [[NSMutableArray alloc]init];
-
-
- self.navigationItem.title=@"View Order Detail";
-
-
-
-
- UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector( onBackClick:)];
-
- // closeButton.tintColor = UIColorFromRGB(0x996633);
-
-
-
- self.navigationItem.leftBarButtonItem = closeButton;
-
-
-
- self.btnOpen = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(onOpenOrderClick:)];//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onOpenOrderClick:)];
-
- // self.btnOpen.tintColor = UIColorFromRGB(0x996633);
-
-
-
- self.btnSign = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"signature"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(onSignOrderClick:)];//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onOpenOrderClick:)];
-
- // self.btnSign.tintColor = UIColorFromRGB(0x996633);
-
-
- self.btnCopy =[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"copy"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(onCopyOrderClick:)];// [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Commit", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCommitOrderClick:)];
-
- // self.btnCopy.tintColor = UIColorFromRGB(0x996633);
-
- // self.btnSend = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Email", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onSendMailClick:)];
-
-
-
- self.btnRelease = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"unlock"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(onReleaseOrderClick:)];
- // self.btnRelease.tintColor = UIColorFromRGB(0x996633);
-
- self.btnPDF = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"mail"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(onDownloadOrderClick:)];//[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Download", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onDownloadOrderClick:)];
-
-
- // self.btnPDF.tintColor = UIColorFromRGB(0x996633);
-
- // UIBarButtonItem *item1 = [[UIBarButtonItem alloc] init];
- // item1.title = @"item1";
- //// item1.image = [UIImage imageNamed:@"rect_setting"];
- // UIBarButtonItem *item2 = [[UIBarButtonItem alloc] init];
- //// item2.image = [UIImage imageNamed:@"rect_about"];
- // item2.title = @"item2";
-
- // UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
- // fixedItem.width = 0.0f;
- AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
- [items addObject:self.btnOpen];
- // [items addObject:fixedItem];
- // [items addObject:self.btnCommit];
- // [items addObject:fixedItem];
- if (appDelegate.user_type != USER_ROLE_CUSTOMER) {
- [items addObject:self.btnRelease];
- }
- // [items addObject:fixedItem];
- [items addObject:self.btnPDF];
- // [items addObject:fixedItem];
- [items addObject:self.btnSign];
- // [items addObject:fixedItem];
- if (appDelegate.user_type != USER_ROLE_CUSTOMER) {
- [items addObject:self.btnCopy];
- }
-
- // [items addObject:item2];
- self.navigationItem.rightBarButtonItems=items;
-
- self.btnOpen.enabled =false;
- self.btnSign.enabled = false;
-
- self.btnCopy.enabled =false;
- self.btnPDF.enabled =false;
- self.btnRelease.enabled =false;
- // if(self.isTempOrder)
- // {
- //
- //
- // self.btnOpen.enabled =true;
- //
- //
- // self.btnCommit.enabled =true;
- // }
- // else
- // {
- //
- // [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
- //
- // [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
- // self.btnOpen.enabled =false;
- // self.btnCommit.enabled =false;
- // }
- // Do any additional setup after loading the view.
-
-
- // [self loaddata];
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- }
- - (IBAction)onReleaseOrderClick:(id)sender {
-
-
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Are you sure to release order?" message:nil preferredStyle:UIAlertControllerStyleAlert];
- //block代码块取代了delegate
-
-
-
- UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Release Order"];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* order_json = [iSalesNetwork release_Order:self.order_code];
-
- 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];
-
- // appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
- //
- // appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
- // if(self.selectOrder)
- // self.selectOrder();
- [self.navigationController popToRootViewControllerAnimated:false];
-
- }
- else
- {
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" 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];
-
-
-
-
-
- // get customer info
-
-
-
-
- }
- - (void)onDownloadOrderClick:(id)sender {
- __weak typeof(self) weakself = self;
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- PDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
-
- ViewController.mail_content = [self.content_data valueForKey:@"email_content"];
-
- NSString* so = [self.content_data valueForKey:@"so#"];
- if(so==nil)
- so =@"";
-
- NSString* company = [self.content_data[@"customerInfo"] valueForKey:@"customer_name"];
- if(company==nil)
- company =@"";
-
-
- ViewController.save_name =so;
- ViewController.hidenavi = false;
- if(company==nil)
- company=@"";
- NSString* customer_email= [self.content_data[@"customerInfo"] valueForKey:@"customer_email"];
- // NSMutableArray* arr_subject = [[NSMutableArray alloc]init];
-
- // if(company.length>0)
- // [arr_subject addObject:company];
- // if(so.length>0)
- // [arr_subject addObject:so];
-
- if(company.length==0)
- company=@"";
- if(so.length==0)
- so=@"";
-
- NSMutableArray* send_to = [[NSMutableArray alloc]init];
- if(customer_email.length>0)
- {
- send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
- // customer_email compo
- // [send_to addObject:customer_email];
- }
- ViewController.mail_to = send_to;
-
- NSString* subject=[NSString stringWithFormat:@"%@ -- SO# %@ from NEW PACIFIC DIRECT,INC.",company,so];//[arr_subject componentsJoinedByString:@" : "];
-
- ViewController.mail_subject = subject;
-
-
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"View Sales Order:" message:nil preferredStyle:UIAlertControllerStyleAlert];
- //block代码块取代了delegate
-
-
-
- UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"With Thumbnails" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-
- if(appDelegate.offline_mode)
- {
- NSMutableDictionary* params = [@{
- @"thumb" : @"1",
- @"order_code" : self.order_code,
- } mutableCopy];
- NSData *dicData = [OLDataProvider offline_request_salesorder:params];
- NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:dicData options:NSJSONReadingMutableContainers error:nil];
- if ([dic[@"result"] integerValue] == RESULT_TRUE) {
- NSString *path = dic[@"pdf_path"];
- [weakself saleOrderWithPath:path];
- // ViewController.url = path;
- // ViewController.isLocalfile = YES;
- //
- // [self.navigationController pushViewController:ViewController animated:YES];
- } else {
- [RAUtils message_alert:@"Sales Order Open Failed" title:@"Message" controller:weakself];
- }
- }
- else
- {
- NSString* url=[self.content_data valueForKey:@"pdfUrl"];
-
-
- url= [url stringByAppendingString:@"&has_item_pic=true"];
- DebugLog(@"pdf url:%@",url);
-
- ViewController.url = url;
-
-
- [self.navigationController pushViewController:ViewController animated:YES];
- }
-
- }];
-
- int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
- NSString* alertthreetitle=@"Without Thumbnails";
- if(appDelegate.user_type==USER_ROLE_CUSTOMER&&self.is_shoporder&& (status_code==1 /*||status_code==0*/||status_code==30))
- {
- alertthreetitle=@"Print Receipt";
- }
- UIAlertAction *alertthree = [UIAlertAction actionWithTitle:alertthreetitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-
- if(appDelegate.offline_mode)
- {
- NSMutableDictionary* params = [@{
- @"thumb" : @"0",
- @"order_code" : self.order_code,
- } mutableCopy];
- NSData *dicData = [OLDataProvider offline_request_salesorder:params];
- NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:dicData options:NSJSONReadingMutableContainers error:nil];
- if ([dic[@"result"] integerValue] == RESULT_TRUE) {
- NSString *path = dic[@"pdf_path"];
- [weakself saleOrderWithPath:path];
- // ViewController.url = path;
- // ViewController.isLocalfile = YES;
- //
- // [self.navigationController pushViewController:ViewController animated:YES];
- } else {
-
- [RAUtils message_alert:@"Sales Order Open Failed" title:@"Message" controller:weakself];
-
- }
- }
- else
- {
- NSString* url=[self.content_data valueForKey:@"pdfUrl"];
- DebugLog(@"pdf url:%@",url);
- ViewController.url = url;
- [self.navigationController pushViewController:ViewController animated:YES];
- }
-
- }];
-
-
- UIAlertAction *alertCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {}];
-
-
- if(appDelegate.user_type==USER_ROLE_CUSTOMER&&self.is_shoporder&& (status_code==1 /*||status_code==0*/||status_code==30))//[status isEqualToString:@"Saved Order"])
- {
- [alertControl addAction:alertthree];
- [alertControl addAction:alertCancel];
- }
- else
- {
- [alertControl addAction:actionOne];
-
- [alertControl addAction:alertthree];
- [alertControl addAction:alertCancel];
- }
-
-
- //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
-
-
- [self presentViewController:alertControl animated:YES completion:nil];
-
-
-
- // get customer info
-
- //
-
-
-
-
-
-
- }
- - (void)onCopyOrderClick:(id)sender {
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.order_code) {
-
- __weak typeof(self) weakself = self;
- UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:@"You must release current order,are you sure to release the order then copy a new order?" preferredStyle:UIAlertControllerStyleAlert];
-
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-
- }];
-
- UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Release Order"];
-
- dispatch_async(dispatch_get_global_queue(0, 0), ^{
-
- NSDictionary* order_json = [iSalesNetwork release_Order:appDelegate.order_code];
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- if([[order_json valueForKey:@"result"] intValue]==2)
- {
- [appDelegate closeOrder];
-
- [weakself copyOrder];
-
- } else {
-
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Release Order" controller:weakself] ;
- }
- });
-
- });
-
- }];
-
- [alertVC addAction:cancelAction];
- [alertVC addAction:yesAction];
-
- [self presentViewController:alertVC animated:YES completion:nil];
-
- } else {
-
- UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Copy confirm", nil) message:NSLocalizedString(@"Are you sure to copy order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
- [alert show];
-
- }
-
-
-
-
- }
- //- (void)onCommitOrderClick:(id)sender {
- // // get customer info
- //
- // int model_count = [[self.content_data valueForKey:@"model_count"] intValue];
- // if(model_count==0)
- // {
- //// UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Error." message:@"Can not submit an order without models." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
- ////
- //// [alert show];
- //
- //
- // [RAUtils alert_view:@"Cannot submit an order without models" title:@""];
- // }
- //
- // else
- // {
- //
- // UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Submit confirm", nil) message:NSLocalizedString(@"Are you sure to submit order?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
- // [alert show];
- //
- // }
- //
- //
- //}
- -(void) upload_img :(UIImage*) img
- {
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- if(appDelegate.offline_mode)
- {
-
- NSData *data = [OLDataProvider offline_saveBusinesscard:UIImagePNGRepresentation(img)];;
-
- // 再将NSData转为字符串
- NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
-
- // NSMutableString *str = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
-
- DebugLog(@"data string: %@",jsonStr);
- NSError *error=nil;
- NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error];
-
-
-
- if([[json valueForKey:@"result"] intValue]==2)
- {
- NSString* img_url_down = json[@"img_url_aname"];
- NSString* img_url_up = json[@"img_url"];
-
- {
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Signature"];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* order_json = [iSalesNetwork sign_Order:self.order_code path:img_url_up];
-
- 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 = self.order_code;
- // [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
- //
- //
- // appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
- //
- // appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
- // [self.navigationController popViewControllerAnimated:false];
- //
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- // if(self.selectOrder)
- // self.selectOrder(self.content_data);
-
- [self.content_data setValue:img_url_down forKey:@"sign_url"];
- //self.btnSign.enabled = false;
- [self.detailTable reloadData];
-
- [RAUtils message_alert:@"Successful." title:@"Signature" controller:self];
-
-
- }
- else
- {
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Signature" controller:self] ;
- }
-
-
-
- });
- });
- }
- }
- else
- {
- [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Upload Image" controller:self] ;
- }
- }
- else
- {
-
-
-
-
-
-
- // UIAlertView * waitalert = [[UIAlertView alloc] initWithTitle:@"wait" message:@"uploading" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
- // [waitalert show];
-
- NSData *imageData = UIImagePNGRepresentation(img);
-
- AFHTTPRequestSerializer* serializer=[AFHTTPRequestSerializer serializer] ;
-
-
-
- NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- if(appDelegate.user!=nil)
- [params setValue:appDelegate.user forKey:@"user"];
- // if(appDelegate.contact_id!=nil)
- // [params setValue:appDelegate.contact_id forKey:@"contactId"];
- if(appDelegate.password!=nil)
- [params setValue:appDelegate.password forKey:@"password"];
-
- DebugLog(URL_UPLOAD_IMG);
-
- NSMutableURLRequest *request = [serializer multipartFormRequestWithMethod:@"POST" URLString:URL_UPLOAD_IMG parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
- [formData appendPartWithFileData:imageData name:@"upfile" fileName:@"test.jpg" mimeType:@"image/png"];
- } error:nil];
-
-
- // NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:WEBSERVICE_URL parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
- // [formData appendPartWithFileData:imageData name:@"upfile" fileName:@"test" mimeType:@"image/png"];
- // } error:nil];
- //
- AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
-
-
-
- //manager.responseSerializer.acceptableContentTypes = [self.operationManager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
-
-
-
- //
- NSProgress *progress = nil;
-
- NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
-
- // [progress removeObserver:self forKeyPath:@"fractionCompleted"];
-
-
-
-
- if (error) {
-
- NSString* err_msg = [error localizedDescription];
- DebugLog(@"%@",err_msg);// [self.view updateWithMessage:[NSString stringWithFormat:@"Error : %@!", error.debugDescription]];
-
-
- NSMutableString *str = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
-
- DebugLog(@"data string: %@",str);
-
- [RAUtils message_alert:@"Can not connect to server please try again." title:@"Upload Image" controller:self] ;
-
- } else {
- DebugLog(@"response ");
-
-
-
- NSData *data = [NSJSONSerialization dataWithJSONObject:(NSDictionary*)responseObject options:kNilOptions error:nil];
-
- // 再将NSData转为字符串
- NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
-
- // NSMutableString *str = [[NSMutableString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
-
- DebugLog(@"data string: %@",jsonStr);
-
- NSDictionary* json = responseObject;
-
- if([[json valueForKey:@"result"] intValue]==2)
- {
- NSString* img_url_down = json[@"img_url_aname"];
- NSString* img_url_up = json[@"img_url"];
-
- {
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Signature"];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* order_json = [iSalesNetwork sign_Order:self.order_code path:img_url_up];
-
- 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 = self.order_code;
- // [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
- //
- //
- // appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
- //
- // appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
- // [self.navigationController popViewControllerAnimated:false];
- //
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- // if(self.selectOrder)
- // self.selectOrder(self.content_data);
-
- [self.content_data setValue:img_url_down forKey:@"sign_url"];
- //self.btnSign.enabled = false;
- [self.detailTable reloadData];
-
- [RAUtils message_alert:@"Successful." title:@"Signature" controller:self];
-
-
- }
- else
- {
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Signature" controller:self] ;
- }
-
-
-
- });
- });
- }
-
-
- }
- else
- {
- [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Upload Image" controller:self] ;
- }
-
-
-
-
-
-
- }
- // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- }];
-
- [uploadTask resume];
- }
-
- }
- - (IBAction)onSignOrderClick:(id)sender {
-
- // SignatureViewController * vc;
-
- __block UIImage* signimg=nil;
- SignatureViewController * vc =[ [UIStoryboard storyboardWithName:@"signature" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"SignatureViewController"];
-
- vc.onReturnImg = ^(UIImage* img)
- {
- signimg = img;
-
- if(signimg!=nil)
- [self upload_img:signimg];
-
-
- };
- // orderinfoVC.url_type = URL_REMOTE;
- // orderinfoVC.request_url=URL_CARTDELIVERY;
- //
- // orderinfoVC.params = params;
- //
- // orderinfoVC.delegate=self;
- //
- // if(checked.count==count)
- // {
- // orderinfoVC.have_tail = true
- // }
-
- [self.navigationController pushViewController:vc animated:true];
- }
- - (IBAction)onOpenOrderClick:(id)sender {
- // get customer info
-
-
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Are you sure to open order?" message:nil preferredStyle:UIAlertControllerStyleAlert];
- //block代码块取代了delegate
-
-
-
- UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-
- {
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Open Order"];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* order_json = [iSalesNetwork open_Order:self.order_code];
-
- 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 = self.order_code;
- appDelegate.order_status = self.order_status;
- [appDelegate SetSo:[self.content_data valueForKey:@"so#"]];
-
-
- appDelegate.customerInfo=[[self.content_data objectForKey:@"customerInfo"] mutableCopy];
-
- appDelegate.contact_id=[appDelegate.customerInfo valueForKey:@"customer_cid"];
- [self.navigationController popViewControllerAnimated:false];
-
- [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
- if(self.selectOrder)
- self.selectOrder(self.content_data);
-
-
- }
- else
- {
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" 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];
-
-
-
-
-
-
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- -(void) loaddata
- {
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Loading"];
-
-
-
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
- if(self.isrefreshing)
- return;
-
- self.detailTable.hidden = true;
- self.label_net_err.hidden=true;
- self.isrefreshing=true;
-
- self.mum.center = self.view.center;
- self.mum.hidden = false;
- [self.mum startAnimating];
-
- DebugLog(@"reloading...");
-
- self.web_info_height=0;
- self.web_moreinfo_height=0;
- self.content_data = nil;
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* order_json = [iSalesNetwork request_OrderDetail:self.orderid];
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- [self.mum stopAnimating];
- if([[order_json valueForKey:@"result"] intValue]==2)
- {
- self.detailTable.hidden = false;
- self.content_data = [order_json mutableCopy];
-
-
- }
- else
- if([[order_json valueForKey:@"result"] intValue]==RESULT_NET_ERROR)
- {
- self.label_net_err.hidden=false;
- self.detailTable.hidden=true;
- }
- else
- {
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Loading Order Detail" controller:self] ;
- }
-
- bool web_order =[[self.content_data valueForKey:@"from_online"] boolValue];
- if(web_order)
- self.btnCopy.enabled = false;
- else
- self.btnCopy.enabled = true;
- int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- int model_count =[[self.content_data valueForKey:@"model_count"] intValue];
- if(model_count>0)/*&& ! appDelegate.offline_mode*/
- {
- if(appDelegate.user_type== USER_ROLE_EMPLOYEE)
- self.btnPDF.enabled =true;
- else
- {
- // || appDelegate.user_type==USER_ROLE_CUSTOMER
- if(self.is_shoporder)
- {
- if(status_code==1||status_code==30)
- self.btnPDF.enabled =true;
- }
- else
- {
- if(status_code==2)
- self.btnPDF.enabled =true;
- }
- }
- }
- // [self.btnPDF setImage:[[UIImage imageNamed:@"download"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
-
- // NSString* status = [self.content_data valueForKey:@"order_status"];
- NSString* lock_user = [self.content_data valueForKey:@"opened_customer"];
- bool offline_edit =[[self.content_data valueForKey:@"offline_edit"] boolValue];
- if(status_code==1)//[status isEqualToString:@"Saved Order"])
- {
- // [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
- //
- // [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
-
- if(appDelegate.offline_mode==false||offline_edit)
- {
- self.btnOpen.enabled =true;
-
- self.btnSign.enabled = true;
- }
- // if([lock_user isEqualToString:appDelegate.user])
- // {
- // self.btnCommit.enabled =true;
- // }
- // else
- // self.btnCommit.enabled =false;
- }
- else
- if(status_code==0)//[status isEqualToString:@"Quote Saved"])
- {
- // [self.btnOpen setImage:[[UIImage imageNamed:@"edit"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
- //
- // [self.btnCommit setImage:[[UIImage imageNamed:@"commit"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
-
- if(appDelegate.offline_mode==false||offline_edit)
- {
- self.btnOpen.enabled =true;
-
- self.btnSign.enabled = true;
- }
- // self.btnCommit.enabled =false;
- }
-
- if(((!appDelegate.offline_mode && [lock_user isEqualToString:appDelegate.user]) || (appDelegate.offline_mode && [self.order_code isEqualToString:appDelegate.order_code]))&& (status_code==1||status_code==0))
- {
- // [self.btnRelease setImage:[[UIImage imageNamed:@"order"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
-
-
- self.btnRelease.enabled =true;
- }
- else
- {
-
-
- // [self.btnRelease setImage:[[UIImage imageNamed:@"order"] imageWithRenderingMode:UIImageRenderingModeAutomatic]];
- self.btnRelease.enabled =false;
- }
-
- [self.detailTable reloadData];
- self.isrefreshing=false;
-
- });
-
- });
- });
- }
- - (void)viewWillAppear:(BOOL)animated
- {
-
- [super viewWillAppear:animated];
- // if(appDelegate.can_submit_order)
- // {
- //
- //
- // [self.btnCommit setImage:[UIImage imageNamed:@"commit"]];
- // self.btnCommit.enabled = true;
- // }
- // else
- // {
- // [self.btnCommit setImage:nil];
- // self.btnCommit.enabled = false;
- // }
- //
- [[self navigationController] setNavigationBarHidden:NO animated:NO];
-
- }
- - (IBAction)imgbtnClicked:(UIButton*)sender {
- UITableViewCell* cell =(UITableViewCell*) sender.superview.superview;
-
- NSIndexPath * indexPath = [self.detailTable indexPathForCell:cell];
-
- if(indexPath.section!=1)
- return ;
- // DebugLog(@"shouldchangeedit %d_%d",indexPath.section,indexPath.row);
- NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
-
- NSString* product_id = [item_json valueForKey:@"product_id"];
-
- DetailViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController" ];
- // dvc
-
- dvc.product_id=product_id;
- dvc.category_id=nil;
- dvc.ispush=true;
- [dvc reload];
- [self.navigationController pushViewController:dvc animated:true];
- }
- /*
- #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 - Table view data source
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
- {
- // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
- // if([item_json objectForKey:@"combine"] == nil)
- // {
- // return 120;
- // }
- // else
- // return 150;
-
- switch (indexPath.section) {
- case 0:
- {
- if(indexPath.row==0)
- {
- float height= self.web_info_height;
- if(height==0)
- height=DEF_TABLE_HEIGHT;
-
-
- return height;
- }
- else
- return 148;
-
- }
- break;
-
- case 1:
- {
- float height= self.web_moreinfo_height;
- if(height==0)
- height=DEF_TABLE_HEIGHT;
-
-
- // DebugLog(@"heightForRowAtIndexPath...............webview,hight = %f section=%ld",height,indexPath.section);
- //wait(1000);
- return height;
- }
- break;
- case 2:
-
- {
- NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
-
- NSString* notes =[item_json valueForKey:@"note"];
- if(notes.length>0)
- {
- return 190;
- }
- else
- return 162;
- }
- case 3:
- return 44;
- default:
- break;
- }
- return 44;
-
- }
- //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- //{
- // return 0;
- //}
- //- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- //{
- // return 0;
- //}
- //- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
- //{
- // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
- // return myView;
- //
- //}
- //- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- //{
- // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
- //// myView.backgroundColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
- //// UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 90, 22)];
- //// titleLabel.textColor=[UIColor whiteColor];
- //// titleLabel.backgroundColor = [UIColor clearColor];
- //// if(section==0)
- //// titleLabel.text=NSLocalizedString(@"display_items", nil);
- //// else
- //// titleLabel.text=NSLocalizedString(@"hide_items", nil);
- //// [titleLabel sizeToFit];
- //// [myView addSubview:titleLabel];
- ////
- // return myView;
- //}
- //
- - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- {
-
-
- NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
-
- if(value==nil)
- value=@"";
- unsigned long color = strtoul([value UTF8String],0,16);
-
-
- DefaultTableHeaderView* myView = [[DefaultTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
- // myView.backgroundColor = UIColorFromRGB(0x996633);;
-
-
- myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath;
- // myView.layer.masksToBounds = false;
- //添加四个边阴影
-
- myView.layer.shadowColor = [UIColor blackColor].CGColor;
- myView.layer.shadowOffset = CGSizeMake(0, 0);
- myView.layer.shadowOpacity = 0.5;
- myView.layer.shadowRadius = 2.0;
- myView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
-
- NSString*labeltitle = nil;
- switch (section) {
- case 0:
- labeltitle= @"Order Info";
- break;
- case 1:
- {
- labeltitle= @"More Info";
-
- NSString* btntitle=nil ;
- if(self.showMore)
- {
- btntitle=@"Hide";
- // [section setValue:@"false" forKey:@"hide"];
- // [sender setTitle:@"Show" forState:UIControlStateNormal];
- }
- else{
- btntitle=@"Show";
- }
-
-
- UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
- btn.tag=section;
- [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
- [btn setTitle:btntitle forState:UIControlStateNormal];
- btn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
- [myView addSubview:btn];
-
- }
- break;
- case 2:{
- labeltitle= @"Models";
-
- NSString* btntitle=nil ;
- if(self.showModels)
- {
- btntitle=@"Hide";
- }
- else{
- btntitle=@"Show";
- }
-
-
- UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
- btn.tag=section;
-
- [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
-
- [btn setTitle:btntitle forState:UIControlStateNormal];
- btn.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
- [myView addSubview:btn];
-
- }
- break;
- case 3:
- labeltitle= @"Price Info";
- default:
- break;
- }
-
-
-
- UILabel *titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 5.5, 200, 20)];
- titlelabel.textColor=UIColorFromRGB(color);;
- titlelabel.backgroundColor = [UIColor clearColor];
- titlelabel.text=NSLocalizedString(labeltitle, nil);
- [titlelabel sizeToFit];
- titlelabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
- [myView addSubview:titlelabel];
-
- //
- return myView;
- }
- #pragma mark - hide section button clicked
- - (void)HideSction:(UIButton *)sender {
- /*
- NSMutableDictionary* section= [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%d",sender.tag]] mutableCopy];
- bool hide = [[section valueForKey:@"hide"]boolValue];
- if(hide)
- {
- [section setValue:@"false" forKey:@"hide"];
- [sender setTitle:@"Show" forState:UIControlStateNormal];
- }
- else{
- [section setValue:@"true" forKey:@"hide"];
- [sender setTitle:@"Hide" forState:UIControlStateNormal];
- }
-
- [self.content_data_download setObject:section forKey:[NSString stringWithFormat:@"section_%d",sender.tag]];
- self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
-
- */
-
- switch (sender.tag) {
- case 0:{
-
- }
- break;
- case 1:{
- self.showMore=!self.showMore;
- NSRange range = NSMakeRange(1, 1);
- NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range];
- [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
- }
- break;
- case 2:{
- self.showModels = !self.showModels;
-
- NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndex:2];
- [self.detailTable reloadSections:sectionToReload withRowAnimation:UITableViewRowAnimationAutomatic];
- }
- break;
-
- default:
- break;
- }
-
-
-
- }
- - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
- switch (section) {
- case 0:
- return @"Order Info";
- break;
- case 1:
- return @"More Info";
- break;
- case 2:
- return @"Models";
- case 3:
- return @"Price Info";
- default:
- break;
- }
- return nil;
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- if(self.content_data==nil)
- return 0;
- return 4;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 33;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
-
- // NSDictionary * item_json = [self.content_data objectForKey:@"items"];
- if(section==0)
- return 2;
- if(section==1)
- {
- if(self.showMore)
- return 1;
- else
- return 0;
- }
-
- if(section==2)
- {
- if (self.showModels) {
- int count =[[self.content_data valueForKey:@"model_count"] intValue];
- return count;
- } else {
- return 0;
- }
- }
- if(section==3)
- return 6;
- return 0;
-
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
-
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
-
- switch(indexPath.section)
- {
- case 0:
- {
-
- if(indexPath.row==0)
- {
- NSString *CellIdentifier = @"OrderDetailHtmlCell";
- OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
-
-
-
-
- cell.webview.tag = indexPath.section;
-
- cell.webview.delegate = self;
- // cell.webView.scrollView.contentSize.height = 0;
- cell.webview.scrollView.bounces=NO;
- cell.webview.scrollView.directionalLockEnabled = true;
- CGSize size= cell.webview.scrollView.contentSize;
- size.height=10;
- cell.webview.scrollView.contentSize=size;
-
- [cell.webview loadHTMLString:[self.content_data valueForKey:@"order_info"] baseURL:nil];
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
- }
- else
- {
-
- NSString *CellIdentifier = @"OrderDetailSignatureCell";
- OrderDetailSignatureCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- NSString* img_url = [self.content_data valueForKey:@"sign_url"];
-
- cell.sign_img.userInteractionEnabled = NO;
- __block BOOL hasTapGesture = NO;
- [cell.sign_img.gestureRecognizers enumerateObjectsUsingBlock:^(__kindof UIGestureRecognizer * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-
- if ([obj isKindOfClass:[UITapGestureRecognizer class]]) {
- hasTapGesture = YES;
- *stop = YES;
- }
-
- }];
-
- if (!hasTapGesture) {
- UITapGestureRecognizer *signatureTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onSignOrderClick:)];
- [cell.sign_img addGestureRecognizer:signatureTap];
- }
-
- int status_code = [[self.content_data valueForKey:@"orderStatus"] intValue];
- bool offline_edit =[[self.content_data valueForKey:@"offline_edit"] boolValue];
- if(status_code==1) {
- if(appDelegate.offline_mode==false||offline_edit) {
- cell.sign_img.userInteractionEnabled = YES;
- }
- }
- else if(status_code==0) {
- if(appDelegate.offline_mode==false||offline_edit) {
- cell.sign_img.userInteractionEnabled = YES;
- }
- }
-
-
- NSString* file_name=[img_url lastPathComponent];
- NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
- if(img_data!=nil)
- {
-
- UIImage * img =[UIImage imageWithData:img_data];
- cell.sign_img.image=img ;
- }
- else
- {
-
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
-
-
- if(downloadimg_data!=nil)
- {
-
- [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
-
- UIImage * img =[UIImage imageWithData:downloadimg_data];
- cell.sign_img.image=img ;
- }
- else {
- if (cell.sign_img.userInteractionEnabled) {
- cell.sign_img.image=[UIImage imageNamed:@"taptosign_s"];
- } else {
- cell.sign_img.image = nil;
- }
- }
-
-
- });
- });
-
-
- }
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
-
-
- }
- }
- break;
- case 1:
- {
- NSString *CellIdentifier = @"OrderDetailHtmlCell";
- OrderDetailHtmlCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
-
-
-
- cell.webview.tag = indexPath.section;
- cell.webview.delegate = self;
- // cell.webView.scrollView.contentSize.height = 0;
- cell.webview.scrollView.bounces=NO;
- cell.webview.scrollView.directionalLockEnabled = true;
- CGSize size= cell.webview.scrollView.contentSize;
- size.height=10;
- cell.webview.scrollView.contentSize=size;
-
-
-
- [cell.webview loadHTMLString:[self.content_data valueForKey:@"more_order_info"] baseURL:nil];
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
-
-
- // NSString *CellIdentifier = @"OrderDetailInfoCell";
- // OrderDetailInfoCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- //
- // cell.infoLabel.text =[self.content_data valueForKey:@"more_order_info"];
- //
- //
- //
- //// float width = tableView.frame.size.width;
- //// width-=CELL_MARGIN*2;
- //// CGSize constraintkey = CGSizeMake(width-2*LABEL_MARGIN, 10.0f);//key label width is 40% cell width;
- ////
- //// NSString* key =[self.content_data valueForKey:@"order_info"];
- ////
- ////
- ////
- //// CGRect frame;
- //// frame.size = constraintkey;
- //// frame.origin.x=0;
- //// frame.origin.y=0;
- ////
- //// RTLabel* rtlabel = [[RTLabel alloc] initWithFrame:frame];
- ////
- //// [rtlabel setText: key];
- //// CGSize optimumSize = [rtlabel optimumSize];
- ////
- //// float height = optimumSize.height;
- //// height = MAX(height+LINE_WIDTH+2*LABEL_MARGIN, DEF_CELL_HEIGHT);
- ////
- ////
- //// frame.origin.x=LABEL_MARGIN;
- //// frame.size=CGSizeMake(width, height);
- ////
- //// cell.infoLabel.frame = frame;
- //
- //
- //
- //
- // cell.backgroundColor = [UIColor whiteColor];
- // return cell;
- }
- break;
- case 2:
- {
- NSString *CellIdentifier = @"OrderDetailModelCell";
- OrderDetailModelCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
-
- int count = [[item_json valueForKey:@"count"] intValue];
- NSDictionary * combine_json =[item_json objectForKey:@"combine"];
- cell.bundle_item=combine_json;
-
- double dprice=0.0;
-
- if(cell.bundle_item!=nil)
- {
- int citem=0;
-
- int bcount=[[cell.bundle_item valueForKey:@"count"] intValue];
- for(int bc=0;bc<bcount;bc++)
- {
- NSDictionary * bitem = [cell.bundle_item objectForKey:[NSString stringWithFormat:@"item_%d",bc]];
- int modulus= [[bitem valueForKey:@"modulus"] intValue];
- citem+= modulus;
- double uprice= [[bitem valueForKey:@"unit_price"]doubleValue];
- dprice+= uprice*modulus;
-
- }
- if(citem==1)
- [ cell.buttonBundle setTitle:[NSString stringWithFormat: @"%d bundle item with price of $ %.2f",citem,dprice ]forState:UIControlStateNormal];
- else
- [ cell.buttonBundle setTitle:[NSString stringWithFormat: @"%d bundle items with price of $ %.2f",citem,dprice ]forState:UIControlStateNormal];
-
- cell.buttonBundle.hidden = NO;
- }
- else
- {
- cell.buttonBundle.hidden = YES;
-
- }
-
-
-
- NSString* img_url = [item_json valueForKey:@"img"];
- NSString* description = [item_json valueForKey:@"Item Number"];
- // NSString* description = [item_json valueForKey:@"Item Number"];
- NSString* unitprice = [item_json valueForKey:@"The unit price"];
- NSString* origin_price = [item_json valueForKey:@"origin_price"];
- NSString* subtotal = [item_json valueForKey:@"Subtotal"];
- NSString* qty = [item_json valueForKey:@"QTY"];
- NSString* status = [item_json valueForKey:@"order_item_status"];
- NSString* notes = [item_json valueForKey:@"note"];
-
- if(notes.length>0)
- {
- cell.noteLabel.text = [@"Note: " stringByAppendingString:[notes stringByReplacingOccurrencesOfString:@"\n" withString:@" "]];
- }
- else
- cell.noteLabel.text = nil;
- if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
- {
-
- }
- else
- {
- unitprice=nil;
- origin_price=nil;
- subtotal=nil;
- }
-
- float duprice = [unitprice floatValue];
- float dsubtotal = (duprice+dprice)*[qty intValue];
-
- cell.descriptionLabel.text=description;
- if(dprice>0)
- cell.unitpriceLabel.text = [NSString stringWithFormat:@"%.2f+%.2f",duprice,dprice];//unitprice;
- else
- cell.unitpriceLabel.text = [NSString stringWithFormat:@"%.2f",duprice];//unitprice;
- cell.subtotalLabel.text = [NSString stringWithFormat:@"%.2f",dsubtotal];//subtotal;
- cell.qtyLabel.text = qty;
- cell.statusLabel.text = status;
-
-
- cell.labelOldPrice.text = origin_price;
-
- double discount =[[item_json valueForKey:@"discount"] doubleValue];
- NSString* discountstr=[NSString stringWithFormat:@"%@%% off", [RAUtils FloatFormat:discount]];
- cell.labelDiscount.text = discountstr;
- bool isfree = [[item_json valueForKey:@"is_free"]boolValue];
- if(isfree)
- {
- cell.labelOldPrice.hidden = false;
- cell.labelOldPrice.textColor = [UIColor redColor];
- cell.labelOldPrice.text=@"Free";
- cell.labelOldPrice.hideline = true;
-
- cell.labelDiscount.hidden = true;
- }
- else
- {
- cell.labelOldPrice.textColor = [UIColor blackColor];
- cell.labelOldPrice.hideline = false;
- if(discount==0)
- {
- cell.labelOldPrice.hidden = true;
- cell.labelDiscount.hidden = true;
-
- }
- else
- {
- cell.labelOldPrice.hidden = false;
- cell.labelDiscount.hidden = false;
- }
- }
-
- if (![cell.imageName isEqualToString:img_url]) {
- cell.imageName = img_url;
- [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"loading_s"] forState:UIControlStateNormal];
-
- NSString* file_name=[img_url lastPathComponent];
- NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
- if(img_data!=nil)
- {
-
- UIImage * img =[UIImage imageWithData:img_data];
- [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
- }
- else
- {
-
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
-
-
- if(downloadimg_data!=nil)
- {
-
- [iSalesDB cache_img:downloadimg_data filename:file_name saveTo:img_url];
-
- UIImage * img =[UIImage imageWithData:downloadimg_data];
- [cell.imgbtn setBackgroundImage:img forState:UIControlStateNormal];
- }
- else
- [cell.imgbtn setBackgroundImage:[UIImage imageNamed:@"notfound_s"] forState:UIControlStateNormal];
-
-
- });
- });
-
-
- }
- }
-
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
-
- }
- break;
-
- case 3:
- {
- NSString *CellIdentifier = @"OrderDetailPriceCell";
- OrderDetailPriceCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
- switch (indexPath.row) {
- case 0:
- {
- cell.chargeLabel.text =@"Sub-Total:";
- NSString* price=[self.content_data valueForKey:@"Sub-Total"];
- if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
- {
-
- }
- else
- {
- price=nil;
- }
- cell.priceLabel.text =price;
- break;
- }
- case 1:
- cell.chargeLabel.text = @"Shipping:";
- cell.priceLabel.text =[self.content_data valueForKey:@"Shipping"];
- break;
- case 2:
- cell.chargeLabel.text = @"Liftgate Fee(No loading dock):";
- cell.priceLabel.text =[self.content_data valueForKey:@"Liftgate Fee(No loading dock)"];
- break;
- case 3: {
- cell.chargeLabel.text = @"Handling Fee:";
- cell.priceLabel.text =[self.content_data valueForKey:@"Handling Fee"];
-
- }
- break;
- case 4: {
- cell.chargeLabel.text = @"Tax:";
- NSString *tax = [self.content_data valueForKey:@"Tax"] ? [self.content_data valueForKey:@"Tax"] : @"$0.00";
- cell.priceLabel.text = tax;
- }
- break;
- case 5:
- {
- NSString* price=[self.content_data valueForKey:@"Total"];
- if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
- {
-
- }
- else
- {
- price=nil;
- }
- cell.chargeLabel.text = @"Total:";
- cell.priceLabel.text =price;
- break;
- }
- default:
- break;
- }
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
- }
- }
- return nil;
- // if(tableView==self.itemListTable)
- // {
- // NSString *CellIdentifier = @"CartItemCell";
- // ModelItemCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
- // NSDictionary * combine_json =[item_json objectForKey:@"combine"];
- //
- // cell.bundle_item=combine_json;
- // NSString* img_url = [item_json valueForKey:@"img_url"];
- // NSString* description = [item_json valueForKey:@"description"];
- // // NSString* identifier = [item_json valueForKey:@"identifier"];
- // // NSString* attribute = [item_json valueForKey:@"attribute"];
- // NSString* currency = [item_json valueForKey:@"currency"];
- // int count =[[item_json valueForKey:@"count"] intValue];
- //
- // int stockUom =[[item_json valueForKey:@"stockUom"] intValue];
- //
- // double totalprice =[[item_json valueForKey:@"subtotal_price"] doubleValue];
- //
- // double unitprice=[[item_json valueForKey:@"unit_price"] doubleValue];
- // cell.unit_price = unitprice;
- // // cell.labelAttribute.text = attribute;
- // // cell.labelCurrency.text = currency;
- // cell.labelDescription.text = description;
- // // cell.labelIdentifier.text = identifier;
- // cell.labelPrice.text = [NSString stringWithFormat:@"%.2f",totalprice];
- //
- // cell.labelUnitPrice.text = [NSString stringWithFormat:@"%.2f",unitprice];
- //
- //
- //
- // NSString* cart_item_id= [item_json valueForKey:@"cart_item_id"];
- // cell.cart_id = cart_item_id;
- // [cell init_Stepper:stockUom max:9999 min:stockUom value:count];
- //
- //
- //
- // [cell set_Count:count];
- //
- // NSString* file_name=[img_url lastPathComponent];
- // NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
- // if(img_data!=nil)
- // {
- //
- // UIImage * img =[UIImage imageWithData:img_data];
- // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
- // }
- // else
- // {
- //
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- //
- //
- //
- // if(downloadimg_data!=nil)
- // {
- // [iSalesDB cache_img:downloadimg_data :file_name ];
- //
- // UIImage * img =[UIImage imageWithData:downloadimg_data];
- // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
- // }
- //
- // });
- // });
- //
- //
- // }
- // return cell;
- // }
- // else
- // {
- // NSString *CellIdentifier = @"OrderInfoListItem";
- // UITableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- // return cell;
- // }
- }
- #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)
- {
- [self copyOrder];
- }
- }
- - (void)copyOrder {
-
- UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Copy Order"];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-
- NSDictionary* order_json = [iSalesNetwork copy_Order:self.order_code];
-
- dispatch_async(dispatch_get_main_queue(), ^{
- [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
- if([[order_json valueForKey:@"result"] intValue]==2)
- {
- // NSString* orderCode = [order_json valueForKey:@"orderCode"];
-
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // if([appDelegate.order_code isEqualToString: self.order_code])
- // {
- // [appDelegate closeOrder];
- //// appDelegate.order_code= nil;
- // [appDelegate SetSo:nil];
- //
- //
- // }
- UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Copy successful." message:[NSString stringWithFormat:@"New order SO#: %@",[order_json valueForKey:@"so_id"]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
-
- [alert show];
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- [self.navigationController popViewControllerAnimated:false];
-
- }
- else
- {
- [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Cpoy Order" controller:self] ;
- }
-
-
-
- });
- });
- }
- #pragma mark - web view delegate
- //- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
- //{
- // if(navigationType != UIWebViewNavigationTypeLinkClicked)
- // return true;
- // // NSString *currentURL =[webView.request.URL lastPathComponent];// [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
- //
- // NSString* str = request.URL.absoluteString;
- // if([str isEqualToString:@"about:blank"])
- // return true;
- // WebViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"WebViewController"];
- // ViewController.url = str;
- // // ViewController. = self.function_name;
- // // ViewController.behavior =BEHAVIOR_SEARCH;
- //
- // [self.navigationController pushViewController:ViewController animated:YES];
- // DebugLog(@"shouldStartLoadWithRequest");
- // return false;
- //}
- - (void)webViewDidFinishLoad:(UIWebView *)webView
- {
-
-
- DebugLog(@"webViewDidFinishLoad @@@@@@@@@@@@@@@@@ entry");
-
-
-
- UITableViewCell *cell = (UITableViewCell *)[[webView superview] superview];
-
-
- NSIndexPath *indexPath = [self.detailTable indexPathForCell:cell];
- if(indexPath==nil)
- {//for ios7
- cell = (UITableViewCell *) webView.superview.superview.superview;
- indexPath = [self.detailTable indexPathForCell:cell];
- }
- float height= 0;
- if(indexPath.section==0)
- height=self.web_info_height;
- else
- height = self.web_moreinfo_height;
-
- if(height>0)
- return;
-
-
- // UIScrollView *scrollerView = [webView.subviews objectAtIndex:0];
- // CGSize size= webView.scrollView.contentSize;
- // CGSize fittingSize = [webView sizeThatFits:CGSizeZero];
-
- CGRect frame = webView.frame;
- NSString *fitHeight = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight;"];
- frame.size.height = [fitHeight floatValue];
- //webView.frame = frame;
-
-
- // DebugLog(@"webViewDidFinishLoad ^^^^^^^^^^^^^^^^^Saveheight height=%f section=%ld",webView.scrollView.contentSize.height,indexPath.section);
-
- if(indexPath.section==0)
- self.web_info_height=frame.size.height;
- else
- self.web_moreinfo_height = frame.size.height;
- // [self.content.webviewHeight setObject:[NSString stringWithFormat:@"%f",frame.size.height/*webView.scrollView.contentSize.height*/] forKey:[NSString stringWithFormat:@"%ld",(long)indexPath.section]];
-
- DebugLog(@"webViewDidFinishLoad ^^^^^^^^^^^^^^^^^reloadRowsAtIndexPaths");
-
-
-
- // [self.table beginUpdates];
- [self.detailTable reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
- // [self.table endUpdates];
-
- // [self.webviewoprationQueue addOperationWithBlock:^{
- // }];
-
-
- // [self.table endUpdates];
- // }
-
-
- }
- @end
|