OrderListViewController.m 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296
  1. //
  2. // OrderListViewController.m
  3. // RedAnt ERP Mobile
  4. //
  5. // Created by Ray on 8/18/15.
  6. // Copyright (c) 2015 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "OrderListViewController.h"
  9. #import "OrderListTableViewCell.h"
  10. #import "iSalesNetwork.h"
  11. #import "OrderDetailViewController.h"
  12. #import "MainViewController.h"
  13. #import "ContactListViewController.h"
  14. #import "DefaultAppearance.h"
  15. #import "DefaultTableHeaderView.h"
  16. @interface OrderListViewController ()
  17. @end
  18. @implementation OrderListViewController
  19. -(void) logout
  20. {
  21. self.offset = 0;
  22. [self.content_data removeAllObjects];
  23. [self.table_order reloadData];
  24. self.status_cadedate = nil;
  25. }
  26. -(void) reload_container_getdata:(bool) update_data
  27. {
  28. [super reload_container_getdata:update_data];
  29. if(update_data)
  30. {
  31. // self.offset = 0;
  32. // [self.content_data removeAllObjects];
  33. self.reset_result=true;
  34. self.norefresh=true;
  35. [self loadpage];
  36. }
  37. else
  38. {
  39. [self.table_order reloadData];
  40. }
  41. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  42. if(appDelegate.can_create_order)
  43. {
  44. [self.btn_newOrder setImage:[UIImage imageNamed:@"neworder"]];
  45. self.btn_newOrder.enabled = true;
  46. }
  47. else
  48. {
  49. [self.btn_newOrder setImage:nil];
  50. self.btn_newOrder.enabled = false;
  51. }
  52. }
  53. -(void) showHidePrice
  54. {
  55. [self reload_container_getdata:false];
  56. }
  57. - (void)viewDidLoad {
  58. [super viewDidLoad];
  59. self.edgesForExtendedLayout = UIRectEdgeNone;
  60. self.loading_queue = dispatch_queue_create("orderlist_loading", NULL);
  61. self.label_net_err.layer.borderColor = [UIColor darkGrayColor].CGColor;
  62. self.label_net_err.layer.borderWidth = 2.0;
  63. self.label_net_err.layer.cornerRadius=15;
  64. self.label_net_err.layer.masksToBounds=true;
  65. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(refresh_btn_click:)];
  66. // tap.minimumPressDuration = 0.8; //定义按的时间
  67. [self.label_net_err addGestureRecognizer:tap];
  68. // Do any additional setup after loading the view.
  69. self.offset = 0;
  70. self.limit = 25;
  71. self.content_data = [[NSMutableArray alloc]init];
  72. UIRefreshControl *ref = [[UIRefreshControl alloc]init];
  73. ref.tag = 201 ;
  74. ref.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
  75. ref.tintColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
  76. // ref.hidden = true;
  77. [ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged];
  78. [self.table_order addSubview:ref];
  79. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
  80. NSString *documents = [paths objectAtIndex:0];
  81. NSString *dist_path = [documents stringByAppendingPathComponent:@"status_filter_cadedate.json"];
  82. // if ([[NSFileManager defaultManager] fileExistsAtPath:dist_path]) {
  83. //
  84. // NSLog(@"文件已经存在了");
  85. //
  86. // }
  87. // else
  88. // {
  89. //
  90. //
  91. //
  92. // // NSLog(@"resourceSampleImagesFolderPath=%@",resourceFolderPath);
  93. //
  94. // NSData *mainBundleFile = [NSData dataWithContentsOfFile:order_filter_source_path];
  95. //
  96. // // NSLog(@"mainBundleFile==%@",mainBundleFile);
  97. //
  98. // [[NSFileManager defaultManager] createFileAtPath:dist_path
  99. //
  100. // contents:mainBundleFile
  101. //
  102. // attributes:nil];
  103. //
  104. // }
  105. [self loadfilter];
  106. }
  107. -(void) loadfilter
  108. {
  109. if(self.status_cadedate!=nil)
  110. return;
  111. UIApplication * app = [UIApplication sharedApplication];
  112. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  113. NSData* json =nil;
  114. if(self.init_style==OL_OPEN)
  115. {
  116. json=[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"status_filter_cadedate_open" ofType:@"json" ]];
  117. NSError *error=nil;
  118. self.status_cadedate = [[NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error] mutableCopy];
  119. }
  120. else
  121. {
  122. // json=//[NSData dataWithContentsOfFile:dist_path];
  123. // NSError *error=nil;
  124. self.status_cadedate = appDelegate.OrderFilter;//[[NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error] mutableCopy];
  125. }
  126. }
  127. - (IBAction)onCancel:(id)sender {
  128. if(self.onCancel)
  129. self.onCancel();
  130. [self.navigationController popViewControllerAnimated:false];
  131. }
  132. - (IBAction)onStatusFilterClick:(id)sender {
  133. EnumSelectViewController* enumvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"EnumSelectorViewController"];
  134. enumvc.delegate = self;
  135. enumvc.max_select = 0;
  136. //enumvc.updatePosition = indexPath;
  137. // if([[required lowercaseString] isEqualToString:@"true"])
  138. // enumvc.canbeEmpty = false;
  139. // else
  140. // enumvc.canbeEmpty =true;
  141. enumvc.cadedate = self.status_cadedate ;
  142. enumvc.title = @"Order Status Selection";
  143. // enumvc.value = [value_json mutableCopy];
  144. enumvc.single_select =false;
  145. [self.navigationController pushViewController:enumvc animated:true];
  146. }
  147. - (void)viewWillAppear:(BOOL)animated
  148. {
  149. [super viewWillAppear:animated];
  150. [self loadfilter];
  151. // UIApplication * app = [UIApplication sharedApplication];
  152. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  153. // if(appDelegate.bLogin==false)
  154. // {
  155. // LoginViewController * loginvc =[ self.storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
  156. //// loginvc.delegate = self;
  157. // // loginvc.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  158. //
  159. // loginvc.returnValue = ^(bool blogin){
  160. //
  161. //
  162. // UIApplication * app = [UIApplication sharedApplication];
  163. // AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  164. // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  165. //
  166. // [main_vc checklogin:true];
  167. //
  168. //// self.offset = 0;
  169. //// [self.content_data removeAllObjects];
  170. //// [self loadpage];
  171. //
  172. // [[self navigationController] setNavigationBarHidden:!self.showNavibar animated:NO];
  173. //
  174. // };
  175. //
  176. // UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:loginvc] ;
  177. //
  178. //
  179. //
  180. //
  181. //
  182. // // [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
  183. //
  184. // navi.modalPresentationStyle = UIModalTransitionStyleCrossDissolve;//有三种状态,自己看看是哪种
  185. // [self presentViewController:navi animated:YES completion:^{
  186. //
  187. // // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  188. //
  189. // NSLog(@"LoginViewController present.........");
  190. //
  191. // // self.btop = false;
  192. // // <#code#>
  193. // }];
  194. // }
  195. // else
  196. // {
  197. //
  198. // if(!self.norefresh)//避免 多次刷新
  199. // {
  200. // self.norefresh = true;
  201. // self.offset = 0;
  202. // [self.content_data removeAllObjects];
  203. // [self loadpage];
  204. //
  205. // }
  206. //
  207. // }
  208. [[self navigationController] setNavigationBarHidden:!self.showNavibar animated:NO];
  209. }
  210. - (IBAction)onNewOrderClicked:(id)sender {
  211. NSString* msg=@"Do you want to create a new order?";
  212. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  213. if(appDelegate.order_code.length==0)
  214. {
  215. if(appDelegate.contact_id.length>0)
  216. {
  217. msg = [msg stringByAppendingString:@"\n\nCustomer:"];
  218. msg = [msg stringByAppendingString:appDelegate.customerInfo[@"customer_name"]];
  219. }
  220. }
  221. UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Attention", nil) message:msg delegate:self cancelButtonTitle:NSLocalizedString(@"NO", nil) otherButtonTitles:NSLocalizedString(@"YES", nil), nil];
  222. [alert show];
  223. }
  224. - (void)didReceiveMemoryWarning {
  225. [super didReceiveMemoryWarning];
  226. // Dispose of any resources that can be recreated.
  227. }
  228. -(void)manually_refresh
  229. {
  230. UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:201];
  231. if(self.isrefreshing)
  232. {
  233. [reF endRefreshing];
  234. return;
  235. }
  236. reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Refreshing"];
  237. if ([self respondsToSelector:@selector(ReloadData)])
  238. [self performSelector:@selector(ReloadData) withObject:nil afterDelay:1];
  239. }
  240. -(void)ReloadData
  241. {
  242. // [self.content_data removeAllObjects];
  243. // [self.table_order reloadData];
  244. // self.table_order.hidden = true;
  245. UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:201];
  246. [reF endRefreshing];
  247. reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
  248. self.keywords=self.searchbar.text;
  249. // self.offset = 0;
  250. self.reset_result=true;
  251. // [self.content_data removeAllObjects];
  252. // [self.table_order reloadData];
  253. [self loadpage];
  254. // [self loadpage];
  255. }
  256. -(void) loadpage
  257. {
  258. dispatch_async(self.loading_queue, ^{
  259. dispatch_sync(dispatch_get_main_queue(), ^{
  260. if(self.reset_result)
  261. {
  262. self.offset = 0;
  263. [self.content_data removeAllObjects];
  264. [self.table_order reloadData];
  265. }
  266. // NSMutableArray* arr_status = [[NSMutableArray alloc] init];
  267. NSMutableArray* arr_statusname = [[NSMutableArray alloc] init];
  268. int count = [[self.status_cadedate valueForKey:@"count"] intValue];
  269. for(int i=0;i<count;i++)
  270. {
  271. NSDictionary* val_json =[self.status_cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]];
  272. int check = [[val_json valueForKey:@"check"] intValue];
  273. if(check==1)
  274. {
  275. // [arr_status addObject:[NSString stringWithFormat:@"%@",[val_json valueForKey:@"value_id"]]];
  276. [arr_statusname addObject:[NSString stringWithFormat:@"%@",[val_json valueForKey:@"value"]]];
  277. // break;
  278. }
  279. }
  280. // NSString * str_status = [arr_status componentsJoinedByString:@","];
  281. NSString * str_statusname = [arr_statusname componentsJoinedByString:@","];
  282. if(str_statusname.length==0)
  283. str_statusname = @"All";
  284. self.label_filter.text = str_statusname;
  285. if(self.offset==0)
  286. {
  287. self.table_order.hidden = true;
  288. self.mum.center = self.view.center;
  289. self.mum.hidden = false;
  290. [self.mum startAnimating];
  291. }
  292. self.label_net_err.hidden=true;
  293. });
  294. });
  295. dispatch_async(self.loading_queue, ^{
  296. if(self.isrefreshing)
  297. return;
  298. self.isrefreshing=true;
  299. NSMutableArray* arr_status = [[NSMutableArray alloc] init];
  300. // NSMutableArray* arr_statusname = [[NSMutableArray alloc] init];
  301. int count = [[self.status_cadedate valueForKey:@"count"] intValue];
  302. for(int i=0;i<count;i++)
  303. {
  304. NSDictionary* val_json =[self.status_cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]];
  305. int check = [[val_json valueForKey:@"check"] intValue];
  306. if(check==1)
  307. {
  308. [arr_status addObject:[NSString stringWithFormat:@"%@",[val_json valueForKey:@"value_id"]]];
  309. // [arr_statusname addObject:[NSString stringWithFormat:@"%@",[val_json valueForKey:@"value"]]];
  310. // break;
  311. }
  312. }
  313. NSString * str_status = [arr_status componentsJoinedByString:@","];
  314. NSMutableDictionary* content=nil;
  315. content=[[iSalesNetwork request_OrderList:self.offset limit : self.limit keywords:self.keywords status:str_status customer:self.customer_id] mutableCopy];
  316. dispatch_sync(dispatch_get_main_queue(), ^{
  317. [self.mum stopAnimating];
  318. int result=[[content valueForKey:@"result"] intValue];
  319. if(result==2||result==0)
  320. {
  321. int count = [[content valueForKey:@"count" ] intValue] ;
  322. self.time_zone = [content valueForKey:@"time_zone" ];
  323. self.offset += count;
  324. for(int i=0;i<count;i++)
  325. {
  326. NSDictionary* objmsg = [content objectForKey:[NSString stringWithFormat:@"item_%d",i]];
  327. [self.content_data addObject:[NSMutableDictionary dictionaryWithDictionary:objmsg]];
  328. }
  329. if(count<self.limit)
  330. {
  331. // int i =self.btnrefresh.state;
  332. self.load_more_hint=@"All loaded";
  333. // self.btnrefresh.titleLabel.text =NSLocalizedString(@"no_more", nil);
  334. // [self.btnrefresh setTitle:@"No more" forState:UIControlStateNormal];
  335. }
  336. else
  337. {
  338. self.load_more_hint=@"Load more...";
  339. // self.btnrefresh.enabled = true;
  340. // self.btnrefresh.titleLabel.text =NSLocalizedString(@"load_more",nil);
  341. // [self.btnrefresh setTitle:@"Load more" forState:UIControlStateNormal];
  342. }
  343. self.table_order.hidden = false;
  344. self.reset_result=false;
  345. [self.table_order reloadData ];
  346. }
  347. else if(result==RESULT_NET_ERROR &&self.offset==0)
  348. {
  349. self.label_net_err.hidden=false;
  350. self.table_order.hidden = true;
  351. }
  352. else
  353. {
  354. [RAUtils message_alert:[content valueForKey:@"err_msg"] title:@"Loading Order List" controller:self] ;
  355. }
  356. self.isrefreshing=false;
  357. // NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  358. // bool autologin =[defaults boolForKey:@"autologin"];
  359. // if(!autologin)
  360. // {
  361. // TabBarController * viewController =[self.storyboard instantiateViewControllerWithIdentifier:@"LoginTabBar"];
  362. // [self presentViewController:viewController animated:YES completion:^{
  363. //
  364. // }];
  365. // }
  366. });
  367. });
  368. }
  369. - (void)loadmore
  370. {
  371. // self.btnrefresh.enabled = NO;
  372. // self.btnrefresh.titleLabel.text =NSLocalizedString(@"loading",nil);
  373. // [self.btnrefresh setTitle:@"Loading..." forState:UIControlStateNormal];
  374. [self loadpage];
  375. }
  376. //-(void)changeCell
  377. //{
  378. //// UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
  379. //// reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"refreshing"];
  380. // [self performSelector:@selector(loadmore) withObject:nil afterDelay:1];
  381. // DebugLog(@"refresh!!!!!!!!");
  382. //
  383. //}
  384. -(void) neworder
  385. {
  386. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Create Order"];
  387. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  388. NSDictionary* return_json = [iSalesNetwork new_Order];
  389. dispatch_async(dispatch_get_main_queue(), ^{
  390. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  391. if([[return_json valueForKey:@"result"] intValue]==2)
  392. {
  393. int result=[[return_json valueForKey:@"result"] intValue];
  394. if(result==2)
  395. {
  396. //successed.
  397. NSString* order_code = [return_json valueForKey:@"orderCode"];
  398. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  399. appDelegate.order_code = order_code;
  400. appDelegate.order_status = [[return_json valueForKey:@"orderStatus"] intValue];
  401. MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  402. [main_vc reloadCart:true immediately:false];
  403. [self ReloadData];
  404. // [self performSelector:@selector(loadpage) withObject:nil afterDelay:1];
  405. // [self loadpage];
  406. // if(self.shopCartBlock!=nil)
  407. // {
  408. // UIImage* img=[self photoStackView:self.photoStack photoForIndex:0];
  409. //
  410. //
  411. // CGRect iv_rect = CGRectMake(self.btnaddCart.center.x-50, self.btnaddCart.center.y-50, 100, 100);
  412. // UIImageView* iv = [[UIImageView alloc] initWithFrame:iv_rect];
  413. // iv.image = img;
  414. // // [self.contentView addSubview:iv];
  415. // self.shopCartBlock(iv);
  416. //
  417. // }
  418. }
  419. }
  420. else
  421. {
  422. [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Create Order" controller:self] ;
  423. }
  424. });
  425. });
  426. }
  427. #pragma mark - UIAlertViewDelegate
  428. // Called when a button is clicked. The view will be automatically dismissed after this call returns
  429. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  430. {
  431. if(buttonIndex!=alertView.cancelButtonIndex)
  432. {
  433. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  434. if(appDelegate.order_code.length>0)
  435. {
  436. appDelegate.order_code= nil;
  437. [appDelegate SetSo:nil];
  438. // MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  439. ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  440. cvc.showNavibar = true;
  441. cvc.contact_type = @"Sales_Order_Customer";
  442. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  443. appDelegate.contact_id=[value valueForKey:@"customer_cid"];
  444. appDelegate.customerInfo = value;
  445. self.norefresh = true;
  446. [self neworder];
  447. // [main_vc checklogin:true];
  448. // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  449. //
  450. // if(self.returnValue)
  451. // self.returnValue(value);
  452. };
  453. cvc.onCancel = ^(){
  454. self.norefresh = true;
  455. if(appDelegate.customerInfo==nil)
  456. {
  457. [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
  458. }
  459. else
  460. {
  461. [self neworder];
  462. }
  463. // [main_vc checklogin:true];
  464. };
  465. cvc.onReset = ^(){
  466. // [main_vc checklogin:true];
  467. };
  468. [self.navigationController pushViewController:cvc animated:true];
  469. }
  470. else
  471. {
  472. //create new;
  473. if(appDelegate.customerInfo==nil)// select contact if current contact not exist
  474. {
  475. MainViewController* main_vc=(MainViewController*)appDelegate.main_vc;
  476. ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
  477. cvc.showNavibar = true;
  478. cvc.contact_type = @"Sales_Order_Customer";
  479. cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
  480. appDelegate.contact_id=[value valueForKey:@"customer_cid"];
  481. appDelegate.customerInfo = value;
  482. if(appDelegate.order_code==nil)
  483. [self neworder];
  484. // [main_vc checklogin:true];
  485. // [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
  486. //
  487. // if(self.returnValue)
  488. // self.returnValue(value);
  489. };
  490. cvc.onCancel = ^(){
  491. [RAUtils message_alert:@"Cannot create order without cursomer infomation." title:@"" controller:self];
  492. };
  493. cvc.onReset = ^(){
  494. [main_vc checklogin:true];
  495. };
  496. [self.navigationController pushViewController:cvc animated:true];
  497. }
  498. else
  499. {
  500. [self neworder];
  501. }
  502. }
  503. }
  504. }
  505. #pragma mark - Table view data source
  506. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
  507. {
  508. return 66;
  509. }
  510. //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  511. //{
  512. // return 0;
  513. //}
  514. //- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  515. //{
  516. // return 0;
  517. //}
  518. //- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  519. //{
  520. // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  521. // return myView;
  522. //
  523. //}
  524. - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  525. {
  526. NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  527. if(value==nil)
  528. value=@"";
  529. unsigned long color = strtoul([value UTF8String],0,16);
  530. DefaultTableHeaderView* myView = [[DefaultTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  531. // myView.backgroundColor = UIColorFromRGB(0x996633);
  532. myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath;
  533. myView.layer.shadowColor = [UIColor blackColor].CGColor;
  534. myView.layer.shadowOffset = CGSizeMake(0, 0);
  535. myView.layer.shadowOpacity = 0.5;
  536. myView.layer.shadowRadius = 2.0;
  537. UILabel *statuslabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 2, 130, 22)];
  538. statuslabel.textColor=UIColorFromRGB(color);
  539. statuslabel.backgroundColor = [UIColor clearColor];
  540. statuslabel.text=NSLocalizedString(@"Status", nil);
  541. [statuslabel sizeToFit];
  542. [myView addSubview:statuslabel];
  543. UILabel *solabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 21, 130, 22)];
  544. solabel.textColor=UIColorFromRGB(color);
  545. solabel.backgroundColor = [UIColor clearColor];
  546. solabel.text=NSLocalizedString(@"SO#", nil);
  547. [solabel sizeToFit];
  548. [myView addSubview:solabel];
  549. UILabel *userlabel = [[UILabel alloc] initWithFrame:CGRectMake(155, 2, 135, 22)];
  550. userlabel.textColor=UIColorFromRGB(color);
  551. userlabel.backgroundColor = [UIColor clearColor];
  552. userlabel.text=NSLocalizedString(@"Sales rep", nil);
  553. [userlabel sizeToFit];
  554. [myView addSubview:userlabel];
  555. UILabel *creatorlabel = [[UILabel alloc] initWithFrame:CGRectMake(155, 21, 135, 22)];
  556. creatorlabel.textColor=UIColorFromRGB(color);
  557. creatorlabel.backgroundColor = [UIColor clearColor];
  558. creatorlabel.text=NSLocalizedString(@"Create by", nil);
  559. [creatorlabel sizeToFit];
  560. [myView addSubview:creatorlabel];
  561. UILabel *contactlabel = [[UILabel alloc] initWithFrame:CGRectMake(300, 11, 150, 22)];
  562. contactlabel.textColor=UIColorFromRGB(color);
  563. contactlabel.backgroundColor = [UIColor clearColor];
  564. contactlabel.text=NSLocalizedString(@"Contact", nil);
  565. [contactlabel sizeToFit];
  566. [myView addSubview:contactlabel];
  567. //
  568. // UILabel *modellabel = [[UILabel alloc] initWithFrame:CGRectMake(424, 11, 52, 22)];
  569. // modellabel.textColor=[UIColor whiteColor];
  570. // modellabel.backgroundColor = [UIColor clearColor];
  571. // modellabel.text=NSLocalizedString(@"Model", nil);
  572. // [modellabel sizeToFit];
  573. // [myView addSubview:modellabel];
  574. // UILabel *modellabel = [[UILabel alloc] initWithFrame:CGRectMake(self.table_order.frame.size.width-276, 2, 100, 22)];
  575. // modellabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
  576. // modellabel.textColor=[UIColor whiteColor];
  577. // modellabel.backgroundColor = [UIColor clearColor];
  578. // modellabel.text=NSLocalizedString(@"Items/QTY", nil);
  579. // [modellabel sizeToFit];
  580. // [myView addSubview:modellabel];
  581. UILabel *pricelabel = [[UILabel alloc] initWithFrame:CGRectMake(/*492*/self.table_order.frame.size.width-276, 11, 100, 22)];
  582. pricelabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
  583. pricelabel.textColor=[UIColor whiteColor];
  584. pricelabel.backgroundColor = [UIColor clearColor];
  585. pricelabel.text=NSLocalizedString(@"Order Total", nil);
  586. [pricelabel sizeToFit];
  587. [myView addSubview:pricelabel];
  588. UILabel *timelabel = [[UILabel alloc] initWithFrame:CGRectMake(self.table_order.frame.size.width-163/*605*/,11, 148, 22)];
  589. timelabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
  590. timelabel.textColor=[UIColor whiteColor];
  591. timelabel.backgroundColor = [UIColor clearColor];
  592. if(self.time_zone==nil)
  593. timelabel.text=@"Create time";
  594. else
  595. timelabel.text=[NSString stringWithFormat:@"Create time (%@)",self.time_zone];
  596. [timelabel sizeToFit];
  597. [myView addSubview:timelabel];
  598. myView.autoresizesSubviews=true;
  599. // [myView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
  600. // modellabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  601. // pricelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  602. // timelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  603. myView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  604. //
  605. return myView;
  606. }
  607. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  608. {
  609. return 44;
  610. }
  611. //
  612. //- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  613. // if(section==0)
  614. // return nil;
  615. // else
  616. // return @"detail section";
  617. //}
  618. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  619. {
  620. return 1;
  621. }
  622. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  623. {
  624. // NSDictionary * item_json = [self.content_data objectForKey:@"items"];
  625. if( self.content_data.count==0)
  626. return 0;
  627. return self.content_data.count+1;
  628. }
  629. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  630. {
  631. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  632. // if(tableView==self.itemListTable)
  633. // {
  634. // if(indexPath.row>self.content_data.count)
  635. // {
  636. // int debug=true;
  637. // }
  638. // NSLog(@"row %ld",(long)indexPath.row);
  639. if(indexPath.row==self.content_data.count)
  640. {
  641. UITableViewCell *moreCell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"mores"];
  642. UILabel *moreDataLabel=[[UILabel alloc] init];
  643. moreDataLabel.tag=200;
  644. moreDataLabel.text=self.load_more_hint;
  645. [moreDataLabel setFont:[UIFont systemFontOfSize:14.0f]];
  646. [moreDataLabel setTextAlignment:NSTextAlignmentCenter];
  647. moreDataLabel.frame=CGRectMake(0, 10, self.table_order.bounds.size.width, 20);
  648. [moreDataLabel setBackgroundColor:[UIColor clearColor]];
  649. // [moreDataLabel addTarget:self action:@selector(changeCell) forControlEvents:UIControlEventValueChanged];
  650. [moreCell.contentView addSubview:moreDataLabel];
  651. if([self.load_more_hint isEqualToString:@"Load more..."])
  652. [self performSelector:@selector(loadmore) withObject:nil afterDelay:1];
  653. // NSLog(@"更多...");
  654. moreCell.backgroundColor = [UIColor whiteColor];
  655. return moreCell;
  656. }
  657. else
  658. {
  659. NSString *CellIdentifier = @"OrderListTableViewCell";
  660. OrderListTableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  661. NSString* po= [self.content_data[indexPath.row] valueForKey:@"so#"];
  662. NSString* price= [self.content_data[indexPath.row] valueForKey:@"price"];
  663. if(appDelegate.can_see_price&&appDelegate.price_hidden==false)
  664. {
  665. }
  666. else
  667. {
  668. price=nil;
  669. }
  670. NSString* purchase_time= [self.content_data[indexPath.row] valueForKey:@"purchase_time"];
  671. NSString* status = [self.content_data[indexPath.row] valueForKey:@"order_status"] ;
  672. NSString* customer_name = [self.content_data[indexPath.row] valueForKey:@"customer_name"];
  673. NSString* model_count = [self.content_data[indexPath.row] valueForKey:@"model_count"];
  674. NSString* sales = [self.content_data[indexPath.row] valueForKey:@"sales_rep"];
  675. NSString* creator = [self.content_data[indexPath.row] valueForKey:@"create_by"];
  676. cell.label_so.text=po;
  677. cell.labelprice.text=price;
  678. cell.label_date.text=purchase_time;
  679. cell.label_contact.text=customer_name;
  680. cell.label_model.text = model_count;
  681. cell.label_sales.text = sales;
  682. cell.label_creator.text = creator;
  683. cell.label_status.text=status;
  684. cell.backgroundColor = [UIColor whiteColor];
  685. return cell;
  686. }
  687. // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  688. // NSDictionary * combine_json =[item_json objectForKey:@"combine"];
  689. // cell.bundle_item=combine_json;
  690. // NSString* img_url = [item_json valueForKey:@"img_url"];
  691. // NSString* description = [item_json valueForKey:@"description"];
  692. // // NSString* identifier = [item_json valueForKey:@"identifier"];
  693. // // NSString* attribute = [item_json valueForKey:@"attribute"];
  694. // NSString* currency = [item_json valueForKey:@"currency"];
  695. // int count =[[item_json valueForKey:@"count"] intValue];
  696. // double price =[[item_json valueForKey:@"price"] doubleValue];
  697. // // cell.labelAttribute.text = attribute;
  698. // cell.labelCurrency.text = currency;
  699. // cell.labelDescription.text = description;
  700. // // cell.labelIdentifier.text = identifier;
  701. // cell.labelPrice.text = [NSString stringWithFormat:@"%.2f",price];
  702. //
  703. //
  704. //
  705. // [cell set_Count:count];
  706. // NSString* file_name=[img_url lastPathComponent];
  707. // NSData* img_data=[iSalesDB load_cached_img:file_name];
  708. // if(img_data!=nil)
  709. // {
  710. //
  711. // UIImage * img =[UIImage imageWithData:img_data];
  712. // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
  713. // }
  714. // else
  715. // {
  716. //
  717. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  718. //
  719. // NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  720. //
  721. // dispatch_async(dispatch_get_main_queue(), ^{
  722. //
  723. //
  724. //
  725. // if(downloadimg_data!=nil)
  726. // {
  727. // [iSalesDB cache_img:downloadimg_data :file_name ];
  728. //
  729. // UIImage * img =[UIImage imageWithData:downloadimg_data];
  730. // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
  731. // }
  732. //
  733. // });
  734. // });
  735. //
  736. //
  737. // }
  738. // }
  739. // else
  740. // {
  741. // NSString *CellIdentifier = @"OrderInfoListItem";
  742. // UITableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  743. // return cell;
  744. // }
  745. }
  746. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  747. {
  748. //
  749. if(indexPath.row==self.content_data.count)
  750. return;
  751. NSString* orderid= [self.content_data[indexPath.row] valueForKey:@"order_id"];
  752. OrderDetailViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"OrderDetailViewController" ];
  753. // int i =[[self.content_data[indexPath.row] valueForKey:@"order_code"];
  754. dvc.selectOrder=^(NSMutableDictionary* order_detail){
  755. [self.navigationController popViewControllerAnimated:false];
  756. if(self.selectOrder)
  757. self.selectOrder(order_detail);
  758. };
  759. NSString* order_code =[self.content_data[indexPath.row] valueForKey:@"order_code"];
  760. dvc.order_code = order_code;
  761. dvc.order_status =[[self.content_data[indexPath.row] valueForKey:@"orderStatus"] intValue];
  762. // bool temp_order = false ;
  763. // NSString* order_status=[self.content_data[indexPath.row] valueForKey:@"order_status"];
  764. // if([order_status isEqualToString:@"Saved"]||[order_status isEqualToString:@"Quoted"])
  765. // temp_order=true;
  766. //
  767. // dvc.isTempOrder = temp_order;
  768. // dvc
  769. dvc.orderid=orderid;
  770. // dvc.category_id=nil;
  771. // dvc.ispush=true;
  772. // [dvc reload];
  773. [self.navigationController pushViewController:dvc animated:true];
  774. }
  775. #pragma mark - searchBar delegate;
  776. - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
  777. {
  778. self.keywords=searchBar.text;
  779. // self.offset = 0;
  780. // [self.content_data removeAllObjects];
  781. self.reset_result=true;
  782. [self loadpage];
  783. }
  784. - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
  785. {
  786. if([searchText isEqualToString:@""] && !self.reset)
  787. {
  788. NSLog(@"clear");
  789. self.reset=true;
  790. self.keywords=nil;
  791. // self.offset = 0;
  792. // [self.content_data removeAllObjects];
  793. self.reset_result=true;
  794. [self loadpage];
  795. }
  796. else
  797. self.reset = false;
  798. }
  799. #pragma mark 在滑动手势删除某一行的时候,显示出更多的按钮
  800. - (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
  801. {
  802. // 添加一个删除按钮
  803. // self.indexPath=indexPath;
  804. if(indexPath.row==self.content_data.count)
  805. return @[];
  806. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  807. if(appDelegate.user_type!=USER_ROLE_EMPLOYEE)
  808. return @[];
  809. NSString* so= [self.content_data[indexPath.row] valueForKey:@"so#"];
  810. NSString* orderid= [self.content_data[indexPath.row] valueForKey:@"order_id"];
  811. NSString* order_status= [self.content_data[indexPath.row] valueForKey:@"order_status"];
  812. UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
  813. NSLog(@"delete click");
  814. NSString * title =[NSString stringWithFormat:@"Are you sure to delete order SO#: %@",so];
  815. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert];
  816. //block代码块取代了delegate
  817. // [alertControl addTextFieldWithConfigurationHandler:^(UITextField *textField) {
  818. // textField.text = self.save_name;
  819. //
  820. //
  821. // }];
  822. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  823. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Delete Order"];
  824. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  825. NSDictionary* return_json = [iSalesNetwork delete_Order:orderid];
  826. dispatch_async(dispatch_get_main_queue(), ^{
  827. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  828. if([[return_json valueForKey:@"result"] intValue]==2)
  829. {
  830. if([appDelegate.order_code isEqualToString: [self.content_data[indexPath.row] valueForKey:@"order_code"]])
  831. {
  832. appDelegate.order_code= nil;
  833. [appDelegate SetSo:nil];
  834. }
  835. [RAUtils message_alert:nil title:@"Order Delete" controller:self] ;
  836. [self ReloadData];
  837. }
  838. else
  839. {
  840. [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Delete Order" controller:self] ;
  841. }
  842. });
  843. });
  844. }];
  845. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  846. NSLog(@"Cancel");
  847. }];
  848. [alertControl addAction:actionOne];
  849. [alertControl addAction:alertthree];
  850. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  851. [self presentViewController:alertControl animated:YES completion:nil];
  852. }];
  853. deleteRowAction.backgroundColor = UIColorFromRGB(0x336699);
  854. // 添加一个编辑按钮
  855. UITableViewRowAction *cancelAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Cancel Order"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
  856. NSLog(@"edit click");
  857. NSString * title =[NSString stringWithFormat:@"Are you sure to cancel order SO#: %@",so];
  858. UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert];
  859. UIAlertAction *actionOne = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  860. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Cancel Order"];
  861. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  862. NSDictionary* return_json = [iSalesNetwork cancel_Order:orderid order_code:nil];
  863. dispatch_async(dispatch_get_main_queue(), ^{
  864. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  865. if([[return_json valueForKey:@"result"] intValue]==2)
  866. {
  867. if([appDelegate.order_code isEqualToString: [self.content_data[indexPath.row] valueForKey:@"order_code"]])
  868. {
  869. appDelegate.order_code= nil;
  870. appDelegate.user_type = 0;
  871. appDelegate.customerInfo = nil;
  872. appDelegate.contact_id = nil;
  873. appDelegate.order_customer_id = nil;
  874. [appDelegate SetSo:nil];
  875. appDelegate.cart_count=0;
  876. [appDelegate update_count_mark];
  877. }
  878. [RAUtils message_alert:nil title:@"Order Canceled" controller:self] ;
  879. [self ReloadData];
  880. }
  881. else
  882. {
  883. [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Cancel Order" controller:self] ;
  884. }
  885. });
  886. });
  887. }];
  888. UIAlertAction *alertthree = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  889. NSLog(@"Cancel");
  890. }];
  891. [alertControl addAction:actionOne];
  892. [alertControl addAction:alertthree];
  893. //UIAlertControllerStyle类型为UIAlertControllerStyleAlert可以添加addTextFieldWithConfigurationHandler:^(UITextField *textField)
  894. [self presentViewController:alertControl animated:YES completion:nil];
  895. //
  896. }];
  897. cancelAction.backgroundColor = UIColorFromRGB(0xff9933);
  898. if([order_status isEqualToString:@"Saved Order"]&&appDelegate.can_cancel_order)
  899. return @[cancelAction];
  900. else
  901. {
  902. if([order_status isEqualToString:@"Quote Saved"])
  903. {
  904. NSMutableArray* arr=[@[] mutableCopy];
  905. if(appDelegate.can_delete_order)
  906. [arr addObject:deleteRowAction];
  907. if(appDelegate.can_cancel_order)
  908. [arr addObject:cancelAction];
  909. return arr;
  910. }
  911. }
  912. return @[];
  913. }
  914. - (void)tableView:(UITableView *)tableView
  915. commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  916. }
  917. - (UITableViewCellEditingStyle)tableView:(UITableView *)tv editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
  918. if(indexPath.row==self.content_data.count)
  919. return UITableViewCellEditingStyleNone;
  920. NSString* order_status= [self.content_data[indexPath.row] valueForKey:@"order_status"];
  921. if(![order_status isEqualToString:@"Saved Order"]&&! [order_status isEqualToString:@"Quote Saved"])
  922. return UITableViewCellEditingStyleNone;
  923. else
  924. return UITableViewCellEditingStyleDelete;
  925. }
  926. /*
  927. #pragma mark - Navigation
  928. // In a storyboard-based application, you will often want to do a little preparation before navigation
  929. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  930. // Get the new view controller using [segue destinationViewController].
  931. // Pass the selected object to the new view controller.
  932. }
  933. */
  934. #pragma mark EnumSelectViewControllerDelegate
  935. -(void) EnumValueChanged:(NSMutableDictionary *)value indexPath :(NSIndexPath*) indexPath
  936. {
  937. self.status_cadedate = value;
  938. UIApplication * app = [UIApplication sharedApplication];
  939. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  940. appDelegate.OrderFilter = value;
  941. // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
  942. // NSString *documents = [paths objectAtIndex:0];
  943. // NSString *dist_path = [documents stringByAppendingPathComponent:@"status_filter_cadedate.json"];
  944. //
  945. //
  946. // // if ([[NSFileManager defaultManager] fileExistsAtPath:dist_path]) {
  947. // //
  948. // // NSLog(@"文件已经存在了");
  949. // //
  950. // // }
  951. // // else
  952. // // {
  953. // //
  954. // //
  955. // //
  956. // // NSLog(@"resourceSampleImagesFolderPath=%@",resourceFolderPath);
  957. //
  958. //NSData *data = [NSJSONSerialization dataWithJSONObject:self.status_cadedate options:kNilOptions error:nil];
  959. //
  960. // // NSLog(@"mainBundleFile==%@",mainBundleFile);
  961. //
  962. // [[NSFileManager defaultManager] createFileAtPath:dist_path
  963. //
  964. // contents:data
  965. //
  966. // attributes:nil];
  967. //
  968. // }
  969. // self.keywords=searchBar.text;
  970. // self.offset = 0;
  971. // [self.content_data removeAllObjects];
  972. self.reset_result=true;
  973. [self loadpage];
  974. //[self.btnStatusFilter setTitle:setTitle:alert ];
  975. }
  976. @end