| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987 |
- //
- // ScanOrderListViewController.m
- // iSales-USAI
- //
- // Created by Rui Zhang on 2/8/22.
- // Copyright © 2022 United Software Applications, Inc. All rights reserved.
- //
- #import "ScanOrderListViewController.h"
- #import "OrderListTableViewCell.h"
- #import "RANetwork.h"
- #import "OrderDetailViewController.h"
- #import "MainViewController.h"
- #import "ContactListViewController.h"
- #import "DefaultAppearance.h"
- #import "DefaultTableHeaderView.h"
- #import "SelectUploadOrderViewController.h"
- #import "NotificationNameCenter.h"
- #import "RASingleton.h"
- #import "ERPUtils.h"
- #import "UploadCell.h"
- #import "CustomerEditViewController.h"
- #import "CreateOrderViewController.h"
- #import "MainViewController.h"
- @interface ScanOrderListViewController ()
- @property (nonatomic,strong) NSOperationQueue *dataOperationQueue;
- @property (nonatomic,strong) NSMutableArray *mergeList;
- @property (nonatomic,assign) NSInteger orderType;///<sales order/shop order
- @property (nonatomic,strong) NSMutableDictionary *sales_order_filter;
- @property (nonatomic,strong) NSMutableDictionary *shop_order_filter;
- @property (strong, nonatomic) IBOutlet UIBarButtonItem *mergeListButton;
- @property (strong, nonatomic) IBOutlet UIBarButtonItem *editOrderListButton;
- @property (strong, nonatomic) IBOutlet UISegmentedControl *orderTypeSegmentControl;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *tableTopConstraint;
- @end
- @implementation ScanOrderListViewController
- - (NSOperationQueue *)dataOperationQueue {
- if (!_dataOperationQueue) {
- _dataOperationQueue = [[NSOperationQueue alloc] init];
- _dataOperationQueue.maxConcurrentOperationCount = 1;
- }
- return _dataOperationQueue;
- }
- - (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- AppDelegate* appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
- [appdelegate.uploadManager removeObserver:self forKeyPath:@"arr_queue"];
- }
- - (NSMutableArray *)mergeList {
- if (!_mergeList) {
- _mergeList = [NSMutableArray array];
- }
- return _mergeList;
- }
- -(void) logout
- {
- [self.mergeList removeAllObjects];
- self.offset = 0;
- [self.content_data removeAllObjects];
- [self.submit_content_data removeAllObjects];
- [self.table_order reloadData];
- [self.table_submit reloadData];
- self.status_cadedate = nil;
- }
- #ifndef RA_NOTIFICATION
- -(void) reload_container_getdata:(bool) update_data
- {
- [super reload_container_getdata:update_data];
- if(update_data)
- {
- // self.offset = 0;
- // [self.content_data removeAllObjects];
- self.reset_result=true;
- self.norefresh=true;
- [self reload_data];
- }
- else
- {
- [self.table_order reloadData];
- }
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- if(appDelegate.can_create_order)
- {
-
-
- [self.btn_newOrder setImage:[UIImage imageNamed:@"neworder"]];
- self.btn_newOrder.enabled = true;
- }
- else
- {
- [self.btn_newOrder setImage:nil];
- self.btn_newOrder.enabled = false;
- }
- }
- #endif
- -(void) showHidePrice
- {
- #ifndef RA_NOTIFICATION
- [self reload_container_getdata:false];
- #endif
- }
- - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
- {
-
- if([keyPath isEqualToString:@"arr_queue"])
- {
- // NSArray* arr1 = [change objectForKey:NSKeyValueChangeOldKey];
- // NSArray* arr2 = [change objectForKey:NSKeyValueChangeNewKey];
- // if(arr1.count!=arr2.count)
-
- __weak typeof(self) weakself = self;
- dispatch_async(dispatch_get_main_queue(), ^{
- blockDebugLog(@"arr_queue changed reload tableview");
- [self.table_upload reloadData];
- });
-
- }
- // if(context)
- // NSLog(@"old: %@", [change objectForKey:NSKeyValueChangeOldKey]);
- // NSLog(@"old: %@", [change objectForKey:NSKeyValueChangeNewKey]);
- // NSLog(@"context: %@", context);
- }
- - (void)onNewOrder: (NSNotification *)notification
- {
- [self onNewOrderClicked:nil];
-
- }
- - (void)onShowList: (NSNotification *)notification
- {
-
- if([notification.name isEqualToString:@"ShowUnSubmit"])
- {
- [self.orderTypeSegmentControl setSelectedSegmentIndex:0];
-
- self.table_order.hidden=false;
- self.table_submit.hidden = true;
- // [self.table_upload reloadData];
- [self.table_order reloadData];
- [self.table_submit reloadData];
-
- // onSegmentChanged
- }
- else
- {
-
- [self.orderTypeSegmentControl setSelectedSegmentIndex:1];
-
- self.table_order.hidden=true;
- self.table_submit.hidden = false;
- // [self.table_order reloadData];
- [self.table_order reloadData];
- [self.table_submit reloadData];
- }
-
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // self.edgesForExtendedLayout = UIRectEdgeNone;
-
- self.loading_queue = dispatch_queue_create("orderlist_loading", NULL);
-
- 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;
- #ifndef RA_NOTIFICATION
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changePriceType:) name:Change_Price_Type_Notification object:nil];
- #endif
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(lockOrderListNotification:) name:Lock_Permission_Notification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(lockOrderListNotification:) name:unLock_Permission_Notification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleUserLogin:) name:User_LoginOK_Notification object:nil];
-
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onNewOrder:) name:@"NewOrder" object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onShowList:) name:@"ShowSubmit" object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onShowList:) name:@"ShowUnSubmit" object:nil];
-
-
- AppDelegate* appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
-
-
- [appdelegate.uploadManager addObserver:self
- forKeyPath:@"arr_queue"
- options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld)
- context:@"arr_queue changed"];
-
-
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(refresh_btn_click:)];
- // tap.minimumPressDuration = 0.8; //定义按的时间
- [self.label_net_err addGestureRecognizer:tap];
- // Do any additional setup after loading the view.
- self.offset = 0;
- self.limit = 25;
- self.content_data = [[NSMutableArray alloc]init];
- self.submit_content_data = [[NSMutableArray alloc]init];
- // Customer Order Type 0 Shop Order/ 1 Sales Order
- // self.orderType = self.orderTypeSegmentControl.selectedSegmentIndex;
- [RASingleton sharedInstance].customer_order_type = self.orderType;
-
-
- UIRefreshControl *ref = [[UIRefreshControl alloc]init];
- ref.tag = 201 ;
- 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.table_order addSubview:ref];
- self.table_order.allowsMultipleSelectionDuringEditing = YES;
-
- // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
- // NSString *documents = [paths objectAtIndex:0];
- // NSString *dist_path = [documents stringByAppendingPathComponent:@"status_filter_cadedate.json"];
-
-
- // if ([[NSFileManager defaultManager] fileExistsAtPath:dist_path]) {
- //
- // DebugLog(@"文件已经存在了");
- //
- // }
- // else
- // {
- //
- //
- //
- // // DebugLog(@"resourceSampleImagesFolderPath=%@",resourceFolderPath);
- //
- // NSData *mainBundleFile = [NSData dataWithContentsOfFile:order_filter_source_path];
- //
- // // DebugLog(@"mainBundleFile==%@",mainBundleFile);
- //
- // [[NSFileManager defaultManager] createFileAtPath:dist_path
- //
- // contents:mainBundleFile
- //
- // attributes:nil];
- //
- // }
-
- [self loadfilter];
-
-
- }
- -(void) loadfilter
- {
- //
- // if(self.status_cadedate!=nil)
- // return;
- //
- // UIApplication * app = [UIApplication sharedApplication];
- // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- //
- // if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
- // self.shop_order_filter = [RASingleton sharedInstance].shop_order_status_filter;
- // self.sales_order_filter = [RASingleton sharedInstance].sales_order_status_filter;
- // if(self.init_style==OL_OPEN)
- // {
- // NSData *data=[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"status_filter_cadedate_open" ofType:@"json" ]];
- // NSError *error=nil;
- // self.status_cadedate = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error] mutableCopy];
- //
- // }
- //// else if (self.orderTypeSegmentControl.selectedSegmentIndex == 0) {
- //// self.status_cadedate = self.shop_order_filter;
- //// } else {
- //// self.status_cadedate = self.sales_order_filter;
- //// }
- // return;
- // }
- //
- // NSData* json =nil;
- // if(self.init_style==OL_OPEN)
- // {
- // json=[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"status_filter_cadedate_open" ofType:@"json" ]];
- // NSError *error=nil;
- // self.status_cadedate = [[NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error] mutableCopy];
- //
- // }
- // else
- // {
- // // json=//[NSData dataWithContentsOfFile:dist_path];
- // // NSError *error=nil;
- // self.status_cadedate = appDelegate.OrderFilter;//[[NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error] mutableCopy];
- // }
- }
- - (IBAction)onCancel:(id)sender {
- if(self.onCancel)
- self.onCancel();
- [self.navigationController popViewControllerAnimated:false];
- }
- - (IBAction)onStatusFilterClick:(id)sender {
- // if (self.table_order.isEditing || self.init_style == OL_OPEN) {
- // return;
- // }
- // EnumSelectViewController* enumvc =[[UIStoryboard storyboardWithName:@"CommonEditor" bundle:nil] instantiateViewControllerWithIdentifier:@"EnumSelectorViewController"];
- // enumvc.delegate = self;
- // enumvc.max_select = 0;
- // //enumvc.updatePosition = indexPath;
- // // if([[required lowercaseString] isEqualToString:@"true"])
- // // enumvc.canbeEmpty = false;
- // // else
- // // enumvc.canbeEmpty =true;
- // enumvc.cadedate = self.status_cadedate ;
- // enumvc.title = @"Order Status Selection";
- // // enumvc.value = [value_json mutableCopy];
- // enumvc.single_select =false;
- //
- // [self.navigationController pushViewController:enumvc animated:true];
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [self loadfilter];
-
- [[self navigationController] setNavigationBarHidden:!self.showNavibar animated:NO];
-
- // 检查权限
- AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
- NSMutableArray *items = [self.toolbarView.items mutableCopy];
-
- if(appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
-
- // Check for Saved Order中Type和History Type不一致导致Status不正确
- [RASingleton sharedInstance].customer_order_type = self.orderType;
- // if (!self.table_order.isEditing) { // 在编辑状态下不能change Type否则显示混乱
- // [self changeOrderType:self.orderType];
- // }
-
- // 合并订单的权限
- if ([RASingleton sharedInstance].permissions_merge_order) { // 能够合并
-
- // 4 6 顺序不能换
- if (![items containsObject:self.editOrderListButton]) { // 没显示button
- [items insertObject:self.editOrderListButton atIndex:4];
- }
-
- self.toolbarView.items = items;
-
- } else { // 不能合并
-
- if ([items containsObject:self.editOrderListButton]) { // 显示button
- [items removeObject:self.editOrderListButton];
- }
-
- self.toolbarView.items = items;
- }
-
- // // Check For Saved Order 不能合并
- // if(self.init_style==OL_OPEN || self.orderType == 1) {
- //
- // if ([items containsObject:self.editOrderListButton]) { // 显示button
- // [items removeObject:self.editOrderListButton];
- // }
- //
- // self.toolbarView.items = items;
- //
- // }
-
- } else {
-
-
- if ([items containsObject:self.editOrderListButton]) { // 显示button
- [items removeObject:self.editOrderListButton];
- }
-
- self.toolbarView.items = items;
- }
-
- // 非Customer用户不用区分Sales Order 和 Shop Order
- {
- self.orderTypeSegmentControl.hidden = NO;
-
- // [self.view removeConstraint:self.tableTopConstraint];
- //
- //
- // NSLayoutConstraint *myConstraint =[NSLayoutConstraint
- // constraintWithItem:self.table_order //item1
- // attribute:NSLayoutAttributeTop //约束属性
- // relatedBy:NSLayoutRelationEqual //属性间的关系
- // toItem:self.orderTypeSegmentControl//item2
- // attribute:NSLayoutAttributeBottom//约束属性
- // multiplier:1
- // constant:0.0];// 固定距离
- // self.tableTopConstraint = myConstraint;
- // [self.view addConstraint: myConstraint];//为button重新添加一个约束
- //
- //
- //
- // CGFloat y = CGRectGetMinY(self.orderTypeSegmentControl.frame);
- // CGFloat height = CGRectGetHeight(self.orderTypeSegmentControl.frame);
- // CGRect frame = self.table_order.frame;
- // if (frame.origin.y == y) {
- // frame.origin.y = y + height;
- // frame.size.height -= height;
- // }
- // self.table_order.frame = frame;
- }
-
- // 修复Homer显示NPD
- // if (self.orderTypeSegmentControl.numberOfSegments > 1) {
- // [self.orderTypeSegmentControl setTitle:[NSString stringWithFormat:@"Purchase Order to %@",COMPANY_SHORT_NAME] forSegmentAtIndex:1];
- // }
- //
- // // 显示Sales Order与否
- // if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
- // if ([RASingleton sharedInstance].global_lock || ![RASingleton sharedInstance].customer_can_see_sales_Order) { // 是否解锁,是否有查看Sales Order权限
- // if (self.orderTypeSegmentControl.numberOfSegments > 1) {
- // [self.orderTypeSegmentControl removeSegmentAtIndex:1 animated:YES];
- // [self changeOrderType:0];
- // }
- // } else {
- //
- // if (self.orderTypeSegmentControl.numberOfSegments == 1 && !self.table_order.isEditing) {
- // [self.orderTypeSegmentControl insertSegmentWithTitle:[NSString stringWithFormat:@"Purchase Order to %@",COMPANY_SHORT_NAME] atIndex:1 animated:YES];
- // }
- //
- // }
- // }
-
- }
- -(void) newoloorder
- {
- // NSString* order_code = RASingleton.sharedInstance.scan_temp_code;
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // appDelegate.order_code = order_code;
-
- // if(appDelegate.user.length==0)
- // {
- // [RAUtils message_alert:@"Please login first." title:@"Warring" controller:self];
- // return;
- // }
-
- // NSData* json =[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:URL_SO_CART ofType:@"json" ]];
- // NSMutableDictionary* cartTemplate=[OLDataProvider loadScanTemplate:@"scan_cart.json"];
- // RASingleton.sharedInstance.scan_cart=cartTemplate;//[[RAConvertor data2dict:json] mutableCopy];
-
-
-
- // appDelegate.user_type = USER_ROLE_EMPLOYEE;
- appDelegate.can_set_cart_price = true;
- appDelegate.can_see_price = true;
- RASingleton.sharedInstance.scan_cart = nil;
- RASingleton.sharedInstance.price_type = 1;
- // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- // NSString *documents = [paths objectAtIndex:0];
-
- {
-
-
- NSString *orderdir = [OLDataProvider getScanPath];
- // NSError *error = nil;
- // [ [NSFileManager defaultManager] moveItemAtPath:[OLDataProvider getScanTempPath] toPath:orderdir error:&error];
- //
- //
-
- // [OLDataProvider moveScanTemp2Order];
- // bool bsuccess=[[NSFileManager defaultManager] createDirectoryAtPath:orderdir withIntermediateDirectories:YES attributes:nil error:&error];
-
-
- // NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
- // NSString * string = [checked componentsJoinedByString:@","];
- // [params setValue:string forKey:@"cart2Checkbox"];
-
- // NSData* data=[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:URL_SO_ORDER ofType:@"json" ]];
-
- // NSMutableDictionary* dict=[[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error] mutableCopy];
- //
- // NSMutableDictionary* dict=[OLDataProvider loadScanTemplate:@"scan_order.json"];
- //
- //
- //
- //
- // NSString *orderPath = [orderdir stringByAppendingPathComponent:@"order.json"];
- //
- //
- //
- // [RAUtils dicttofile:orderPath dict:dict];
- //
-
-
-
-
- NSString *contactpath = [orderdir stringByAppendingPathComponent:@"contact.json"];
-
-
-
- [RAUtils dicttofile:contactpath dict:appDelegate.customerInfo];
-
-
- }
-
-
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- #else
- MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- [main_vc reloadCart:true immediately:false];
- #endif
-
- // MainViewController * mainvc=(MainViewController * )appDelegate.main_vc;
- // mainvc.btnScan.enabled = true;
-
- // [appDelegate updateScanButton:true];
-
- // AppDelegate* appDelegate = (AppDelegate*)UIApplication.sharedApplication.delegate;
- MainViewController * mainvc = (MainViewController*)appDelegate.main_vc;
-
- // [ActiveViewController Notify:@"ScanOrderListViewController" Message:@"NewOrder"];
- [mainvc switchToCart];
-
- }
- - (IBAction)onNewOrderClicked:(id)sender {
-
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- // if(appDelegate.user.length<=0)
- // {
- // [RAUtils message_alert:@"Please login first." title:@"Warring" controller:self];
- // return;
- // }
-
- if(appDelegate.order_code.length>0)
- {
- // // 当前订单先关闭
-
- [OLDataProvider scanCloseOrder];
-
- }
-
-
- // RASingleton.sharedInstance.enable_OfflineOrder = true;
-
-
- // __block MainViewController *brself= self;
- // if(appDelegate.contact_id.length<=0&&false)
- // {
- //
- // UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"New Offline Order" message:nil preferredStyle:UIAlertControllerStyleAlert];
- // UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"With Offline Contact" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
- //
- // // if(appDelegate.order_code && appDelegate.order_code.length>0)
- // // {
- // // [RAUtils message_alert:@"Please close current order and try again." title:@"" controller:self];
- // // }
- // // NSLog(@"new click");
- //
- // NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
- //
- // // NSString *path = [[NSBundle mainBundle] pathForResource:@"editContact.json" ofType:nil];
- //
- // CustomerEditViewController * cuseditVC = [[CustomerEditViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
- // cuseditVC.bnewcustomer=true;
- // cuseditVC.bolocustomer = true;
- // cuseditVC.url_type = URL_FILE;
- // cuseditVC.request_url=[OLDataProvider scanTemplatePath:@"scan_contact.json"];
- //
- // cuseditVC.params = params;
- //
- // cuseditVC.returnValue=^(NSMutableDictionary* value)
- // {
- // if(value==nil)
- // {
- // [RAUtils message_alert:@"Cannot create order without customer infomation." title:@"" controller:self];
- // }
- // else
- // {
- // NSString* contact_id=[[NSUUID new] UUIDString];
- //
- //
- // //---------------- construct customer_contact----------------------
- // NSString* customer_first_name = [value valueForKey:@"customer_first_name"];
- // if(customer_first_name==nil)
- // customer_first_name=@"";
- //
- // NSString* customer_last_name= [value valueForKey:@"customer_last_name"];
- // if(customer_last_name==nil)
- // customer_last_name=@"";
- // NSString* customer_contact = [NSString stringWithFormat:@"%@ %@",customer_first_name,customer_last_name];
- // customer_contact=[customer_contact stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
- // [value setValue:customer_contact forKey:@"customer_contact"];
- //
- //
- //
- // value [@"customer_cid"] = contact_id;
- // appDelegate.contact_id=contact_id;
- // appDelegate.customerInfo = value;
- //
- //
- //
- //
- //
- //
- // // [brself refreshContactDisplay];
- // [self newoloorder];
- //
- // // [brself switchToCart:nil];
- //
- // }
- // };
- //
- //
- // // cuseditVC.delegate=self;
- // //
- // // if(checked.count==count)
- // // {
- // // orderinfoVC.have_tail = true
- // // }
- //
- // [[self navigationController] setNavigationBarHidden:NO animated:NO];
- // [self.navigationController pushViewController:cuseditVC animated:false];
- //
- // // [self dismissViewControllerAnimated:NO completion:^{
- // //// [(UINavigationController*)[self parentViewController] pushViewController:cuseditVC animated:false];;
- // //// [[self navigationController] setNavigationBarHidden:NO animated:NO];
- // //
- // //// [self pushViewController:cuseditVC animated:false];
- // // }];
- //
- // // [[self navigationController] setNavigationBarHidden:NO animated:NO];
- // // [self.navigationController pushViewController:cuseditVC animated:false];
- //
- //
- // }];
- //
- //
- //
- // UIAlertAction *alertCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
- //
- // }];
- //
- // [alertControl addAction:actionOne];
- //
- // // [alertControl addAction:alertthree];
- // [alertControl addAction:alertCancel];
- //
- // [self presentViewController:alertControl animated:YES completion:nil];
- // }
- // else
- {
- [self newoloorder];
- }
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- -(void)manually_refresh
- {
- UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:201];
- if(self.isrefreshing)
- {
- [reF endRefreshing];
- return;
- }
- reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Refreshing"];
- if ([self respondsToSelector:@selector(ReloadData)])
- [self performSelector:@selector(ReloadData) withObject:nil afterDelay:1];
-
- }
- -(void)ReloadData
- {
-
-
- // [self.content_data removeAllObjects];
- // [self.table_order reloadData];
-
-
- // self.table_order.hidden = true;
- UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:201];
-
- [reF endRefreshing];
-
- reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
-
- self.keywords=nil;
- // self.offset = 0;
- self.reset_result=true;
- // [self.content_data removeAllObjects];
- // [self.table_order reloadData];
-
-
- [self loadpage];
-
- // [self loadpage];
-
- }
- - (void)operation_loadPage {
-
- if (self.dataOperationQueue.operationCount > 1) { // 队列后面还有操作
- return;
- }
-
- // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- // NSString *documents = [paths objectAtIndex:0];
-
- NSString *userdir = [OLDataProvider getUserPath];
- NSMutableDictionary* orderlist = [OLDataProvider getScanOrderList];
- // NSString *orderlistPath = [userdir stringByAppendingPathComponent:@"orderlist.json"];
- // orderlist=[[RAUtils dictfromfile:orderlistPath] mutableCopy];
- [self.content_data removeAllObjects];
- int count = [orderlist[@"count"] intValue];
- for(int i=0;i<count;i++)
- {
-
- NSDictionary* objmsg = [orderlist objectForKey:[NSString stringWithFormat:@"item_%d",i]];
- [self.content_data addObject:[NSMutableDictionary dictionaryWithDictionary:objmsg]];
-
- }
-
-
-
- NSMutableDictionary* submitlist = [OLDataProvider getScanSubmitList];
- // NSString *submitlistPath = [userdir stringByAppendingPathComponent:@"submitlist.json"];
- // submitlist=[[RAUtils dictfromfile:submitlistPath] mutableCopy];
- [self.submit_content_data removeAllObjects];
- int scount = [submitlist[@"count"] intValue];
- for(int i=0;i<scount;i++)
- {
-
- NSDictionary* objmsg = [submitlist objectForKey:[NSString stringWithFormat:@"item_%d",i]];
- [self.submit_content_data addObject:[NSMutableDictionary dictionaryWithDictionary:objmsg]];
-
- }
-
-
- // int i =self.btnrefresh.state;
- self.load_more_hint=@"All loaded";
- // self.btnrefresh.titleLabel.text =NSLocalizedString(@"no_more", nil);
- // [self.btnrefresh setTitle:@"No more" forState:UIControlStateNormal];
-
-
-
- dispatch_sync(dispatch_get_main_queue(), ^{
- // self.table_order.hidden = false;
- // self.table_submit.hidden = false;
- self.reset_result=false;
- [self.table_order reloadData ];
- [self.table_submit reloadData ];
- });
- return;
- //
- //
- //
- //// dispatch_async(self.loading_queue, ^{
- //
- // dispatch_sync(dispatch_get_main_queue(), ^{
- // if(self.reset_result)
- // {
- // self.offset = 0;
- // [self.content_data removeAllObjects];
- // [self.table_order reloadData];
- // }
- //
- // // NSMutableArray* arr_status = [[NSMutableArray alloc] init];
- //
- // NSMutableArray* arr_statusname = [[NSMutableArray alloc] init];
- // int count = [[self.status_cadedate valueForKey:@"count"] intValue];
- // for(int i=0;i<count;i++)
- // {
- // NSDictionary* val_json =[self.status_cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]];
- // int check = [[val_json valueForKey:@"check"] intValue];
- // if(check==1)
- // {
- // // [arr_status addObject:[NSString stringWithFormat:@"%@",[val_json valueForKey:@"value_id"]]];
- // [arr_statusname addObject:[NSString stringWithFormat:@"%@",[val_json valueForKey:@"value"]]];
- //
- // // break;
- // }
- // }
- //
- // // NSString * str_status = [arr_status componentsJoinedByString:@","];
- // NSString * str_statusname = [arr_statusname componentsJoinedByString:@","];
- // if(str_statusname.length==0)
- // str_statusname = @"All";
- // self.label_filter.text = str_statusname;
- // if(self.offset==0)
- // {
- // self.table_order.hidden = true;
- //
- // self.mum.center = self.view.center;
- //
- // self.mum.hidden = false;
- // [self.mum startAnimating];
- // }
- // self.label_net_err.hidden=true;
- //
- // });
- //// });
- //// dispatch_async(self.loading_queue, ^{
- // if(self.isrefreshing)
- // return;
- // self.isrefreshing=true;
- //
- //
- //
- //
- //
- //
- //
- //
- //
- // NSMutableArray* arr_status = [[NSMutableArray alloc] init];
- //
- // // NSMutableArray* arr_statusname = [[NSMutableArray alloc] init];
- // int count = [[self.status_cadedate valueForKey:@"count"] intValue];
- // for(int i=0;i<count;i++)
- // {
- // NSDictionary* val_json =[self.status_cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]];
- // int check = [[val_json valueForKey:@"check"] intValue];
- // if(check==1)
- // {
- // [arr_status addObject:[NSString stringWithFormat:@"%@",[val_json valueForKey:@"value_id"]]];
- // // [arr_statusname addObject:[NSString stringWithFormat:@"%@",[val_json valueForKey:@"value"]]];
- //
- // // break;
- // }
- // }
- //
- // NSString * str_status = [arr_status componentsJoinedByString:@","];
- //
- //
- //
- //
- //
- // dispatch_sync(dispatch_get_main_queue(), ^{
- // BOOL isMerged = NO;
- // AppDelegate *appDelegate = nil;
- // appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
- // if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
- // if (self.orderType == 0) {
- // isMerged = NO;
- // } else {
- // isMerged = YES;
- // }
- // }
- //
- // [RANetwork request_orderlist:self.offset limit:self.limit keywords:self.keywords status:str_status customer:self.customer_id is_merged:isMerged completionHandler:^(NSMutableDictionary *result) {
- // NSMutableDictionary* content=result;
- //
- //
- //
- //
- //
- //
- // [self.mum stopAnimating];
- // self.isrefreshing=false;
- // if (self.dataOperationQueue.operationCount > 1) { // 队列后面还有操作
- // return ;
- // }
- // int result_code=[[content valueForKey:@"result"] intValue];
- //
- // if(result_code==2||result_code==0)
- // {
- //
- //
- // int count = [[content valueForKey:@"count" ] intValue] ;
- //
- //
- // self.time_zone = [content valueForKey:@"time_zone" ];
- // self.offset += count;
- // for(int i=0;i<count;i++)
- // {
- //
- // NSDictionary* objmsg = [content objectForKey:[NSString stringWithFormat:@"item_%d",i]];
- // [self.content_data addObject:[NSMutableDictionary dictionaryWithDictionary:objmsg]];
- //
- // }
- // if(count<self.limit)
- // {
- //
- // // int i =self.btnrefresh.state;
- // self.load_more_hint=@"All loaded";
- // // self.btnrefresh.titleLabel.text =NSLocalizedString(@"no_more", nil);
- // // [self.btnrefresh setTitle:@"No more" forState:UIControlStateNormal];
- // }
- // else
- // {
- // self.load_more_hint=@"Load more...";
- // // self.btnrefresh.enabled = true;
- // // self.btnrefresh.titleLabel.text =NSLocalizedString(@"load_more",nil);
- // // [self.btnrefresh setTitle:@"Load more" forState:UIControlStateNormal];
- // }
- //
- //
- // self.table_order.hidden = false;
- // self.reset_result=false;
- // [self.table_order reloadData ];
- // }
- // else if(result_code==RESULT_NET_ERROR &&self.offset==0)
- // {
- // self.label_net_err.hidden=false;
- // self.table_order.hidden = true;
- // }
- // else
- // {
- // [RAUtils message_alert:[content valueForKey:@"err_msg"] title:@"Loading Order List" controller:self] ;
- // }
- //
- //
- //
- //
- //
- //
- // }];
- //
- // });
- //
- ////
- //// NSMutableDictionary* content=nil;
- //// content=[[RANetwork request_OrderList:self.offset limit : self.limit keywords:self.keywords status:str_status customer:self.customer_id is_merged:isMerged] mutableCopy];
- ////
- ////
- //// dispatch_sync(dispatch_get_main_queue(), ^{
- ////
- ////
- ////
- ////
- ////
- //// [self.mum stopAnimating];
- //// self.isrefreshing=false;
- //// if (self.dataOperationQueue.operationCount > 1) { // 队列后面还有操作
- //// return ;
- //// }
- //// int result=[[content valueForKey:@"result"] intValue];
- ////
- //// if(result==2||result==0)
- //// {
- ////
- ////
- //// int count = [[content valueForKey:@"count" ] intValue] ;
- ////
- ////
- //// self.time_zone = [content valueForKey:@"time_zone" ];
- //// self.offset += count;
- //// for(int i=0;i<count;i++)
- //// {
- ////
- //// NSDictionary* objmsg = [content objectForKey:[NSString stringWithFormat:@"item_%d",i]];
- //// [self.content_data addObject:[NSMutableDictionary dictionaryWithDictionary:objmsg]];
- ////
- //// }
- //// if(count<self.limit)
- //// {
- ////
- //// // int i =self.btnrefresh.state;
- //// self.load_more_hint=@"All loaded";
- //// // self.btnrefresh.titleLabel.text =NSLocalizedString(@"no_more", nil);
- //// // [self.btnrefresh setTitle:@"No more" forState:UIControlStateNormal];
- //// }
- //// else
- //// {
- //// self.load_more_hint=@"Load more...";
- //// // self.btnrefresh.enabled = true;
- //// // self.btnrefresh.titleLabel.text =NSLocalizedString(@"load_more",nil);
- //// // [self.btnrefresh setTitle:@"Load more" forState:UIControlStateNormal];
- //// }
- ////
- ////
- //// self.table_order.hidden = false;
- //// self.reset_result=false;
- //// [self.table_order reloadData ];
- //// }
- //// else if(result==RESULT_NET_ERROR &&self.offset==0)
- //// {
- //// self.label_net_err.hidden=false;
- //// self.table_order.hidden = true;
- //// }
- //// else
- //// {
- //// [RAUtils message_alert:[content valueForKey:@"err_msg"] title:@"Loading Order List" controller:self] ;
- //// }
- ////
- ////
- ////
- ////
- //// });
- ////
- //
- //// });
- }
- -(void) loadpage
- {
- __weak typeof(self) weakself = self;
- NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
-
- if (weakself) {
- __strong typeof(weakself) strongself = weakself;
- [strongself operation_loadPage];
- }
-
- }];
-
- [self.dataOperationQueue addOperation:operation];
-
- }
- - (void)loadmore
- {
- // self.btnrefresh.enabled = NO;
- // self.btnrefresh.titleLabel.text =NSLocalizedString(@"loading",nil);
-
- // [self.btnrefresh setTitle:@"Loading..." forState:UIControlStateNormal];
- [self loadpage];
- }
- //-(void)changeCell
- //{
- //// UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
- //// reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"refreshing"];
- // [self performSelector:@selector(loadmore) withObject:nil afterDelay:1];
- // DebugLog(@"refresh!!!!!!!!");
- //
- //}
- -(void) neworder
- {
-
- __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Create Order" completion:^{
- [RANetwork request_create_order:^(NSMutableDictionary *result) {
- NSMutableDictionary* return_json =result;
-
- [waitalert dismissViewControllerAnimated:YES completion:^{
- if([[return_json valueForKey:@"result"] intValue]==2)
- {
- int result=[[return_json valueForKey:@"result"] intValue];
- if(result==2)
- {
- //successed.
-
- NSString* order_code = [return_json valueForKey:@"orderCode"];
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- appDelegate.order_code = order_code;
- appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
-
-
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- #else
- MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- [main_vc reloadCart:true immediately:false];
- #endif
-
- [self ReloadData];
-
-
- // [self performSelector:@selector(loadpage) withObject:nil afterDelay:1];
- // [self loadpage];
-
-
- // if(self.shopCartBlock!=nil)
- // {
- // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
- //
- //
- // CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
- // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
- // iv.image = img;
- // // [self.contentView addSubview:iv];
- // self.shopCartBlock(iv);
- //
- // }
-
- }
- }
- else
- {
- [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:self] ;
- }
- }];
- // [waitalert dismissViewControllerAnimated:YES completion:nil];
-
-
-
-
-
-
-
-
- }];
-
- }];
-
- // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- //
- // NSDictionary* return_json = [RANetwork new_Order];
- //
- // dispatch_async(dispatch_get_main_queue(), ^{
- // [waitalert dismissViewControllerAnimated:YES completion:nil];
- //
- //
- // if([[return_json valueForKey:@"result"] intValue]==2)
- // {
- // int result=[[return_json valueForKey:@"result"] intValue];
- // if(result==2)
- // {
- // //successed.
- //
- // NSString* order_code = [return_json valueForKey:@"orderCode"];
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // appDelegate.order_code = order_code;
- // appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
- //
- //
- //#ifdef RA_NOTIFICATION
- // [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- //#else
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- // [main_vc reloadCart:true immediately:false];
- //#endif
- //
- // [self ReloadData];
- //
- //
- // // [self performSelector:@selector(loadpage) withObject:nil afterDelay:1];
- // // [self loadpage];
- //
- //
- // // if(self.shopCartBlock!=nil)
- // // {
- // // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
- // //
- // //
- // // CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
- // // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
- // // iv.image = img;
- // // // [self.contentView addSubview:iv];
- // // self.shopCartBlock(iv);
- // //
- // // }
- //
- // }
- // }
- // else
- // {
- // [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:self] ;
- // }
- //
- //
- //
- //
- // });
- // });
- }
- //#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)
- // {
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- //
- // if(appDelegate.order_code && appDelegate.order_code.length>0)
- // {
- //// appDelegate.order_code= nil;
- //// [appDelegate SetSo:nil];
- //
- // if (appDelegate.user_type == USER_ROLE_EMPLOYEE) {
- // // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- // ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- // cvc.showNavibar = true;
- // cvc.contact_type = @"Sales_Order_Customer";
- // cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
- //
- // appDelegate.contact_id=[value valueForKey:@"customer_cid"];
- // appDelegate.customerInfo = value;
- //
- // self.norefresh = true;
- // [self neworder];
- //
- //
- //
- // // [main_vc checklogin:true];
- // // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
- //
- // //
- // // if(self.returnValue)
- // // self.returnValue(value);
- // };
- //
- // cvc.onCancel = ^(){
- // self.norefresh = true;
- // if(appDelegate.customerInfo==nil)
- // {
- // [RAUtils message_alert:@"Cannot create order without customer infomation." title:@"" controller:self];
- // }
- // else
- // {
- // [self neworder];
- // }
- // // [main_vc checklogin:true];
- // };
- // cvc.onReset = ^(){
- // // [main_vc checklogin:true];
- // };
- //
- // [self.navigationController pushViewController:cvc animated:true];
- // }
- // else if (appDelegate.user_type == USER_ROLE_CUSTOMER){
- // [self neworder];
- // }
- //
- // }
- // else
- // {
- // //create new;
- //
- // if(appDelegate.customerInfo==nil)// select contact if current contact not exist
- // {
- // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
- // ContactListViewController* cvc = [[UIStoryboard storyboardWithName:@"ERP_Mobile_Contact" bundle:nil] instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
- // cvc.showNavibar = true;
- // cvc.contact_type = @"Sales_Order_Customer";
- // cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
- //
- // appDelegate.contact_id=[value valueForKey:@"customer_cid"];
- // appDelegate.customerInfo = value;
- //
- //
- // if(appDelegate.order_code==nil)
- // [self neworder];
- //
- // // [main_vc checklogin:true];
- // // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
- //
- // //
- // // if(self.returnValue)
- // // self.returnValue(value);
- // };
- //
- // cvc.onCancel = ^(){
- //
- // [RAUtils message_alert:@"Cannot create order without customer infomation." title:@"" controller:self];
- //
- //
- //
- // };
- // cvc.onReset = ^(){
- // [main_vc checklogin:true];
- // };
- //
- // [self.navigationController pushViewController:cvc animated:true];
- // }
- // else
- // {
- // [self neworder];
- // }
- // }
- //
- // }
- //}
- #pragma mark - Table view data source
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
- {
- if(tableView==self.table_order||tableView==self.table_submit)
- return 66;
- else
- return 100;
-
- }
- //- (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
- {
- if(tableView==self.table_order)
- {
- 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.shadowColor = [UIColor blackColor].CGColor;
- myView.layer.shadowOffset = CGSizeMake(0, 0);
- myView.layer.shadowOpacity = 0.5;
- myView.layer.shadowRadius = 2.0;
-
-
- UILabel *statuslabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 11, 130, 22)];
- statuslabel.textColor=UIColorFromRGB(color);
- statuslabel.backgroundColor = [UIColor clearColor];
- statuslabel.text=NSLocalizedString(@"Status", nil);
- [statuslabel sizeToFit];
- [myView addSubview:statuslabel];
-
- // UILabel *solabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 21, 130, 22)];
- // solabel.textColor=UIColorFromRGB(color);
- // solabel.backgroundColor = [UIColor clearColor];
- // solabel.text=NSLocalizedString(@"SO#", nil);
- // [solabel sizeToFit];
- // [myView addSubview:solabel];
-
- // UILabel *userlabel = [[UILabel alloc] initWithFrame:CGRectMake(165, 21, 125, 22)];
- // userlabel.textColor=UIColorFromRGB(color);
- // userlabel.backgroundColor = [UIColor clearColor];
- // userlabel.text=NSLocalizedString(@"Sales rep", nil);
- // [userlabel sizeToFit];
- // [myView addSubview:userlabel];
-
- UILabel *creatorlabel = [[UILabel alloc] initWithFrame:CGRectMake(165, 11, 125, 22)];
- creatorlabel.textColor=UIColorFromRGB(color);
- creatorlabel.backgroundColor = [UIColor clearColor];
- creatorlabel.text=NSLocalizedString(@"Create by", nil);
- [creatorlabel sizeToFit];
- [myView addSubview:creatorlabel];
-
- UILabel *contactlabel = [[UILabel alloc] initWithFrame:CGRectMake(296, 11, 150, 22)];
-
- contactlabel.textColor=UIColorFromRGB(color);
- contactlabel.backgroundColor = [UIColor clearColor];
- contactlabel.text=NSLocalizedString(@"Company / Contact ID", nil);
- [contactlabel sizeToFit];
- [myView addSubview:contactlabel];
-
-
-
- //
- // UILabel *modellabel = [[UILabel alloc] initWithFrame:CGRectMake(424, 11, 52, 22)];
- // modellabel.textColor=[UIColor whiteColor];
- // modellabel.backgroundColor = [UIColor clearColor];
- // modellabel.text=NSLocalizedString(@"Model", nil);
- // [modellabel sizeToFit];
- // [myView addSubview:modellabel];
-
- // UILabel *modellabel = [[UILabel alloc] initWithFrame:CGRectMake(self.table_order.frame.size.width-276, 2, 100, 22)];
- // modellabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
- // modellabel.textColor=[UIColor whiteColor];
- // modellabel.backgroundColor = [UIColor clearColor];
- // modellabel.text=NSLocalizedString(@"Items/QTY", nil);
- // [modellabel sizeToFit];
- // [myView addSubview:modellabel];
-
-
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- UILabel *pricelabel = nil;
- if(appDelegate.user_type==USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore && self.orderType==1)
- pricelabel=[[UILabel alloc] initWithFrame:CGRectMake(/*492*/self.table_order.frame.size.width-276, 2, 100, 22)];
- else
- pricelabel=[[UILabel alloc] initWithFrame:CGRectMake(/*492*/self.table_order.frame.size.width-276, 11, 100, 22)];
- pricelabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
- pricelabel.textColor=UIColorFromRGB(color);
- pricelabel.backgroundColor = [UIColor clearColor];
- pricelabel.text=NSLocalizedString(@"Order Total", nil);
- [pricelabel sizeToFit];
- [myView addSubview:pricelabel];
-
-
- if(appDelegate.user_type==USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore && self.orderType==1)
- {
- UILabel *polabel = nil;
- polabel=[[UILabel alloc] initWithFrame:CGRectMake(/*492*/self.table_order.frame.size.width-276, 21, 100, 22)];
- polabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
- polabel.textColor=UIColorFromRGB(color);
- polabel.backgroundColor = [UIColor clearColor];
- polabel.text=NSLocalizedString(@"PO#", nil);
- [polabel sizeToFit];
- [myView addSubview:polabel];
- }
-
-
- UILabel *timelabel = [[UILabel alloc] initWithFrame:CGRectMake(self.table_order.frame.size.width-163/*605*/,11, 148, 22)];
- timelabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
- timelabel.textColor=UIColorFromRGB(color);
- timelabel.backgroundColor = [UIColor clearColor];
- if(self.time_zone==nil)
- timelabel.text=@"Create time";
- else
- timelabel.text=[NSString stringWithFormat:@"Create time (%@)",self.time_zone];
- [timelabel sizeToFit];
- [myView addSubview:timelabel];
-
- myView.autoresizesSubviews=true;
- // [myView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
-
-
-
-
- // modellabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
- // pricelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
- // timelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
- myView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
- //
- return myView;
- }
- else
- if(tableView==self.table_submit)
- {
- 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.shadowColor = [UIColor blackColor].CGColor;
- myView.layer.shadowOffset = CGSizeMake(0, 0);
- myView.layer.shadowOpacity = 0.5;
- myView.layer.shadowRadius = 2.0;
-
-
- UILabel *statuslabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 11, 130, 22)];
- statuslabel.textColor=UIColorFromRGB(color);
- statuslabel.backgroundColor = [UIColor clearColor];
- statuslabel.text=NSLocalizedString(@"SO#", nil);
- [statuslabel sizeToFit];
- [myView addSubview:statuslabel];
-
- // UILabel *solabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 21, 130, 22)];
- // solabel.textColor=UIColorFromRGB(color);
- // solabel.backgroundColor = [UIColor clearColor];
- // solabel.text=NSLocalizedString(@"SO#", nil);
- // [solabel sizeToFit];
- // [myView addSubview:solabel];
-
- // UILabel *userlabel = [[UILabel alloc] initWithFrame:CGRectMake(165, 21, 125, 22)];
- // userlabel.textColor=UIColorFromRGB(color);
- // userlabel.backgroundColor = [UIColor clearColor];
- // userlabel.text=NSLocalizedString(@"Sales rep", nil);
- // [userlabel sizeToFit];
- // [myView addSubview:userlabel];
-
- UILabel *creatorlabel = [[UILabel alloc] initWithFrame:CGRectMake(165, 11, 125, 22)];
- creatorlabel.textColor=UIColorFromRGB(color);
- creatorlabel.backgroundColor = [UIColor clearColor];
- creatorlabel.text=NSLocalizedString(@"Create by", nil);
- [creatorlabel sizeToFit];
- [myView addSubview:creatorlabel];
-
- UILabel *contactlabel = [[UILabel alloc] initWithFrame:CGRectMake(296, 11, 150, 22)];
-
- contactlabel.textColor=UIColorFromRGB(color);
- contactlabel.backgroundColor = [UIColor clearColor];
- contactlabel.text=NSLocalizedString(@"Company / Customer ID", nil);
- [contactlabel sizeToFit];
- [myView addSubview:contactlabel];
-
-
-
- //
- // UILabel *modellabel = [[UILabel alloc] initWithFrame:CGRectMake(424, 11, 52, 22)];
- // modellabel.textColor=[UIColor whiteColor];
- // modellabel.backgroundColor = [UIColor clearColor];
- // modellabel.text=NSLocalizedString(@"Model", nil);
- // [modellabel sizeToFit];
- // [myView addSubview:modellabel];
-
- // UILabel *modellabel = [[UILabel alloc] initWithFrame:CGRectMake(self.table_order.frame.size.width-276, 2, 100, 22)];
- // modellabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
- // modellabel.textColor=[UIColor whiteColor];
- // modellabel.backgroundColor = [UIColor clearColor];
- // modellabel.text=NSLocalizedString(@"Items/QTY", nil);
- // [modellabel sizeToFit];
- // [myView addSubview:modellabel];
-
-
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- UILabel *pricelabel = nil;
- if(appDelegate.user_type==USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore && self.orderType==1)
- pricelabel=[[UILabel alloc] initWithFrame:CGRectMake(/*492*/self.table_order.frame.size.width-276, 2, 100, 22)];
- else
- pricelabel=[[UILabel alloc] initWithFrame:CGRectMake(/*492*/self.table_order.frame.size.width-276, 11, 100, 22)];
- pricelabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
- pricelabel.textColor=UIColorFromRGB(color);
- pricelabel.backgroundColor = [UIColor clearColor];
- pricelabel.text=NSLocalizedString(@"Order Total", nil);
- [pricelabel sizeToFit];
- [myView addSubview:pricelabel];
-
-
- if(appDelegate.user_type==USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore && self.orderType==1)
- {
- UILabel *polabel = nil;
- polabel=[[UILabel alloc] initWithFrame:CGRectMake(/*492*/self.table_order.frame.size.width-276, 21, 100, 22)];
- polabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
- polabel.textColor=UIColorFromRGB(color);
- polabel.backgroundColor = [UIColor clearColor];
- polabel.text=NSLocalizedString(@"PO#", nil);
- [polabel sizeToFit];
- [myView addSubview:polabel];
- }
-
-
- UILabel *timelabel = [[UILabel alloc] initWithFrame:CGRectMake(self.table_order.frame.size.width-163/*605*/,11, 148, 22)];
- timelabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
- timelabel.textColor=UIColorFromRGB(color);
- timelabel.backgroundColor = [UIColor clearColor];
- if(self.time_zone==nil)
- timelabel.text=@"Create time";
- else
- timelabel.text=[NSString stringWithFormat:@"Create time (%@)",self.time_zone];
- [timelabel sizeToFit];
- [myView addSubview:timelabel];
-
- myView.autoresizesSubviews=true;
- // [myView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
-
-
-
-
- // modellabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
- // pricelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
- // timelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
- myView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
- //
- return myView;
- }
- else return nil;
-
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 44;
- }
- //
- //- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
- // if(section==0)
- // return nil;
- // else
- // return @"detail section";
- //}
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- if(tableView==self.table_order)
- {
- return self.content_data.count;
- // NSDictionary * item_json = [self.content_data objectForKey:@"items"];
- // if( self.content_data.count==0)
- // return 0;
- // return self.content_data.count+1;
- }
- if(tableView==self.table_submit)
- {
- return self.submit_content_data.count;
- // NSDictionary * item_json = [self.content_data objectForKey:@"items"];
- // if( self.content_data.count==0)
- // return 0;
- // return self.content_data.count+1;
- }
- else
- {
- AppDelegate* Appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
- return Appdelegate.uploadManager.arr_queue.count;
- }
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if(tableView==self.table_order)
- {
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- // if(tableView==self.itemListTable)
- // {
-
- // if(indexPath.row>self.content_data.count)
- // {
- // int debug=true;
- // }
- // DebugLog(@"row %ld",(long)indexPath.row);
- // if(indexPath.row==self.content_data.count)
- // {
- // UITableViewCell *moreCell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"mores"];
- // UILabel *moreDataLabel=[[UILabel alloc] init];
- //
- // moreDataLabel.tag=200;
- // moreDataLabel.text=self.load_more_hint;
- // [moreDataLabel setFont:[UIFont systemFontOfSize:14.0f]];
- // [moreDataLabel setTextAlignment:NSTextAlignmentCenter];
- // moreDataLabel.frame=CGRectMake(0, 10, self.table_order.bounds.size.width, 20);
- // [moreDataLabel setBackgroundColor:[UIColor clearColor]];
- // moreDataLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
- // // [moreDataLabel addTarget:self action:@selector(changeCell) forControlEvents:UIControlEventValueChanged];
- //
- // [moreCell.contentView addSubview:moreDataLabel];
- // if([self.load_more_hint isEqualToString:@"Load more..."])
- // [self performSelector:@selector(loadmore) withObject:nil afterDelay:1];
- // // DebugLog(@"更多...");
- // moreCell.backgroundColor = [UIColor whiteColor];
- // return moreCell;
- // }
- // else
- {
- NSString *CellIdentifier = @"OrderListTableViewCell";
- OrderListTableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
- NSString* so= [self.content_data[indexPath.row] valueForKey:@"so#"];
- NSString* price= [self.content_data[indexPath.row] valueForKey:@"price"];
- // if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
- // {
- //
- // }
- // else
- // {
- // price=nil;
- // }
- //
- // NSInteger statusCode = [[self.content_data[indexPath.row] valueForKey:@"orderStatus"] integerValue];
- NSString* purchase_time= [self.content_data[indexPath.row] valueForKey:@"purchase_time"];
- NSString* status = [self.content_data[indexPath.row] valueForKey:@"order_status"] ;
- // if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
- // status = [ERPUtils orderStatus:statusCode];
- // }
- NSString* customer_name = [self.content_data[indexPath.row] valueForKey:@"customer_name"];
- NSString* model_count = [self.content_data[indexPath.row] valueForKey:@"model_count"];
- NSString* sales = [self.content_data[indexPath.row] valueForKey:@"sales_rep"];
- NSString* creator = [self.content_data[indexPath.row] valueForKey:@"create_by"];
- NSString *po = [self.content_data[indexPath.row] valueForKey:@"po_id"];
-
- CGRect price_frame = cell.labelprice.frame;
- if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore && self.orderType == 1) {
-
- cell.label_po.hidden = NO;
- price_frame.origin.y = 5;
- cell.label_po.text = po;
-
- } else {
-
- cell.label_po.hidden = YES;
- price_frame.origin.y = 21;
- }
- cell.labelprice.frame = price_frame;
- cell.label_so.text=so;
- cell.labelprice.text=price;//price;
- cell.label_date.text=purchase_time;
- cell.label_contact.text=customer_name;
- cell.label_model.hidden = false;
- cell.label_model.text = model_count;
-
- cell.label_sales.text = sales;
- cell.label_creator.text = creator;
-
- cell.label_status.text=status;
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
- }
- }
- else if(tableView==self.table_submit)
- {
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- {
- NSString *CellIdentifier = @"OrderListTableViewCell";
- OrderListTableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
- NSString* so= [self.submit_content_data[indexPath.row] valueForKey:@"so#"];
- NSString* price= [self.submit_content_data[indexPath.row] valueForKey:@"price"];
- // if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
- // {
- //
- // }
- // else
- // {
- // price=nil;
- // }
- //
- // NSInteger statusCode = [[self.content_data[indexPath.row] valueForKey:@"orderStatus"] integerValue];
- NSString* purchase_time= [self.submit_content_data[indexPath.row] valueForKey:@"purchase_time"];
- NSString* status = [self.submit_content_data[indexPath.row] valueForKey:@"order_status"] ;
- // if (appDelegate.user && appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
- // status = [ERPUtils orderStatus:statusCode];
- // }
- NSString* customer_name = [self.submit_content_data[indexPath.row] valueForKey:@"customer_name"];
- NSString* model_count = [self.submit_content_data[indexPath.row] valueForKey:@"model_count"];
- NSString* sales = [self.submit_content_data[indexPath.row] valueForKey:@"sales_rep"];
- NSString* creator = [self.submit_content_data[indexPath.row] valueForKey:@"create_by"];
- NSString *po = [self.submit_content_data[indexPath.row] valueForKey:@"po_id"];
-
- CGRect price_frame = cell.labelprice.frame;
- if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore && self.orderType == 1) {
-
- cell.label_po.hidden = NO;
- price_frame.origin.y = 5;
- cell.label_po.text = po;
-
- } else {
-
- cell.label_po.hidden = YES;
- price_frame.origin.y = 21;
- }
- cell.labelprice.frame = price_frame;
- cell.label_so.text=so;
- cell.labelprice.text=price;//[RAConvertor currencyNumber:(price.floatValue)];//price;
- cell.label_date.text=purchase_time;
- cell.label_contact.text=customer_name;
- cell.label_model.hidden = false;
- cell.label_model.text = model_count;
-
- cell.label_sales.text = sales;
- cell.label_creator.text = creator;
-
- cell.label_status.text=status;
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
- }
- }
- else
- {
- AppDelegate* Appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
-
-
-
-
- {
- NSString *CellIdentifier = @"UploadCell";
- UploadCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
-
-
- NSDictionary * item_json = Appdelegate.uploadManager.arr_queue[indexPath.row];
- //
- // if (cell.operation) {
- // cell.operation.updateUI = nil;
- // }
-
- RAUploadOperation* op = item_json[@"operation"];
-
-
-
- NSString* status =nil;
- switch ([item_json[@"status"] intValue]) {
- case TaskStatusStart:
- status=@"uploading";
- break;
- case TaskStatusStop:
- status=@"stop";
- break;
- case TaskStatusError:
- status=@"warning";
- break;
- case TaskStatusWait:
- status=@"waiting";
- break;
- case TaskStatusFinish:
- status=@"finish";
- break;
-
- default:
- status=@"warning";
- break;
- }
-
- double progress =[item_json[@"progress"] doubleValue];
- cell.progress=progress;
- cell.name=item_json[@"file"];
- cell.state= status;
- cell.errorMsg = item_json[@"msg"];
-
-
-
-
- // __block RAUploadOperation* block_op = op;
- // __block UploadCell* block_cell = cell;
- // __block NSIndexPath* block_index = indexPath;
- // long idx = indexPath.row;
- // __weak typeof(self) weakself = self;
-
- op.updateUI=^(){
-
-
- // blockDebugLog(@"updateUI @ row%ld %p \n operation %p",idx,block_cell,block_op);
-
- NSString* status =nil;
- switch ([item_json[@"status"] intValue]) {
- case TaskStatusStart:
- status=@"uploading";
- break;
- case TaskStatusStop:
- status=@"stop";
- break;
- case TaskStatusError:
- status=@"warning";
- break;
- case TaskStatusWait:
- status=@"waiting";
- break;
- case TaskStatusFinish:
- status=@"finish";
- break;
-
- default:
- status=@"warning";
- break;
- }
- double progress =[item_json[@"progress"] doubleValue];
- cell.progress=progress;
- cell.name=item_json[@"file"];
- cell.state= status;
- cell.errorMsg = item_json[@"msg"];
-
- };
- DebugLog(@"%@ set update ui",item_json[@"file"]);
- // cell.operation = op;
- //
- return cell;
- }
-
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if(tableView==self.table_order)
- {
-
-
-
-
- // RASingleton.sharedInstance.enable_OfflineOrder = true;
- if (tableView.isEditing) { // 编辑模式下不响应
- return;
- }
- //
- if(indexPath.row==self.content_data.count)
- return;
-
- {
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
-
- // NSString *orderdir = [OLDataProvider getScanPath];
- NSString *userdir = [OLDataProvider getUserPath];
- NSMutableDictionary* orderitem =self.content_data[indexPath.row];
- NSString* ordercode =orderitem[@"order_code"];
- NSString *orderdir = [userdir stringByAppendingPathComponent:ordercode];
- // NSMutableDictionary* order= [[RAUtils dictfromfile:[orderdir stringByAppendingPathComponent:@"order.json"]] mutableCopy];
- NSMutableDictionary* cart= [[RAUtils dictfromfile:[orderdir stringByAppendingPathComponent:@"cart.json"]] mutableCopy];
-
- if([appDelegate.available_price_group containsObject:cart[@"price_group"]] && [RADataProvider all_price_group][cart[@"price_group"]]!=nil)
- {
- appDelegate.order_code = ordercode;
-
- [appDelegate setUser:orderitem[@"create_by"]];
- // appDelegate.user =;
- // appDelegate.custo orderitem[@"customer_name"]
- // appDelegate.user_type = USER_ROLE_EMPLOYEE;
- appDelegate.can_set_cart_price = true;
- appDelegate.can_see_price = true;
-
-
- NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
-
- // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- // NSString *documents = [paths objectAtIndex:0];
-
-
-
- NSMutableDictionary* contact= [[RAUtils dictfromfile:[orderdir stringByAppendingPathComponent:@"contact.json"]] mutableCopy];
- // NSMutableDictionary* app= [[RAUtils dictfromfile:[orderdir stringByAppendingPathComponent:@"app.json"]] mutableCopy];
-
- [appDelegate setCustomerInfo: contact];
- appDelegate.contact_id = contact[@"customer_cid"];
- RASingleton.sharedInstance.scan_cart = cart;
- appDelegate.price_group = cart[@"price_group"];
- RASingleton.sharedInstance.price_type = [cart[@"price_type"] intValue];
-
-
- [appDelegate update_count_mark];
- // [appDelegate updateScanButton:true];
- [appDelegate SetMode:@""];
-
-
-
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- #else
-
-
- [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- #endif
-
- // [self.navigationController pushViewController:orderinfoVC animated:true];
-
- [((MainViewController*)appDelegate.main_vc) switchToCart];
-
- return;
-
-
-
-
- }
- else
- {
- //价格组不存在 询问刷新
-
- NSString * title =@"Price Has Changed";
- NSString* message = @"Shopping cart items will show updated prices. ";
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
- //block代码块取代了delegate
-
-
- // [alertControl addTextFieldWithConfigurationHandler:^(UITextField *textField) {
- // textField.text = self.save_name;
- //
- //
- // }];
-
- UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Continue" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-
-
- NSMutableDictionary* orderitem =self.content_data[indexPath.row];
- NSString* ordercode =orderitem[@"order_code"];
- appDelegate.order_code = ordercode;
-
- [appDelegate setUser:orderitem[@"create_by"]];
- // appDelegate.user =;
- // appDelegate.custo orderitem[@"customer_name"]
- // appDelegate.user_type = USER_ROLE_EMPLOYEE;
- appDelegate.can_set_cart_price = true;
- appDelegate.can_see_price = true;
-
-
- NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
-
- // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- // NSString *documents = [paths objectAtIndex:0];
-
-
-
- NSMutableDictionary* contact= [[RAUtils dictfromfile:[orderdir stringByAppendingPathComponent:@"contact.json"]] mutableCopy];
- // NSMutableDictionary* app= [[RAUtils dictfromfile:[orderdir stringByAppendingPathComponent:@"app.json"]] mutableCopy];
-
- [appDelegate setCustomerInfo: contact];
- appDelegate.contact_id = contact[@"customer_cid"];
- //用默认价格组替换订单之前保存的价格组
- [RADataProvider default_price_group];
- cart[@"price_group"]=appDelegate.price_group;
-
- RASingleton.sharedInstance.scan_cart = cart;
- // appDelegate.price_group = cart[@"price_group"];
- RASingleton.sharedInstance.price_type = [cart[@"price_type"] intValue];
-
-
- [appDelegate update_count_mark];
- // [appDelegate updateScanButton:true];
- [appDelegate SetMode:@""];
-
-
-
- #ifdef RA_NOTIFICATION
- [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_CART_REFRESH];
- #else
-
-
- [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- #endif
-
- // [self.navigationController pushViewController:orderinfoVC animated:true];
-
- [((MainViewController*)appDelegate.main_vc) switchToCart];
-
- return;
-
-
- }];
-
- UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
- DebugLog(@"Cancel");
- return;
- }];
- [alertControl addAction:actionOne];
-
- [alertControl addAction:alertthree];
-
- //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
-
-
- [self presentViewController:alertControl animated:YES completion:nil];
-
-
- }
-
- }
-
-
- }
- else if(tableView==self.table_submit)
- {
-
-
-
-
- // RASingleton.sharedInstance.enable_OfflineOrder = true;
- if (tableView.isEditing) { // 编辑模式下不响应
- return;
- }
- //
- // if(indexPath.row==self.content_data.count)
- // return;
-
- {
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
-
- NSMutableDictionary* orderitem =self.submit_content_data[indexPath.row];
- NSString* ordercode =orderitem[@"order_code"];
-
- NSString *orderdir = [OLDataProvider getScanOrderPathByCode:ordercode];
- // orderdir = [orderdir stringByAppendingPathComponent:ordercode];
- NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
- CreateOrderViewController * orderinfoVC = [[CreateOrderViewController alloc] initWithNibName:@"CommonEditor.iPad" bundle:nil];
- orderinfoVC.disable_dropdown_refresh=true;
- orderinfoVC.url_type = URL_FILE;
- orderinfoVC.request_url=[orderdir stringByAppendingPathComponent:@"order.json"];
- orderinfoVC.params = params;
- orderinfoVC.title=@"";
- orderinfoVC.delegate=nil;
- [self.navigationController pushViewController:orderinfoVC animated:true];
- // if(checked.count==count)
- // {
- // orderinfoVC.have_tail = true
- // }
-
-
-
- // appDelegate.order_code = ordercode;
- //
- // [appDelegate setUser:orderitem[@"create_by"]];
- //
- // appDelegate.can_set_cart_price = true;
- // appDelegate.can_see_price = true;
- //
- //
- // NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
- //
- //
- //
- //
- // NSString *orderdir = [OLDataProvider getScanPath];
- // NSMutableDictionary* cart= [[RAUtils dictfromfile:[orderdir stringByAppendingPathComponent:@"cart.json"]] mutableCopy];
- // NSMutableDictionary* contact= [[RAUtils dictfromfile:[orderdir stringByAppendingPathComponent:@"contact.json"]] mutableCopy];
- //
- // [appDelegate setCustomerInfo: contact];
- // appDelegate.contact_id = contact[@"customer_cid"];
- // RASingleton.sharedInstance.scan_cart = cart;
- // RASingleton.sharedInstance.price_type = [cart[@"price_type"] intValue];
- //
- //
- // [appDelegate update_count_mark];
- // [appDelegate SetMode:@""];
- //
- //
- //
- //#ifdef RA_NOTIFICATION
- // [ActiveViewController Notify:@"CartViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- //#else
- //
- //
- // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- //#endif
- //
- //// [self.navigationController pushViewController:orderinfoVC animated:true];
- //
- // [((MainViewController*)appDelegate.main_vc) switchToCart];
- //
- return;
-
-
- }
-
-
- }
-
- }
- #pragma mark - searchBar delegate;
- - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
- {
- self.keywords=searchBar.text;
- // self.offset = 0;
- // [self.content_data removeAllObjects];
- self.reset_result=true;
- [self loadpage];
- }
- - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
- {
-
- if([searchText isEqualToString:@""] && !self.reset)
- {
- DebugLog(@"clear");
- self.reset=true;
- self.keywords=nil;
-
- // self.offset = 0;
- // [self.content_data removeAllObjects];
- self.reset_result=true;
- [self loadpage];
- }
- else
- self.reset = false;
- }
- #pragma mark 在滑动手势删除某一行的时候,显示出更多的按钮
- - (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- // 添加一个删除按钮
-
- // self.indexPath=indexPath;
-
- if(tableView==self.table_order)
- {
- if(indexPath.row==self.content_data.count)
- return @[];
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // NSString* so= [self.content_data[indexPath.row] valueForKey:@"so#"];
- NSString* order_code= [self.content_data[indexPath.row] valueForKey:@"order_code"];
- // NSString* order_status= [self.content_data[indexPath.row] valueForKey:@"order_status"];
- // NSInteger statusCode = [[self.content_data[indexPath.row] valueForKey:@"orderStatus"] integerValue];
-
- if(true/*appDelegate.user_type==USER_ROLE_EMPLOYEE || (appDelegate.user_type==USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeCustomer)*/) {
-
- UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
-
- DebugLog(@"delete click");
-
-
- NSString * title =@"Are you sure to delete order?";
-
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert];
- //block代码块取代了delegate
-
-
- // [alertControl addTextFieldWithConfigurationHandler:^(UITextField *textField) {
- // textField.text = self.save_name;
- //
- //
- // }];
-
- UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-
- [OLDataProvider deleteScanOrder:order_code];
-
- if([appDelegate.order_code isEqualToString:order_code])
- [appDelegate closeOrder];
-
-
- //
-
-
- // [self prepareReturn:nil];
-
-
-
- // [self.navigationController popViewControllerAnimated:true];
- // [((MainViewController*)appDelegate.main_vc) switchToOrder];
-
-
- return;
- }];
-
- 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];
-
-
-
-
-
-
-
- }];
- deleteRowAction.backgroundColor = UIColor.redColor;//UIColorFromRGB(0x336699);
-
- // 添加一个编辑按钮
-
-
-
-
-
-
-
-
-
-
-
-
-
- //
- // if(/*[order_status isEqualToString:@"Saved Order"]*/statusCode == 1&&appDelegate.can_cancel_order)
- // return @[cancelAction];
- //
- // else
- // {
-
- {
- NSMutableArray* arr=[@[] mutableCopy];
- if(appDelegate.can_delete_order)
- [arr addObject:deleteRowAction];
- // if(appDelegate.can_cancel_order)
- // [arr addObject:cancelAction];
- return arr;
- }
- // }
-
-
-
- }
-
- return @[];
- }
- else if(tableView==self.table_submit)
- {
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // NSString* so= [self.content_data[indexPath.row] valueForKey:@"so#"];
- NSString* order_code= [self.submit_content_data[indexPath.row] valueForKey:@"order_code"];
- // NSString* order_status= [self.content_data[indexPath.row] valueForKey:@"order_status"];
- // NSInteger statusCode = [[self.content_data[indexPath.row] valueForKey:@"orderStatus"] integerValue];
-
- {
-
- UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
-
- DebugLog(@"delete click");
-
-
- NSString * title =@"Are you sure to delete the submitted record?";
-
- UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert];
- //block代码块取代了delegate
-
- UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
-
- [OLDataProvider deleteSubmittedOrder:order_code];
-
-
-
- return;
- }];
-
- 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];
-
-
-
-
-
-
-
- }];
- deleteRowAction.backgroundColor = UIColorFromRGB(0x336699);
-
- // 添加一个编辑按钮
-
-
- {
- NSMutableArray* arr=[@[] mutableCopy];
- if(appDelegate.can_delete_order)
- [arr addObject:deleteRowAction];
- // if(appDelegate.can_cancel_order)
- // [arr addObject:cancelAction];
- return arr;
- }
- // }
-
-
-
- }
- }
- else
- {
- AppDelegate* Appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
- NSMutableDictionary * task = Appdelegate.uploadManager.arr_queue[indexPath.row];
-
-
- __weak typeof(self) weakself = self;
- UITableViewRowAction *startAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Restart"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
-
- if (Appdelegate.uploadManager.onlyWiFi && Appdelegate.uploadManager.reach.currentReachabilityStatus != ReachableViaWiFi) {
- [weakself.view makeToast:@"Current Network is not WiFi" duration:3.0 position:CSToastPositionCenter];
- [tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
- return ;
- }
- DebugLog(@"Start click");
- task[@"retry"]=[NSNumber numberWithInt:0];
- [Appdelegate.uploadManager startTask:task];
-
- [tableView reloadData];
-
-
-
-
- }];
-
-
- startAction.backgroundColor = UIColorFromRGB(0xff9933);
-
-
- UITableViewRowAction *removeAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Remove" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
-
-
- [Appdelegate.uploadManager removeTask:task];
-
- // [tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
-
- }];
-
- removeAction.backgroundColor = UIColorFromRGB(0x9BBF5A);
-
-
-
-
- // UIColorFromRGB(0x336699);
-
-
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- switch ([task[@"status"] intValue]) {
-
- case TaskStatusFinish:
- return @[removeAction];
-
- case TaskStatusError:
-
- return @[startAction,removeAction];
-
- case TaskStatusStop:
- return @[startAction];
- default:
- return nil;
- break;
- }
-
-
-
- }
-
- }
- - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
-
-
-
- if(tableView==self.table_order)
-
- {
- if(indexPath.row==self.content_data.count)
- return NO;
-
- // // if(self.init_style==OL_OPEN)
- // // return NO;
- //
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // // NSString* order_status= [self.content_data[indexPath.row] valueForKey:@"order_status"];
- // NSInteger statusCode = [[self.content_data[indexPath.row] valueForKey:@"orderStatus"] integerValue];
- //
- // if(appDelegate.user_type==USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
- // // saved && ((type==0 && merge_permission) || type == 1 || can_cancel)
- //
- // BOOL isSavedOrder = /*[order_status isEqualToString:@"Saved Order"]*/statusCode == 1;
- // switch (self.orderType) {
- // case 0:{ // Shop Order
- //
- // if (!isSavedOrder) {
- // return NO;
- // } else {
- // if ([RASingleton sharedInstance].permissions_merge_order || appDelegate.can_cancel_order) {
- // return YES;
- // } else {
- // return NO;
- // }
- // }
- //
- // }
- // break;
- // case 1:{ // Sales Order
- // if (isSavedOrder && appDelegate.can_cancel_order) {
- // return YES;
- // }
- // return NO;
- // }
- // break;
- //
- // default:
- // break;
- // }
- //
- // } else {
- // return YES;
- // }
- return YES;
- }
- else if(tableView==self.table_submit)
- {
- return YES;
- }
- else
- {
- AppDelegate* Appdelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
- if(Appdelegate.uploadManager.arr_queue.count==0)
- return false;
- NSDictionary * item_json = Appdelegate.uploadManager.arr_queue[indexPath.row];
-
- bool ret=false;
- switch ([item_json[@"status"] intValue]) {
- case TaskStatusStart:
- case TaskStatusWait:
-
- ret=false;
- break;
- case TaskStatusFinish:
- case TaskStatusStop:
- case TaskStatusError:
-
- ret = true;
- break;
- default:
- ret=false;
- break;
- }
- return ret;
- }
- }
- - (UITableViewCellEditingStyle)tableView:(UITableView *)tv editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- if(tv==self.table_order)
- {
- if(indexPath.row==self.content_data.count)
- return UITableViewCellEditingStyleNone;
-
- bool offline_edit =[[self.content_data[indexPath.row] valueForKey:@"offline_edit"] boolValue];
-
- // NSString* order_status= [self.content_data[indexPath.row] valueForKey:@"order_status"];
- NSInteger statusCode = [[self.content_data[indexPath.row] valueForKey:@"orderStatus"] integerValue];
- if(/*![order_status isEqualToString:@"Saved Order"]&&! [order_status isEqualToString:@"Quote Saved"]*/statusCode != 1 && statusCode != 0)
- return UITableViewCellEditingStyleNone;
- else
- {
- BOOL condition = offline_edit;
- #ifdef OFFLINE_MODE
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- condition = condition || appDelegate.offline_mode==false;
- #else
- condition = YES;
- #endif
- if (condition)
- return UITableViewCellEditingStyleDelete;
- else
- return UITableViewCellEditingStyleNone;
- }
- }
- else
- return UITableViewCellEditingStyleDelete;
- }
- /*
- #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 EnumSelectViewControllerDelegate
- -(void) EnumValueChanged:(NSMutableDictionary *)value indexPath :(NSIndexPath*) indexPath
- {
-
-
- self.status_cadedate = value;
- UIApplication * app = [UIApplication sharedApplication];
- AppDelegate *appDelegate = (AppDelegate *)[app delegate];
- appDelegate.OrderFilter = value;
-
-
- // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
- // NSString *documents = [paths objectAtIndex:0];
- // NSString *dist_path = [documents stringByAppendingPathComponent:@"status_filter_cadedate.json"];
- //
- //
- // // if ([[NSFileManager defaultManager] fileExistsAtPath:dist_path]) {
- // //
- // // DebugLog(@"文件已经存在了");
- // //
- // // }
- // // else
- // // {
- // //
- // //
- // //
- // // DebugLog(@"resourceSampleImagesFolderPath=%@",resourceFolderPath);
- //
- //NSData *data = [NSJSONSerialization dataWithJSONObject:self.status_cadedate options:kNilOptions error:nil];
- //
- // // DebugLog(@"mainBundleFile==%@",mainBundleFile);
- //
- // [[NSFileManager defaultManager] createFileAtPath:dist_path
- //
- // contents:data
- //
- // attributes:nil];
- //
- // }
-
-
-
-
- // self.keywords=searchBar.text;
- // self.offset = 0;
- // [self.content_data removeAllObjects];
- self.reset_result=true;
- [self loadpage];
-
- //[self.btnStatusFilter setTitle:setTitle:alert ];
-
-
-
- }
- #pragma mark - button action
- - (NSIndexPath *)indexPathOfDeleteOrder:(NSString *)orderID {
- for (NSIndexPath *indexPath in self.table_order.indexPathsForSelectedRows) {
-
- NSString* orderid= [NSString stringWithFormat:@"%@",[self.content_data[indexPath.row] valueForKey:@"order_id"]];
- if ([orderid isEqualToString:orderID]) {
- return indexPath;
- }
- }
- return nil;
- }
- //
- //- (IBAction)mergeListButtonClick:(UIBarButtonItem *)sender {
- //
- // if (!self.table_order.isEditing) {
- //
- // [RAUtils message_alert:@"You have to click select firstly then select some saved order" title:@"Warning" controller:self];
- // return;
- // }
- //
- // [self handleSelectedOrders];
- //
- // if (!self.mergeList.count) {
- //
- // // [RAUtils message_alert:@"Combine List is Empty" title:@"Warning" controller:self];
- // return;
- // }
- //
- // SelectUploadOrderViewController *mergeVC = [[UIStoryboard storyboardWithName:@"OLM" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"SelectUploadOrderViewController"];
- //
- // UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:mergeVC];
- //
- // mergeVC.mergeList = self.mergeList;
- //
- // mergeVC.title = @"Combine List";
- //
- // __weak typeof(self) weakself = self;
- //
- // mergeVC.mergeBlock = ^(NSDictionary *ret) {
- //
- //
- // if (weakself) {
- //
- // __strong typeof(weakself) strongself = weakself;
- //
- // if([[ret objectForKey:@"result"]integerValue] == RESULT_TRUE) {
- //
- // [weakself.mergeList removeAllObjects];
- // [strongself.table_order endEditing:YES];
- // [strongself ReloadData];
- //
- // if ([RASingleton sharedInstance].customer_can_see_sales_Order) {
- //
- // [strongself openOrder:ret];
- //
- // }
- //
- // } else {
- //
- // NSString *msg = [ret objectForKey:@"err_msg"];
- // [RAUtils message_alert:msg title:nil controller:strongself];
- // }
- // }
- //
- // };
- //
- // mergeVC.deleteBlock = ^(NSString *orderID){
- // NSIndexPath *indexPath = [weakself indexPathOfDeleteOrder:orderID];
- // [weakself.table_order deselectRowAtIndexPath:indexPath animated:YES];
- // };
- //
- // mergeVC.clearBlock = ^{
- // for (NSDictionary *order in self.mergeList) {
- //
- // NSString *order_id = [NSString stringWithFormat:@"%@",[order objectForKey:@"order_id"]];
- // NSIndexPath *indexPath = [weakself indexPathOfDeleteOrder:order_id];
- // [weakself.table_order deselectRowAtIndexPath:indexPath animated:YES];
- // }
- // };
- //
- // nav.modalPresentationStyle = UIModalPresentationFormSheet;
- //
- // [self presentViewController:nav animated:YES completion:nil];
- //
- //}
- - (void)handleSelectedOrders {
-
- [self.mergeList removeAllObjects];
- if (!self.table_order.isEditing) {
- return;
- }
- for (NSIndexPath *indexPath in self.table_order.indexPathsForSelectedRows) {
-
- if(indexPath.row==self.content_data.count)
- continue;
-
- NSString* so= [self.content_data[indexPath.row] valueForKey:@"so#"];
- NSString* orderid= [self.content_data[indexPath.row] valueForKey:@"order_id"];
- NSString *create_by = [self.content_data[indexPath.row] valueForKey:@"create_by"];
- NSString *create_time = [self.content_data[indexPath.row] valueForKey:@"purchase_time"];
- NSString *orderCode = [NSString stringWithFormat:@"%@",[self.content_data[indexPath.row] valueForKey:@"order_code"]];
-
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
-
- [dic setValue:orderid forKey:@"order_id"];
- [dic setValue:orderCode forKey:@"order_code"];
- [dic setValue:so forKey:@"so_id"];
- [dic setValue:create_by forKey:@"create_by"];
- [dic setValue:create_time forKey:@"create_time"];
- [dic setValue:[NSNumber numberWithInteger:0] forKey:@"check"]; // 合并到
-
- [self.mergeList addObject:dic];
-
- }
-
- }
- - (IBAction)editOrderListButtonClick:(UIBarButtonItem *)sender {
-
- // if ([RASingleton sharedInstance].global_lock) { // Order list 被锁
- // [RAUtils message_alert:@"Permission Needed.\nGoto Menu -> Unlock" title:@"Warning" controller:self];
- // return;
- // }
- //
- // UIImage *gray = [UIImage imageNamed:@"Combinegray"];
- // UIImage *green = [[UIImage imageNamed:@"converttopo"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];//converttopo
- //
- // if (self.table_order.isEditing) {
- // [self mergeListButtonClick:nil];
- // // 结束选择时恢复
- // if ([RASingleton sharedInstance].customer_can_see_sales_Order && ![RASingleton sharedInstance].global_lock) { // 有查看Sales order 权限,并且app没有锁
- // if (self.orderTypeSegmentControl.numberOfSegments == 1) {
- // [self.orderTypeSegmentControl insertSegmentWithTitle:[NSString stringWithFormat:@"Purchase Order to %@",COMPANY_SHORT_NAME] atIndex:1 animated:YES];
- // }
- // }
- //
- // self.status_cadedate = self.shop_order_filter;
- // [self ReloadData];
- //
- // [self.table_order setEditing:NO animated:YES];
- //// sender.title = @"Select";
- //// [self.mergeList removeAllObjects];
- // [sender setImage:gray];
- //
- // } else {
- // // 选择时不能选择Sales Order
- // if(self.orderTypeSegmentControl.numberOfSegments > 1) {
- // [self.orderTypeSegmentControl removeSegmentAtIndex:1 animated:YES];
- // [self changeOrderType:0];
- // }
- // // 切换filter
- // NSData *data=[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"status_filter_cadedate_open" ofType:@"json" ]];
- // NSError *error=nil;
- // self.status_cadedate = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error] mutableCopy];
- // // 刷新,取Saved Order
- // [self ReloadData];
- //
- // [self.table_order setEditing:YES animated:YES];
- //// sender.title = @"Exit";
- // [sender setImage:green];
- // }
-
- }
- - (IBAction)onSegmentChanged:(UISegmentedControl *)sender {
-
- if(sender.selectedSegmentIndex==0)
- {
- self.table_order.hidden=false;
- self.table_upload.hidden = true;
- [self.table_order reloadData];
- }
- else if(sender.selectedSegmentIndex==1)
- {
- // self.table_order.hidden=true;
- // self.table_upload.hidden = false;
- // [self.table_upload reloadData];
-
-
- self.table_order.hidden=true;
- self.table_submit.hidden = false;
- [self.table_submit reloadData];
-
- }
- // else
- // {
- // [self onNewOrderClicked:nil];
- // }
- //
- }
- //
- //- (void)openOrder:(NSDictionary *)order {
- //
- // if (!order) {
- // return;
- // }
- //
- // NSString *orderCode = [order objectForKey:@"orderCode"];
- // NSInteger orderStatus = [[order objectForKey:@"orderStatus"] integerValue];
- // NSString *so = [order objectForKey:@"so#"];
- //
- // __weak typeof(self) weakself = self;
- //
- // [RANetwork request_open_order:orderCode completionHandler:^(NSMutableDictionary *result) {
- // NSDictionary* order_json = result ;
- //
- //
- // if([[order_json valueForKey:@"result"] intValue]==2)
- // {
- // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // appDelegate.order_code = orderCode;
- // appDelegate.order_status = (int)orderStatus;
- // [appDelegate SetSo:so];
- //
- // __weak MainViewController *mainVC = (MainViewController*)appDelegate.main_vc;
- //
- //#ifdef RA_NOTIFICATION
- // [ActiveViewController Notify:@"CartViewController,OrderListViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- //#else
- //
- //
- // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- // [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
- //#endif
- //
- // [((MainViewController*)appDelegate.main_vc) switchToCart];
- //
- // mainVC.cartViewController.onFinishLoad=^{
- // [mainVC.cartViewController placeOrder];
- // mainVC.cartViewController.onFinishLoad=nil;
- // };
- //
- // }
- // else
- // {
- // [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:weakself] ;
- // }
- //
- //
- //
- //
- // }];
- // // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- // //
- // // NSDictionary* order_json = [RANetwork open_Order:orderCode];
- // //
- // // dispatch_async(dispatch_get_main_queue(), ^{
- // //
- // // if([[order_json valueForKey:@"result"] intValue]==2)
- // // {
- // // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // // appDelegate.order_code = orderCode;
- // // appDelegate.order_status = orderStatus;
- // // [appDelegate SetSo:so];
- // //
- // // __weak MainViewController *mainVC = (MainViewController*)appDelegate.main_vc;
- // //
- // //#ifdef RA_NOTIFICATION
- // // [ActiveViewController Notify:@"CartViewController,OrderListViewController,ContactListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
- // //#else
- // //
- // //
- // // [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
- // // [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
- // // [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
- // //#endif
- // //
- // // [((MainViewController*)appDelegate.main_vc) switchToCart];
- // //
- // // mainVC.cartViewController.onFinishLoad=^{
- // // [mainVC.cartViewController placeOrder];
- // // mainVC.cartViewController.onFinishLoad=nil;
- // // };
- // //
- // // }
- // // else
- // // {
- // // [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Open Order" controller:weakself] ;
- // // }
- // //
- // //
- // //
- // // });
- // // });
- //
- //
- //}
- #pragma mark - notification action
- - (void)changePriceType:(id)notification {
- [self ReloadData];
- }
- - (void)lockOrderListNotification:(NSNotification *)notification {
- if ([notification.name isEqual:Lock_Permission_Notification]) {
- if (self.orderType == 1) {
- self.orderTypeSegmentControl.selectedSegmentIndex = 0;
- // [self changeOrderType:0];
- [self.orderTypeSegmentControl sendActionsForControlEvents:UIControlEventValueChanged];
- }
-
- if(self.orderTypeSegmentControl.numberOfSegments > 1) {
- [self.orderTypeSegmentControl removeSegmentAtIndex:1 animated:YES];
- // [self changeOrderType:0];
- }
- } else { // 解锁
- if ([RASingleton sharedInstance].customer_can_see_sales_Order) { // 有查看Sales order 权限
- if (self.orderTypeSegmentControl.numberOfSegments == 1 && !self.table_order.isEditing) {
- [self.orderTypeSegmentControl insertSegmentWithTitle:[NSString stringWithFormat:@"Purchase Order to %@",COMPANY_SHORT_NAME] atIndex:1 animated:YES];
- }
- }
-
- }
- }
- - (void)handleUserLogin:(NSNotification *)notification {
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- self.orderType = 0;
- if (self.table_order.isEditing) {
- [self.table_order setEditing:NO animated:YES];
- self.editOrderListButton.image = [UIImage imageNamed:@"Combinegray"];
- }
- if (appDelegate.user_type == USER_ROLE_CUSTOMER && appDelegate.customer_type == CustomerTypeStore) {
- self.orderTypeSegmentControl.selectedSegmentIndex = 0;
- [RASingleton sharedInstance].customer_order_type = 0;
-
- }
- }
- - (void)reRefreshView {
- [self.table_order reloadData];
- }
- #pragma mark - RA_NOTIFICAITON
- -(void) refresh_ui
- {
- [self.table_order reloadData];
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- if(appDelegate.can_create_order)
- {
-
-
- [self.btn_newOrder setImage:[UIImage imageNamed:@"neworder"]];
- self.btn_newOrder.enabled = true;
- }
- else
- {
- [self.btn_newOrder setImage:nil];
- self.btn_newOrder.enabled = false;
- }
- }
- -(void) reload_data
- {
- self.reset_result=true;
- self.norefresh=true;
- [self loadpage];
-
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-
- if(appDelegate.can_create_order)
- {
-
-
- [self.btn_newOrder setImage:[UIImage imageNamed:@"neworder"]];
- self.btn_newOrder.enabled = true;
- }
- else
- {
- [self.btn_newOrder setImage:nil];
- self.btn_newOrder.enabled = false;
- }
- }
- -(void) refresh_price
- {
- [self refresh_ui];
- }
- @end
|