DocumentListViewController.m 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251
  1. //
  2. // DocumentListViewController.m
  3. // Granite Expo eSign
  4. //
  5. // Created by Ray on 12/28/16.
  6. // Copyright © 2016 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "DocumentListViewController.h"
  9. #import "ACNetwork.h"
  10. #import "DocListTableViewCell.h"
  11. #import "RAUtils.h"
  12. #import "GEContractFilterViewController.h"
  13. #import "PDFViewController.h"
  14. #import "AppDelegate.h"
  15. #import "ExtDocumentsViewController.h"
  16. #import "DocnotesViewController.h"
  17. #import "AddExtDocumentViewController.h"
  18. #import "DocumentPageViewController.h"
  19. @interface DocumentListViewController ()
  20. @property (nonatomic,strong) NSOperationQueue *dataOperationQueue;
  21. @end
  22. @implementation DocumentListViewController
  23. - (NSOperationQueue *)dataOperationQueue {
  24. if (!_dataOperationQueue) {
  25. _dataOperationQueue = [[NSOperationQueue alloc] init];
  26. _dataOperationQueue.maxConcurrentOperationCount = 1;
  27. }
  28. return _dataOperationQueue;
  29. }
  30. - (void)viewDidLoad {
  31. [super viewDidLoad];
  32. self.offset = 0;
  33. self.limit = 20;
  34. self.table_data = [[NSMutableArray alloc] init];
  35. self.filterparams = [[NSMutableDictionary alloc]init];
  36. self.label_net_err.layer.borderColor = [UIColor darkGrayColor].CGColor;
  37. self.label_net_err.layer.borderWidth = 2.0;
  38. self.label_net_err.layer.cornerRadius=15;
  39. self.label_net_err.layer.masksToBounds=true;
  40. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(refresh_btn_click:)];
  41. [self.label_net_err addGestureRecognizer:tap];
  42. UIRefreshControl *ref = [[UIRefreshControl alloc]init];
  43. ref.tag = 201 ;
  44. ref.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
  45. ref.tintColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
  46. // ref.hidden = true;
  47. [ref addTarget:self action:@selector(manually_refresh) forControlEvents:UIControlEventValueChanged];
  48. [self.tableView addSubview:ref];
  49. // NSMutableArray * arr = [[NSMutableArray alloc] init];
  50. // for(int i=0;i<100;i++)
  51. // {
  52. // [arr addObject:[NSNumber numberWithInt:i]];
  53. // }
  54. // NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
  55. // dict[@"arr"] = arr;
  56. // DebugLog([RAUtils dict2string:dict]);
  57. [self loadpage];
  58. // Do any additional setup after loading the view.
  59. }
  60. - (void)didReceiveMemoryWarning {
  61. [super didReceiveMemoryWarning];
  62. // Dispose of any resources that can be recreated.
  63. }
  64. - (IBAction)onAddClick:(id)sender {
  65. __weak typeof(self) weakself = self;
  66. {
  67. AddExtDocumentViewController * addVC;
  68. addVC = [ [UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"AddExtDocumentViewController"];
  69. addVC.is_present = true;
  70. addVC.doc_number = nil;
  71. addVC.uploadSuccess = ^(NSMutableArray* arr_upload){
  72. if(arr_upload.count>0)
  73. [weakself loadpage];
  74. };
  75. //addVC.arr_documents = [NSMutableArray arrayWithObjects:appDelegate.shareFile, nil];
  76. //appDelegate.shareFile=nil;
  77. // notesVC.docNotes = notes;
  78. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:addVC] ;
  79. navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  80. [self presentViewController:navi animated:YES completion:^{
  81. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  82. DebugLog(@"filter present.........");
  83. // self.btop = false;
  84. // <#code#>
  85. }];
  86. }
  87. }
  88. - (IBAction)onFilterClick:(id)sender {
  89. GEContractFilterViewController * filterVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"GEContractFilterViewController"];
  90. filterVC.filterparams = self.filterparams;
  91. filterVC.OnSearch = ^(NSMutableDictionary* params)
  92. {
  93. // [self reload_container_getdata:true];
  94. self.reset_result=true;
  95. // self.norefresh=true;
  96. [self loadpage];
  97. };
  98. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:filterVC] ;
  99. navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  100. [self presentViewController:navi animated:YES completion:^{
  101. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  102. DebugLog(@"filter present.........");
  103. // self.btop = false;
  104. // <#code#>
  105. }];
  106. }
  107. -(void) previewPDF:(NSString*)url title:(NSString*)title subject:(NSString*)subject islocal:(bool) islocalfile
  108. {
  109. NSString* name=@"";//[self.content_data[indexPath.row] valueForKey:@"tear_name"];
  110. // NSString* url= file;//[self.content_data[indexPath.row] valueForKey:@"pdf_path"];
  111. bool isLocalFile= islocalfile;//[self.content_data[indexPath.row] valueForKey:@"isLocalFile"];
  112. PDFViewController *ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFViewController"];
  113. ViewController.url = url;
  114. ViewController.canSave = false;
  115. ViewController.isLocalfile=isLocalFile;
  116. ViewController.defaultStyle = true;
  117. ViewController.save_name = title;
  118. // NSString* subject;
  119. // if (company.length==0) {
  120. // NSString* cur_time =[RAUtils current_date];
  121. // subject =name;//[NSString stringWithFormat:@"NPD Product List %@",cur_time];
  122. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  123. // NSString* customer_email= [appDelegate.customerInfo valueForKey:@"customer_email"];
  124. NSMutableArray* send_to = [[NSMutableArray alloc]init];
  125. // if(customer_email.length>0)
  126. // {
  127. // send_to=[[customer_email componentsSeparatedByString:NSLocalizedString(@";", nil)] mutableCopy];
  128. // // customer_email compo
  129. // // [send_to addObject:customer_email];
  130. // }
  131. ViewController.mail_to = send_to;
  132. // }
  133. // else
  134. // {
  135. // subject = [NSString stringWithFormat:@"Tear sheet for %@",company ];
  136. // }
  137. // ViewController.attachment_name = [NSString stringWithFormat:@"NPD_Product_List %@.pdf",cur_time];
  138. ViewController.mail_subject = subject;
  139. ViewController.hidenavi = false;
  140. [self.navigationController pushViewController:ViewController animated:YES];
  141. }
  142. #pragma mark - OperationQueue request page data
  143. -(void) loadpage
  144. {
  145. __weak typeof(self) weakself = self;
  146. NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
  147. if (weakself) {
  148. __strong typeof(weakself) strongself = weakself;
  149. [strongself operation_loadPage];
  150. }
  151. }];
  152. [self.dataOperationQueue addOperation:operation];
  153. }
  154. - (void)loadmore
  155. {
  156. // self.btnrefresh.enabled = NO;
  157. // self.btnrefresh.titleLabel.text =NSLocalizedString(@"loading",nil);
  158. // [self.btnrefresh setTitle:@"Loading..." forState:UIControlStateNormal];
  159. [self loadpage];
  160. }
  161. -(void)manually_refresh
  162. {
  163. UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:201];
  164. // if(self.isrefreshing)
  165. // {
  166. // [reF endRefreshing];
  167. // return;
  168. // }
  169. reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Refreshing"];
  170. if ([self respondsToSelector:@selector(ReloadData)])
  171. [self performSelector:@selector(ReloadData) withObject:nil afterDelay:1];
  172. }
  173. -(void)ReloadData
  174. {
  175. // [self.content_data removeAllObjects];
  176. // [self.table_order reloadData];
  177. // self.table_order.hidden = true;
  178. UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:201];
  179. [reF endRefreshing];
  180. reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
  181. // self.keywords=self.searchbar.text;
  182. // // self.offset = 0;
  183. self.reset_result=true;
  184. // [self.content_data removeAllObjects];
  185. // [self.table_order reloadData];
  186. [self loadpage];
  187. // [self loadpage];
  188. }
  189. -(void)refresh_btn_click:(UILongPressGestureRecognizer*)gestureRecognizer
  190. {
  191. // [self reload_container_getdata:true];
  192. self.reset_result=true;
  193. // self.norefresh=true;
  194. [self loadpage];
  195. }
  196. - (void)operation_loadPage {
  197. if (self.dataOperationQueue.operationCount > 1) { // 队列后面还有操作
  198. return;
  199. }
  200. dispatch_sync(dispatch_get_main_queue(), ^{
  201. //在主线程处理界面逻辑
  202. if(self.reset_result)
  203. {
  204. self.offset = 0;
  205. //[self.filterparams removeAllObjects];
  206. [self.table_data removeAllObjects];
  207. [self.tableView reloadData];
  208. }
  209. //
  210. // // NSMutableArray* arr_status = [[NSMutableArray alloc] init];
  211. //
  212. // NSMutableArray* arr_statusname = [[NSMutableArray alloc] init];
  213. // int count = [[self.status_cadedate valueForKey:@"count"] intValue];
  214. // for(int i=0;i<count;i++)
  215. // {
  216. // NSDictionary* val_json =[self.status_cadedate objectForKey:[NSString stringWithFormat:@"val_%d",i]];
  217. // int check = [[val_json valueForKey:@"check"] intValue];
  218. // if(check==1)
  219. // {
  220. // // [arr_status addObject:[NSString stringWithFormat:@"%@",[val_json valueForKey:@"value_id"]]];
  221. // [arr_statusname addObject:[NSString stringWithFormat:@"%@",[val_json valueForKey:@"value"]]];
  222. //
  223. // // break;
  224. // }
  225. // }
  226. //
  227. // // NSString * str_status = [arr_status componentsJoinedByString:@","];
  228. // NSString * str_statusname = [arr_statusname componentsJoinedByString:@","];
  229. // if(str_statusname.length==0)
  230. // str_statusname = @"All";
  231. // self.label_filter.text = str_statusname;
  232. // if(self.offset==0)
  233. // {
  234. // self.table_order.hidden = true;
  235. //
  236. self.mum.center = self.view.center;
  237. self.mum.hidden = false;
  238. [self.mum startAnimating];
  239. // }
  240. self.label_net_err.hidden=true;
  241. });
  242. NSMutableDictionary* content=nil;
  243. // NSMutableDictionary* params = [[NSMutableDictionary alloc]init];
  244. self.filterparams[@"offset"] = [NSNumber numberWithLong:self.offset];
  245. // self.filterparams = params;
  246. content=[[ACNetwork request_DocList:self.filterparams]mutableCopy];
  247. dispatch_sync(dispatch_get_main_queue(), ^{
  248. //在主线程处理界请求结果
  249. [self.mum stopAnimating];
  250. // self.isrefreshing=false;
  251. if (self.dataOperationQueue.operationCount > 1) { // 队列后面还有操作
  252. return ;
  253. }
  254. int result=[[content valueForKey:@"result"] intValue];
  255. if(result==2||result==0)
  256. {
  257. NSArray * arrlist = content[@"list"];
  258. long count = arrlist.count ;
  259. self.offset += count;
  260. [self.table_data addObjectsFromArray:arrlist];
  261. // for(int i=0;i<count;i++)
  262. // {
  263. //
  264. // NSDictionary* objmsg = [content objectForKey:[NSString stringWithFormat:@"item_%d",i]];
  265. //
  266. // table_data
  267. //
  268. // [self.content_data addObject:[NSMutableDictionary dictionaryWithDictionary:objmsg]];
  269. //
  270. // }
  271. if(count<self.limit)
  272. {
  273. // int i =self.btnrefresh.state;
  274. self.load_more_hint=@"All loaded";
  275. // self.btnrefresh.titleLabel.text =NSLocalizedString(@"no_more", nil);
  276. // [self.btnrefresh setTitle:@"No more" forState:UIControlStateNormal];
  277. }
  278. else
  279. {
  280. self.load_more_hint=@"Load more...";
  281. // self.btnrefresh.enabled = true;
  282. // self.btnrefresh.titleLabel.text =NSLocalizedString(@"load_more",nil);
  283. // [self.btnrefresh setTitle:@"Load more" forState:UIControlStateNormal];
  284. }
  285. self.tableView.hidden = false;
  286. self.reset_result=false;
  287. [self.tableView reloadData ];
  288. }
  289. else if(result==RESULT_NET_ERROR &&self.offset==0)
  290. {
  291. self.label_net_err.hidden=false;
  292. self.tableView.hidden = true;
  293. }
  294. else
  295. {
  296. [RAUtils message_alert:[content valueForKey:@"err_msg"] title:@"Loading Document List" controller:self] ;
  297. }
  298. // NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  299. // bool autologin =[defaults boolForKey:@"autologin"];
  300. // if(!autologin)
  301. // {
  302. // TabBarController * viewController =[self.storyboard instantiateViewControllerWithIdentifier:@"LoginTabBar"];
  303. // [self presentViewController:viewController animated:YES completion:^{
  304. //
  305. // }];
  306. // }
  307. });
  308. }
  309. /*
  310. #pragma mark - Navigation
  311. // In a storyboard-based application, you will often want to do a little preparation before navigation
  312. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  313. // Get the new view controller using [segue destinationViewController].
  314. // Pass the selected object to the new view controller.
  315. }
  316. */
  317. #pragma mark - Table view data source
  318. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
  319. {
  320. if(indexPath.row<self.table_data.count)
  321. return 128;
  322. else
  323. return 44;
  324. }
  325. //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  326. //{
  327. // return 0;
  328. //}
  329. //- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  330. //{
  331. // return 0;
  332. //}
  333. //- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  334. //{
  335. // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  336. // return myView;
  337. //
  338. //}
  339. - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  340. {
  341. NSString* value =nil;//[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  342. if(value==nil)
  343. value=@"";
  344. unsigned long color = strtoul([value UTF8String],0,16);
  345. UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  346. myView.backgroundColor = UIColorFromRGB(0xf7f7f7);
  347. myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath;
  348. myView.layer.shadowColor = [UIColor blackColor].CGColor;
  349. myView.layer.shadowOffset = CGSizeMake(0, 0);
  350. myView.layer.shadowOpacity = 0.5;
  351. myView.layer.shadowRadius = 2.0;
  352. UILabel *statuslabel = [[UILabel alloc] initWithFrame:CGRectMake(8, 2, 130, 22)];
  353. statuslabel.textColor=UIColorFromRGB(color);
  354. statuslabel.backgroundColor = [UIColor clearColor];
  355. statuslabel.text=NSLocalizedString(@"Document #", nil);
  356. [statuslabel sizeToFit];
  357. [myView addSubview:statuslabel];
  358. UILabel *solabel = [[UILabel alloc] initWithFrame:CGRectMake(8, 21, 130, 22)];
  359. solabel.textColor=UIColorFromRGB(color);
  360. solabel.backgroundColor = [UIColor clearColor];
  361. solabel.text=NSLocalizedString(@"Address", nil);
  362. [solabel sizeToFit];
  363. [myView addSubview:solabel];
  364. UILabel *userlabel = [[UILabel alloc] initWithFrame:CGRectMake(143, 2, 135, 22)];
  365. userlabel.textColor=UIColorFromRGB(color);
  366. userlabel.backgroundColor = [UIColor clearColor];
  367. userlabel.text=NSLocalizedString(@"Customer", nil);
  368. [userlabel sizeToFit];
  369. [myView addSubview:userlabel];
  370. // UILabel *creatorlabel = [[UILabel alloc] initWithFrame:CGRectMake(155, 21, 135, 22)];
  371. // creatorlabel.textColor=UIColorFromRGB(color);
  372. // creatorlabel.backgroundColor = [UIColor clearColor];
  373. // creatorlabel.text=NSLocalizedString(@"Create by", nil);
  374. // [creatorlabel sizeToFit];
  375. // [myView addSubview:creatorlabel];
  376. UILabel *contactlabel = [[UILabel alloc] initWithFrame:CGRectMake(345, 2, 150, 22)];
  377. contactlabel.textColor=UIColorFromRGB(color);
  378. contactlabel.backgroundColor = [UIColor clearColor];
  379. contactlabel.text=NSLocalizedString(@"Job Date", nil);
  380. [contactlabel sizeToFit];
  381. [myView addSubview:contactlabel];
  382. //
  383. // UILabel *modellabel = [[UILabel alloc] initWithFrame:CGRectMake(424, 11, 52, 22)];
  384. // modellabel.textColor=[UIColor whiteColor];
  385. // modellabel.backgroundColor = [UIColor clearColor];
  386. // modellabel.text=NSLocalizedString(@"Model", nil);
  387. // [modellabel sizeToFit];
  388. // [myView addSubview:modellabel];
  389. // UILabel *modellabel = [[UILabel alloc] initWithFrame:CGRectMake(self.table_order.frame.size.width-276, 2, 100, 22)];
  390. // modellabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
  391. // modellabel.textColor=[UIColor whiteColor];
  392. // modellabel.backgroundColor = [UIColor clearColor];
  393. // modellabel.text=NSLocalizedString(@"Items/QTY", nil);
  394. // [modellabel sizeToFit];
  395. // [myView addSubview:modellabel];
  396. UILabel *pricelabel = [[UILabel alloc] initWithFrame:CGRectMake(/*492*/self.tableView.frame.size.width-313, 2, 100, 22)];
  397. pricelabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
  398. pricelabel.textColor=UIColorFromRGB(color);
  399. pricelabel.backgroundColor = [UIColor clearColor];
  400. pricelabel.text=NSLocalizedString(@"Agent Name", nil);
  401. [pricelabel sizeToFit];
  402. [myView addSubview:pricelabel];
  403. UILabel *timelabel = [[UILabel alloc] initWithFrame:CGRectMake(self.tableView.frame.size.width-111/*605*/,2, 148, 22)];
  404. timelabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
  405. timelabel.textColor=UIColorFromRGB(color);
  406. timelabel.backgroundColor = [UIColor clearColor];
  407. // if(self.time_zone==nil)
  408. timelabel.text=@"Sign Date";
  409. // else
  410. // timelabel.text=[NSString stringWithFormat:@"Create time (%@)",self.time_zone];
  411. [timelabel sizeToFit];
  412. [myView addSubview:timelabel];
  413. myView.autoresizesSubviews=true;
  414. // [myView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
  415. // modellabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  416. // pricelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  417. // timelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  418. myView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  419. //
  420. return myView;
  421. }
  422. //- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  423. //{
  424. //
  425. //
  426. // NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  427. //
  428. // if(value==nil)
  429. // value=@"";
  430. // unsigned long color = strtoul([value UTF8String],0,16);
  431. //
  432. //
  433. // DefaultTableHeaderView* myView = [[DefaultTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  434. // // myView.backgroundColor = UIColorFromRGB(0x996633);;
  435. //
  436. //
  437. // myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath;
  438. // // myView.layer.masksToBounds = false;
  439. // //添加四个边阴影
  440. //
  441. // myView.layer.shadowColor = [UIColor blackColor].CGColor;
  442. // myView.layer.shadowOffset = CGSizeMake(0, 0);
  443. // myView.layer.shadowOpacity = 0.5;
  444. // myView.layer.shadowRadius = 2.0;
  445. //
  446. //
  447. // NSString*labeltitle = nil;
  448. // switch (section) {
  449. // case 0:
  450. // labeltitle= @"Order Info";
  451. // break;
  452. // case 1:
  453. // {
  454. // labeltitle= @"More Info";
  455. //
  456. // NSString* btntitle=nil ;
  457. // if(self.showMore)
  458. // {
  459. // btntitle=@"Hide";
  460. // // [section setValue:@"false" forKey:@"hide"];
  461. // // [sender setTitle:@"Show" forState:UIControlStateNormal];
  462. // }
  463. // else{
  464. // btntitle=@"Show";
  465. // }
  466. //
  467. //
  468. // UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
  469. // btn.tag=section;
  470. // [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
  471. // [btn setTitle:btntitle forState:UIControlStateNormal];
  472. // [myView addSubview:btn];
  473. //
  474. // }
  475. // break;
  476. // case 2:{
  477. // labeltitle= @"Models";
  478. //
  479. // NSString* btntitle=nil ;
  480. // if(self.showModels)
  481. // {
  482. // btntitle=@"Hide";
  483. // }
  484. // else{
  485. // btntitle=@"Show";
  486. // }
  487. //
  488. //
  489. // UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
  490. // btn.tag=section;
  491. //
  492. // [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
  493. //
  494. // [btn setTitle:btntitle forState:UIControlStateNormal];
  495. // [myView addSubview:btn];
  496. //
  497. // }
  498. // break;
  499. // case 3:
  500. // labeltitle= @"Price Info";
  501. // default:
  502. // break;
  503. // }
  504. //
  505. //
  506. //
  507. // UILabel *titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 5.5, 200, 20)];
  508. // titlelabel.textColor=UIColorFromRGB(color);;
  509. // titlelabel.backgroundColor = [UIColor clearColor];
  510. // titlelabel.text=NSLocalizedString(labeltitle, nil);
  511. // [titlelabel sizeToFit];
  512. // [myView addSubview:titlelabel];
  513. //
  514. // //
  515. // return myView;
  516. //}
  517. //- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  518. //
  519. // return [NSString stringWithFormat:@"Signature%ld",(long)section+1];
  520. //
  521. //}
  522. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  523. {
  524. return 1;
  525. }
  526. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  527. {
  528. return 44;
  529. }
  530. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  531. {
  532. if( self.table_data.count==0)
  533. return 0;
  534. return self.table_data.count+1;
  535. }
  536. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  537. {
  538. if(indexPath.row==self.table_data.count)
  539. {
  540. UITableViewCell *moreCell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"mores"];
  541. UILabel *moreDataLabel=[[UILabel alloc] init];
  542. moreDataLabel.tag=200;
  543. moreDataLabel.text=self.load_more_hint;
  544. [moreDataLabel setFont:[UIFont systemFontOfSize:14.0f]];
  545. [moreDataLabel setTextAlignment:NSTextAlignmentCenter];
  546. moreDataLabel.frame=CGRectMake(0, 10, self.tableView.bounds.size.width, 20);
  547. [moreDataLabel setBackgroundColor:[UIColor clearColor]];
  548. // [moreDataLabel addTarget:self action:@selector(changeCell) forControlEvents:UIControlEventValueChanged];
  549. [moreCell.contentView addSubview:moreDataLabel];
  550. if([self.load_more_hint isEqualToString:@"Load more..."])
  551. [self performSelector:@selector(loadmore) withObject:nil afterDelay:1];
  552. // DebugLog(@"更多...");
  553. moreCell.backgroundColor = [UIColor whiteColor];
  554. return moreCell;
  555. }
  556. else
  557. {
  558. NSString *CellIdentifier = @"DocListTableViewCell";
  559. DocListTableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  560. NSDictionary * item_json = self.table_data[indexPath.row];
  561. cell.labelAgent.text = item_json[@"agent_name"];
  562. NSString* job_addr =item_json[@"job_addr"];
  563. NSString* job_city =item_json[@"job_city"];
  564. NSString* job_state =item_json[@"job_state"];
  565. NSString* job_zip =item_json[@"job_zip"];
  566. NSString* tel =item_json[@"tel"];
  567. NSString* notes =item_json[@"notes"];
  568. if(notes.length>0)
  569. {
  570. cell.Icon_notes.hidden = false;
  571. cell.label_notes.hidden = false;
  572. }
  573. else
  574. {
  575. cell.Icon_notes.hidden = true;
  576. cell.label_notes.hidden = true;
  577. }
  578. NSMutableArray* arr_doc = [item_json[@"documents"] mutableCopy];
  579. int imgcount=0;
  580. int filecount=0;
  581. for(int d=0;d<arr_doc.count;d++)
  582. {
  583. NSDictionary* doc= arr_doc[d];
  584. NSString* type = doc[@"type"];
  585. if([type isEqualToString:@"image"])
  586. imgcount++;
  587. else if([type isEqualToString:@"file"])
  588. filecount++;
  589. }
  590. if(imgcount>0)
  591. {
  592. cell.Icon_img.hidden = false;
  593. cell.label_img.hidden = false;
  594. cell.label_img.text=[NSString stringWithFormat:@"%d",imgcount];
  595. }
  596. else
  597. {
  598. cell.Icon_img.hidden = true;
  599. cell.label_img.hidden = true;
  600. cell.label_img.text=@"";
  601. }
  602. if(filecount>0)
  603. {
  604. cell.Icon_file.hidden = false;
  605. cell.label_file.hidden = false;
  606. cell.label_file.text=[NSString stringWithFormat:@"%d",filecount];
  607. }
  608. else
  609. {
  610. cell.Icon_file.hidden = true;
  611. cell.label_file.hidden = true;
  612. cell.label_file.text=@"";
  613. }
  614. if(tel.length>0)
  615. tel= [@"TEL: " stringByAppendingString:tel];
  616. NSMutableArray* arr_ext= [[NSMutableArray alloc] init];
  617. [arr_ext addObject:job_addr];
  618. [arr_ext addObject:@"\r\n"];
  619. [arr_ext addObject:job_city];
  620. [arr_ext addObject:job_state];
  621. [arr_ext addObject:job_zip];
  622. [arr_ext addObject:@"\r\n"];
  623. [arr_ext addObject:tel];
  624. NSString *nsext=[RAUtils arr2string:arr_ext separator:@", " trim:true];
  625. nsext=[nsext stringByReplacingOccurrencesOfString:@", \r\n," withString:@"\r\n"];
  626. // if(sss.length==0)
  627. // sss=@"";
  628. cell.labelDocID.text = item_json[@"doc_number"];//
  629. cell.labelExtInfo.text =nsext;
  630. cell.labelJobDate.text =item_json[@"job_date"];
  631. cell.labelCustomer.text =item_json[@"customer_name"];
  632. cell.labelSignDate.text =item_json[@"signed_date"];
  633. return cell;
  634. }
  635. // if(tableView==self.itemListTable)
  636. // {
  637. // NSString *CellIdentifier = @"CartItemCell";
  638. // ModelItemCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  639. // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  640. // NSDictionary * combine_json =[item_json objectForKey:@"combine"];
  641. //
  642. // cell.bundle_item=combine_json;
  643. // NSString* img_url = [item_json valueForKey:@"img_url"];
  644. // NSString* description = [item_json valueForKey:@"description"];
  645. // // NSString* identifier = [item_json valueForKey:@"identifier"];
  646. // // NSString* attribute = [item_json valueForKey:@"attribute"];
  647. // NSString* currency = [item_json valueForKey:@"currency"];
  648. // int count =[[item_json valueForKey:@"count"] intValue];
  649. //
  650. // int stockUom =[[item_json valueForKey:@"stockUom"] intValue];
  651. //
  652. // double totalprice =[[item_json valueForKey:@"subtotal_price"] doubleValue];
  653. //
  654. // double unitprice=[[item_json valueForKey:@"unit_price"] doubleValue];
  655. // cell.unit_price = unitprice;
  656. // // cell.labelAttribute.text = attribute;
  657. // // cell.labelCurrency.text = currency;
  658. // cell.labelDescription.text = description;
  659. // // cell.labelIdentifier.text = identifier;
  660. // cell.labelPrice.text = [NSString stringWithFormat:@"%.2f",totalprice];
  661. //
  662. // cell.labelUnitPrice.text = [NSString stringWithFormat:@"%.2f",unitprice];
  663. //
  664. //
  665. //
  666. // NSString* cart_item_id= [item_json valueForKey:@"cart_item_id"];
  667. // cell.cart_id = cart_item_id;
  668. // [cell init_Stepper:stockUom max:9999 min:stockUom value:count];
  669. //
  670. //
  671. //
  672. // [cell set_Count:count];
  673. //
  674. // NSString* file_name=[img_url lastPathComponent];
  675. // NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
  676. // if(img_data!=nil)
  677. // {
  678. //
  679. // UIImage * img =[UIImage imageWithData:img_data];
  680. // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
  681. // }
  682. // else
  683. // {
  684. //
  685. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  686. //
  687. // NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  688. //
  689. // dispatch_async(dispatch_get_main_queue(), ^{
  690. //
  691. //
  692. //
  693. // if(downloadimg_data!=nil)
  694. // {
  695. // [iSalesDB cache_img:downloadimg_data :file_name ];
  696. //
  697. // UIImage * img =[UIImage imageWithData:downloadimg_data];
  698. // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
  699. // }
  700. //
  701. // });
  702. // });
  703. //
  704. //
  705. // }
  706. // return cell;
  707. // }
  708. // else
  709. // {
  710. // NSString *CellIdentifier = @"OrderInfoListItem";
  711. // UITableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  712. // return cell;
  713. // }
  714. }
  715. #pragma mark tableview delegate
  716. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  717. {
  718. //如果是最后的状态cell 则返回;
  719. if(indexPath.row==self.table_data.count)
  720. return;
  721. NSDictionary * item_json = self.table_data[indexPath.row];
  722. NSString* pdf_url = item_json[@"pdf_path1"];
  723. NSString* subject = [NSString stringWithFormat:@"%@ %@, %@ %@",item_json[@"doc_number"],item_json[@"customer_name"],item_json[@"signed_date"],item_json[@"signed_time"]];
  724. [self previewPDF:pdf_url title:item_json[@"doc_number"] subject:subject islocal:false];
  725. // if(self.blk_Select)
  726. // {
  727. //
  728. // // SignatureTableViewCell * cell= [tableView cellForRowAtIndexPath:indexPath];
  729. //
  730. // NSDictionary * item_json = self.signatureData[[NSString stringWithFormat:@"item_%ld",(long)indexPath.section]];
  731. //
  732. // // UIImage* img = [UIImage imageWithContentsOfFile:item_json[@"file"]];
  733. //
  734. //
  735. // self.blk_Select(item_json[@"file"]);
  736. //
  737. // }
  738. //
  739. // [self dismissViewControllerAnimated:false completion:nil];
  740. // if (tableView.isEditing) { // 编辑模式下不响应
  741. // return;
  742. // }
  743. // //
  744. // if(indexPath.row==self.content_data.count)
  745. // return;
  746. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  747. //
  748. // if(appDelegate.user_type==USER_ROLE_CUSTOMER) { // Customer
  749. // if ([Singleton sharedInstance].global_lock) { // Order list 被锁
  750. // [RAUtils message_alert:@"App is locked,You can't view the order Detail" title:@"Warning" controller:self];
  751. // return;
  752. // }
  753. // }
  754. //
  755. // NSString* orderid= [self.content_data[indexPath.row] valueForKey:@"order_id"];
  756. // OrderDetailViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"OrderDetailViewController" ];
  757. //
  758. // // int i =[[self.content_data[indexPath.row] valueForKey:@"order_code"];
  759. // dvc.selectOrder=^(NSMutableDictionary* order_detail){
  760. //
  761. // [self.navigationController popViewControllerAnimated:false];
  762. // if(self.selectOrder)
  763. // self.selectOrder(order_detail);
  764. //
  765. //
  766. //
  767. // };
  768. // NSString* order_code =[self.content_data[indexPath.row] valueForKey:@"order_code"];
  769. //
  770. // dvc.is_shoporder=(self.orderType == 0);
  771. // dvc.order_code = order_code;
  772. // dvc.order_status =[[self.content_data[indexPath.row] valueForKey:@"orderStatus"] intValue];
  773. // // bool temp_order = false ;
  774. // // NSString* order_status=[self.content_data[indexPath.row] valueForKey:@"order_status"];
  775. // // if([order_status isEqualToString:@"Saved"]||[order_status isEqualToString:@"Quoted"])
  776. // // temp_order=true;
  777. // //
  778. // // dvc.isTempOrder = temp_order;
  779. //
  780. // // dvc
  781. //
  782. // dvc.orderid=orderid;
  783. // // dvc.category_id=nil;
  784. // // dvc.ispush=true;
  785. // // [dvc reload];
  786. // [self.navigationController pushViewController:dvc animated:true];
  787. }
  788. - (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
  789. {
  790. __weak typeof (self) weekself=self;
  791. __weak NSIndexPath* weekindex = indexPath;
  792. NSDictionary * item_json = self.table_data[indexPath.row];
  793. NSString* notes = item_json[@"notes"];
  794. NSString* doc_number = item_json[@"doc_number"];
  795. NSString* pdfurl =item_json[@"pdf_path1"];
  796. NSString* jsonurl =item_json[@"json_path1"];
  797. NSMutableArray* arr_doc = [item_json[@"documents"] mutableCopy];
  798. UITableViewRowAction *docAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Documents"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
  799. DebugLog(@"Documents click");
  800. [tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
  801. ExtDocumentsViewController * docVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"ExtDocumentsViewController"];
  802. docVC.docNumber = doc_number;
  803. docVC.arr_documents =arr_doc;
  804. docVC.closeExtDoc=^(bool refresh){
  805. if(refresh)
  806. {
  807. self.reset_result=true;
  808. // self.norefresh=true;
  809. [self loadpage];
  810. }
  811. // [weekself.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:weekindex, nil] withRowAnimation:UITableViewRowAnimationAutomatic];
  812. };
  813. // notesVC.docNotes = notes;
  814. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:docVC] ;
  815. navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  816. [self presentViewController:navi animated:YES completion:^{
  817. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  818. DebugLog(@"filter present.........");
  819. // self.btop = false;
  820. // <#code#>
  821. }];
  822. }];
  823. docAction.backgroundColor = UIColorFromRGB(0xff9933);
  824. UITableViewRowAction *modifyAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@" Modify " handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
  825. [tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
  826. __weak typeof(self) weakSelf = self;
  827. DebugLog(@"modify click");
  828. UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait..." title:@"Downloading contract"];
  829. dispatch_async(dispatch_get_global_queue(0, 0), ^{
  830. NSData* jsondata= [NSData dataWithContentsOfURL:[NSURL URLWithString:jsonurl]];
  831. NSData* pdfdata= [NSData dataWithContentsOfURL:[NSURL URLWithString:pdfurl]];
  832. dispatch_async(dispatch_get_main_queue(), ^{
  833. [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  834. if(jsondata==nil||pdfdata==nil)
  835. {
  836. [RAUtils message_alert:@"Please try again." title:@"Can not download contract" controller:self];
  837. return;
  838. }
  839. NSString* tempDir = NSTemporaryDirectory();
  840. NSString* jsonpath=[tempDir stringByAppendingPathComponent:@"json.json"];
  841. NSString* pdfpath=[tempDir stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.pdf",item_json[@"doc_number"]]];
  842. [jsondata writeToFile:jsonpath atomically:true];
  843. [pdfdata writeToFile:pdfpath atomically:true];
  844. DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
  845. // dvc.templateName = @"debug.json";
  846. dvc.templatePath = jsonpath;
  847. dvc.pdfPath = pdfpath;
  848. dvc.action = PDFEditActionModify;
  849. dvc.docment_id = item_json[@"doc_number"];
  850. dvc.OnSave=^(NSString* file, NSString* subject)
  851. {
  852. [weakSelf previewPDF:file title:item_json[@"doc_number"] subject:subject islocal:true];
  853. };
  854. [self.navigationController pushViewController:dvc animated:true];
  855. });
  856. });
  857. // [tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
  858. // DocnotesViewController * notesVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"DocnotesViewController"];
  859. //
  860. // notesVC.docNumber = doc_number;
  861. // notesVC.docNotes = notes;
  862. //
  863. // UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:notesVC] ;
  864. //
  865. //
  866. //
  867. //
  868. //
  869. //
  870. // navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  871. // [self presentViewController:navi animated:YES completion:^{
  872. //
  873. // // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  874. //
  875. // DebugLog(@"filter present.........");
  876. //
  877. // // self.btop = false;
  878. // // <#code#>
  879. // }];
  880. }];
  881. modifyAction.backgroundColor = UIColorFromRGB(0x9BBF5A);
  882. UITableViewRowAction *noteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@" Note " handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
  883. DebugLog(@"note click");
  884. [tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
  885. DocnotesViewController * notesVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"DocnotesViewController"];
  886. notesVC.docNumber = doc_number;
  887. notesVC.docNotes = notes;
  888. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:notesVC] ;
  889. navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  890. [self presentViewController:navi animated:YES completion:^{
  891. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  892. DebugLog(@"filter present.........");
  893. // self.btop = false;
  894. // <#code#>
  895. }];
  896. }];
  897. noteAction.backgroundColor = UIColorFromRGB(0x336699);
  898. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  899. if(jsonurl.length>0)
  900. return @[modifyAction,docAction,noteAction];
  901. else
  902. return @[docAction,noteAction];
  903. }
  904. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
  905. // if(indexPath.row==self.content_data.count)
  906. // return NO;
  907. //
  908. // if(self.init_style==OL_OPEN)
  909. // return NO;
  910. //
  911. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  912. // // NSString* order_status= [self.content_data[indexPath.row] valueForKey:@"order_status"];
  913. // NSInteger statusCode = [[self.content_data[indexPath.row] valueForKey:@"orderStatus"] integerValue];
  914. //
  915. // if(appDelegate.user_type==USER_ROLE_CUSTOMER) {
  916. // // saved && ((type==0 && merge_permission) || type == 1 || can_cancel)
  917. //
  918. // BOOL isSavedOrder = /*[order_status isEqualToString:@"Saved Order"]*/statusCode == 1;
  919. // switch (self.orderType) {
  920. // case 0:{ // Shop Order
  921. //
  922. // if (!isSavedOrder) {
  923. // return NO;
  924. // } else {
  925. // if ([Singleton sharedInstance].permissions_merge_order || appDelegate.can_cancel_order) {
  926. // return YES;
  927. // } else {
  928. // return NO;
  929. // }
  930. // }
  931. //
  932. // }
  933. // break;
  934. // case 1:{ // Sales Order
  935. // if (isSavedOrder && appDelegate.can_cancel_order) {
  936. // return YES;
  937. // }
  938. // return NO;
  939. // }
  940. // break;
  941. //
  942. // default:
  943. // break;
  944. // }
  945. //
  946. // } else {
  947. // return YES;
  948. // }
  949. return YES;
  950. }
  951. - (void)tableView:(UITableView *)tableView
  952. commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  953. }
  954. - (UITableViewCellEditingStyle)tableView:(UITableView *)tv editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
  955. return UITableViewCellEditingStyleDelete;
  956. // if(indexPath.row==self.content_data.count)
  957. // return UITableViewCellEditingStyleNone;
  958. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  959. // bool offline_edit =[[self.content_data[indexPath.row] valueForKey:@"offline_edit"] boolValue];
  960. //
  961. // // NSString* order_status= [self.content_data[indexPath.row] valueForKey:@"order_status"];
  962. // NSInteger statusCode = [[self.content_data[indexPath.row] valueForKey:@"orderStatus"] integerValue];
  963. // if(/*![order_status isEqualToString:@"Saved Order"]&&! [order_status isEqualToString:@"Quote Saved"]*/statusCode != 1 && statusCode != 0)
  964. // return UITableViewCellEditingStyleNone;
  965. // else
  966. // {
  967. // if(appDelegate.offline_mode==false||offline_edit)
  968. // return UITableViewCellEditingStyleDelete;
  969. // else
  970. // return UITableViewCellEditingStyleNone;
  971. // }
  972. }
  973. @end