OrderListViewController.m 47 KB

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