DocumentListViewController.m 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274
  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 "RANetwork.h"
  10. #import "DocListTableViewCell.h"
  11. #import "RAUtils.h"
  12. #import "GEContractFilterViewController.h"
  13. #import "RAPDFViewController.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. RAPDFViewController *ViewController = [[UIStoryboard storyboardWithName:@"wkweb" bundle:nil] instantiateViewControllerWithIdentifier:@"RAPDFViewController"];
  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=[[RANetwork 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. [RAUtils message_box:@"Loading Document List" message:[content valueForKey:@"err_msg"] completion:nil];
  298. }
  299. // NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  300. // bool autologin =[defaults boolForKey:@"autologin"];
  301. // if(!autologin)
  302. // {
  303. // TabBarController * viewController =[self.storyboard instantiateViewControllerWithIdentifier:@"LoginTabBar"];
  304. // [self presentViewController:viewController animated:YES completion:^{
  305. //
  306. // }];
  307. // }
  308. });
  309. }
  310. /*
  311. #pragma mark - Navigation
  312. // In a storyboard-based application, you will often want to do a little preparation before navigation
  313. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  314. // Get the new view controller using [segue destinationViewController].
  315. // Pass the selected object to the new view controller.
  316. }
  317. */
  318. #pragma mark - Table view data source
  319. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
  320. {
  321. if(indexPath.row<self.table_data.count)
  322. return 128;
  323. else
  324. return 44;
  325. }
  326. //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  327. //{
  328. // return 0;
  329. //}
  330. //- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  331. //{
  332. // return 0;
  333. //}
  334. //- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  335. //{
  336. // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  337. // return myView;
  338. //
  339. //}
  340. - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  341. {
  342. NSString* value =nil;//[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  343. if(value==nil)
  344. value=@"";
  345. unsigned long color = strtoul([value UTF8String],0,16);
  346. UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  347. myView.backgroundColor = UIColorFromRGB(0xf7f7f7);
  348. myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath;
  349. myView.layer.shadowColor = [UIColor blackColor].CGColor;
  350. myView.layer.shadowOffset = CGSizeMake(0, 0);
  351. myView.layer.shadowOpacity = 0.5;
  352. myView.layer.shadowRadius = 2.0;
  353. UILabel *statuslabel = [[UILabel alloc] initWithFrame:CGRectMake(8, 2, 130, 22)];
  354. statuslabel.textColor=UIColorFromRGB(color);
  355. statuslabel.backgroundColor = [UIColor clearColor];
  356. statuslabel.text=NSLocalizedString(@"Document #", nil);
  357. [statuslabel sizeToFit];
  358. [myView addSubview:statuslabel];
  359. UILabel *solabel = [[UILabel alloc] initWithFrame:CGRectMake(8, 21, 130, 22)];
  360. solabel.textColor=UIColorFromRGB(color);
  361. solabel.backgroundColor = [UIColor clearColor];
  362. solabel.text=NSLocalizedString(@"Address", nil);
  363. [solabel sizeToFit];
  364. [myView addSubview:solabel];
  365. UILabel *userlabel = [[UILabel alloc] initWithFrame:CGRectMake(153, 2, 135, 22)];
  366. userlabel.textColor=UIColorFromRGB(color);
  367. userlabel.backgroundColor = [UIColor clearColor];
  368. userlabel.text=NSLocalizedString(@"Customer", nil);
  369. [userlabel sizeToFit];
  370. [myView addSubview:userlabel];
  371. // UILabel *creatorlabel = [[UILabel alloc] initWithFrame:CGRectMake(155, 21, 135, 22)];
  372. // creatorlabel.textColor=UIColorFromRGB(color);
  373. // creatorlabel.backgroundColor = [UIColor clearColor];
  374. // creatorlabel.text=NSLocalizedString(@"Create by", nil);
  375. // [creatorlabel sizeToFit];
  376. // [myView addSubview:creatorlabel];
  377. UILabel *contactlabel = [[UILabel alloc] initWithFrame:CGRectMake(355, 2, 150, 22)];
  378. contactlabel.textColor=UIColorFromRGB(color);
  379. contactlabel.backgroundColor = [UIColor clearColor];
  380. contactlabel.text=NSLocalizedString(@"Job Date", nil);
  381. [contactlabel sizeToFit];
  382. [myView addSubview:contactlabel];
  383. //
  384. // UILabel *modellabel = [[UILabel alloc] initWithFrame:CGRectMake(424, 11, 52, 22)];
  385. // modellabel.textColor=[UIColor whiteColor];
  386. // modellabel.backgroundColor = [UIColor clearColor];
  387. // modellabel.text=NSLocalizedString(@"Model", nil);
  388. // [modellabel sizeToFit];
  389. // [myView addSubview:modellabel];
  390. // UILabel *modellabel = [[UILabel alloc] initWithFrame:CGRectMake(self.table_order.frame.size.width-276, 2, 100, 22)];
  391. // modellabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
  392. // modellabel.textColor=[UIColor whiteColor];
  393. // modellabel.backgroundColor = [UIColor clearColor];
  394. // modellabel.text=NSLocalizedString(@"Items/QTY", nil);
  395. // [modellabel sizeToFit];
  396. // [myView addSubview:modellabel];
  397. UILabel *pricelabel = [[UILabel alloc] initWithFrame:CGRectMake(/*492*/self.tableView.frame.size.width-313, 2, 100, 22)];
  398. pricelabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
  399. pricelabel.textColor=UIColorFromRGB(color);
  400. pricelabel.backgroundColor = [UIColor clearColor];
  401. pricelabel.text=NSLocalizedString(@"Agent Name", nil);
  402. [pricelabel sizeToFit];
  403. [myView addSubview:pricelabel];
  404. UILabel *timelabel = [[UILabel alloc] initWithFrame:CGRectMake(self.tableView.frame.size.width-111/*605*/,2, 148, 22)];
  405. timelabel.autoresizingMask=UIViewAutoresizingFlexibleLeftMargin;
  406. timelabel.textColor=UIColorFromRGB(color);
  407. timelabel.backgroundColor = [UIColor clearColor];
  408. // if(self.time_zone==nil)
  409. timelabel.text=@"Sign Date";
  410. // else
  411. // timelabel.text=[NSString stringWithFormat:@"Create time (%@)",self.time_zone];
  412. [timelabel sizeToFit];
  413. [myView addSubview:timelabel];
  414. myView.autoresizesSubviews=true;
  415. // [myView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin];
  416. // modellabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  417. // pricelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  418. // timelabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
  419. myView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  420. //
  421. return myView;
  422. }
  423. //- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  424. //{
  425. //
  426. //
  427. // NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
  428. //
  429. // if(value==nil)
  430. // value=@"";
  431. // unsigned long color = strtoul([value UTF8String],0,16);
  432. //
  433. //
  434. // DefaultTableHeaderView* myView = [[DefaultTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  435. // // myView.backgroundColor = UIColorFromRGB(0x996633);;
  436. //
  437. //
  438. // myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath;
  439. // // myView.layer.masksToBounds = false;
  440. // //添加四个边阴影
  441. //
  442. // myView.layer.shadowColor = [UIColor blackColor].CGColor;
  443. // myView.layer.shadowOffset = CGSizeMake(0, 0);
  444. // myView.layer.shadowOpacity = 0.5;
  445. // myView.layer.shadowRadius = 2.0;
  446. //
  447. //
  448. // NSString*labeltitle = nil;
  449. // switch (section) {
  450. // case 0:
  451. // labeltitle= @"Order Info";
  452. // break;
  453. // case 1:
  454. // {
  455. // labeltitle= @"More Info";
  456. //
  457. // NSString* btntitle=nil ;
  458. // if(self.showMore)
  459. // {
  460. // btntitle=@"Hide";
  461. // // [section setValue:@"false" forKey:@"hide"];
  462. // // [sender setTitle:@"Show" forState:UIControlStateNormal];
  463. // }
  464. // else{
  465. // btntitle=@"Show";
  466. // }
  467. //
  468. //
  469. // UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
  470. // btn.tag=section;
  471. // [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
  472. // [btn setTitle:btntitle forState:UIControlStateNormal];
  473. // [myView addSubview:btn];
  474. //
  475. // }
  476. // break;
  477. // case 2:{
  478. // labeltitle= @"Models";
  479. //
  480. // NSString* btntitle=nil ;
  481. // if(self.showModels)
  482. // {
  483. // btntitle=@"Hide";
  484. // }
  485. // else{
  486. // btntitle=@"Show";
  487. // }
  488. //
  489. //
  490. // UIButton * btn =[[UIButton alloc] initWithFrame:CGRectMake(tableView.bounds.size.width-50-15, 0, 50, 33)];
  491. // btn.tag=section;
  492. //
  493. // [btn addTarget:self action:@selector(HideSction:) forControlEvents:UIControlEventTouchUpInside];
  494. //
  495. // [btn setTitle:btntitle forState:UIControlStateNormal];
  496. // [myView addSubview:btn];
  497. //
  498. // }
  499. // break;
  500. // case 3:
  501. // labeltitle= @"Price Info";
  502. // default:
  503. // break;
  504. // }
  505. //
  506. //
  507. //
  508. // UILabel *titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 5.5, 200, 20)];
  509. // titlelabel.textColor=UIColorFromRGB(color);;
  510. // titlelabel.backgroundColor = [UIColor clearColor];
  511. // titlelabel.text=NSLocalizedString(labeltitle, nil);
  512. // [titlelabel sizeToFit];
  513. // [myView addSubview:titlelabel];
  514. //
  515. // //
  516. // return myView;
  517. //}
  518. //- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  519. //
  520. // return [NSString stringWithFormat:@"Signature%ld",(long)section+1];
  521. //
  522. //}
  523. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  524. {
  525. return 1;
  526. }
  527. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  528. {
  529. return 44;
  530. }
  531. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  532. {
  533. if( self.table_data.count==0)
  534. return 0;
  535. return self.table_data.count+1;
  536. }
  537. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  538. {
  539. if(indexPath.row==self.table_data.count)
  540. {
  541. UITableViewCell *moreCell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"mores"];
  542. UILabel *moreDataLabel=[[UILabel alloc] init];
  543. moreDataLabel.tag=200;
  544. moreDataLabel.text=self.load_more_hint;
  545. [moreDataLabel setFont:[UIFont systemFontOfSize:14.0f]];
  546. [moreDataLabel setTextAlignment:NSTextAlignmentCenter];
  547. moreDataLabel.frame=CGRectMake(0, 10, self.tableView.bounds.size.width, 20);
  548. [moreDataLabel setBackgroundColor:[UIColor clearColor]];
  549. // [moreDataLabel addTarget:self action:@selector(changeCell) forControlEvents:UIControlEventValueChanged];
  550. [moreCell.contentView addSubview:moreDataLabel];
  551. if([self.load_more_hint isEqualToString:@"Load more..."])
  552. [self performSelector:@selector(loadmore) withObject:nil afterDelay:1];
  553. // DebugLog(@"更多...");
  554. moreCell.backgroundColor = [UIColor whiteColor];
  555. return moreCell;
  556. }
  557. else
  558. {
  559. NSString *CellIdentifier = @"DocListTableViewCell";
  560. DocListTableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  561. NSDictionary * item_json = self.table_data[indexPath.row];
  562. cell.labelAgent.text = item_json[@"agent_name"];
  563. NSString* job_addr =item_json[@"job_addr"];
  564. NSString* job_city =item_json[@"job_city"];
  565. NSString* job_state =item_json[@"job_state"];
  566. NSString* job_zip =item_json[@"job_zip"];
  567. NSString* tel =item_json[@"tel"];
  568. NSString* notes =item_json[@"notes"];
  569. if(notes.length>0)
  570. {
  571. cell.Icon_notes.hidden = false;
  572. cell.label_notes.hidden = false;
  573. }
  574. else
  575. {
  576. cell.Icon_notes.hidden = true;
  577. cell.label_notes.hidden = true;
  578. }
  579. NSMutableArray* arr_doc = [item_json[@"documents"] mutableCopy];
  580. int imgcount=0;
  581. int filecount=0;
  582. for(int d=0;d<arr_doc.count;d++)
  583. {
  584. NSDictionary* doc= arr_doc[d];
  585. NSString* type = doc[@"type"];
  586. if([type isEqualToString:@"image"])
  587. imgcount++;
  588. else if([type isEqualToString:@"file"])
  589. filecount++;
  590. }
  591. if(imgcount>0)
  592. {
  593. cell.Icon_img.hidden = false;
  594. cell.label_img.hidden = false;
  595. cell.label_img.text=[NSString stringWithFormat:@"%d",imgcount];
  596. }
  597. else
  598. {
  599. cell.Icon_img.hidden = true;
  600. cell.label_img.hidden = true;
  601. cell.label_img.text=@"";
  602. }
  603. if(filecount>0)
  604. {
  605. cell.Icon_file.hidden = false;
  606. cell.label_file.hidden = false;
  607. cell.label_file.text=[NSString stringWithFormat:@"%d",filecount];
  608. }
  609. else
  610. {
  611. cell.Icon_file.hidden = true;
  612. cell.label_file.hidden = true;
  613. cell.label_file.text=@"";
  614. }
  615. if(tel.length>0)
  616. tel= [@"TEL: " stringByAppendingString:tel];
  617. NSMutableArray* arr_ext= [[NSMutableArray alloc] init];
  618. [arr_ext addObject:job_addr];
  619. [arr_ext addObject:@"\r\n"];
  620. [arr_ext addObject:job_city];
  621. [arr_ext addObject:job_state];
  622. [arr_ext addObject:job_zip];
  623. [arr_ext addObject:@"\r\n"];
  624. [arr_ext addObject:tel];
  625. NSString *nsext=[RAConvertor arr2string:arr_ext separator:@", " trim:true];
  626. nsext=[nsext stringByReplacingOccurrencesOfString:@", \r\n," withString:@"\r\n"];
  627. // if(sss.length==0)
  628. // sss=@"";
  629. cell.labelDocID.text = item_json[@"doc_number"];//
  630. cell.labelExtInfo.text =nsext;
  631. cell.labelJobDate.text =item_json[@"job_date"];
  632. cell.labelCustomer.text =item_json[@"customer_name"];
  633. cell.labelSignDate.text =item_json[@"signed_date"];
  634. return cell;
  635. }
  636. // if(tableView==self.itemListTable)
  637. // {
  638. // NSString *CellIdentifier = @"CartItemCell";
  639. // ModelItemCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  640. // NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  641. // NSDictionary * combine_json =[item_json objectForKey:@"combine"];
  642. //
  643. // cell.bundle_item=combine_json;
  644. // NSString* img_url = [item_json valueForKey:@"img_url"];
  645. // NSString* description = [item_json valueForKey:@"description"];
  646. // // NSString* identifier = [item_json valueForKey:@"identifier"];
  647. // // NSString* attribute = [item_json valueForKey:@"attribute"];
  648. // NSString* currency = [item_json valueForKey:@"currency"];
  649. // int count =[[item_json valueForKey:@"count"] intValue];
  650. //
  651. // int stockUom =[[item_json valueForKey:@"stockUom"] intValue];
  652. //
  653. // double totalprice =[[item_json valueForKey:@"subtotal_price"] doubleValue];
  654. //
  655. // double unitprice=[[item_json valueForKey:@"unit_price"] doubleValue];
  656. // cell.unit_price = unitprice;
  657. // // cell.labelAttribute.text = attribute;
  658. // // cell.labelCurrency.text = currency;
  659. // cell.labelDescription.text = description;
  660. // // cell.labelIdentifier.text = identifier;
  661. // cell.labelPrice.text = [NSString stringWithFormat:@"%.2f",totalprice];
  662. //
  663. // cell.labelUnitPrice.text = [NSString stringWithFormat:@"%.2f",unitprice];
  664. //
  665. //
  666. //
  667. // NSString* cart_item_id= [item_json valueForKey:@"cart_item_id"];
  668. // cell.cart_id = cart_item_id;
  669. // [cell init_Stepper:stockUom max:9999 min:stockUom value:count];
  670. //
  671. //
  672. //
  673. // [cell set_Count:count];
  674. //
  675. // NSString* file_name=[img_url lastPathComponent];
  676. // NSData* img_data=[iSalesDB load_cached_img:file_name loadFrom:img_url];
  677. // if(img_data!=nil)
  678. // {
  679. //
  680. // UIImage * img =[UIImage imageWithData:img_data];
  681. // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
  682. // }
  683. // else
  684. // {
  685. //
  686. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  687. //
  688. // NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  689. //
  690. // dispatch_async(dispatch_get_main_queue(), ^{
  691. //
  692. //
  693. //
  694. // if(downloadimg_data!=nil)
  695. // {
  696. // [iSalesDB cache_img:downloadimg_data :file_name ];
  697. //
  698. // UIImage * img =[UIImage imageWithData:downloadimg_data];
  699. // [cell.btnImage setBackgroundImage:img forState:UIControlStateNormal];
  700. // }
  701. //
  702. // });
  703. // });
  704. //
  705. //
  706. // }
  707. // return cell;
  708. // }
  709. // else
  710. // {
  711. // NSString *CellIdentifier = @"OrderInfoListItem";
  712. // UITableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  713. // return cell;
  714. // }
  715. }
  716. #pragma mark tableview delegate
  717. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  718. {
  719. //如果是最后的状态cell 则返回;
  720. if(indexPath.row==self.table_data.count)
  721. return;
  722. NSDictionary * item_json = self.table_data[indexPath.row];
  723. NSString* pdf_url = item_json[@"pdf_path1"];
  724. NSString* subject = [NSString stringWithFormat:@"%@ %@, %@ %@",item_json[@"doc_number"],item_json[@"customer_name"],item_json[@"signed_date"],item_json[@"signed_time"]];
  725. [self previewPDF:pdf_url title:item_json[@"doc_number"] subject:subject islocal:false];
  726. // if(self.blk_Select)
  727. // {
  728. //
  729. // // SignatureTableViewCell * cell= [tableView cellForRowAtIndexPath:indexPath];
  730. //
  731. // NSDictionary * item_json = self.signatureData[[NSString stringWithFormat:@"item_%ld",(long)indexPath.section]];
  732. //
  733. // // UIImage* img = [UIImage imageWithContentsOfFile:item_json[@"file"]];
  734. //
  735. //
  736. // self.blk_Select(item_json[@"file"]);
  737. //
  738. // }
  739. //
  740. // [self dismissViewControllerAnimated:false completion:nil];
  741. // if (tableView.isEditing) { // 编辑模式下不响应
  742. // return;
  743. // }
  744. // //
  745. // if(indexPath.row==self.content_data.count)
  746. // return;
  747. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  748. //
  749. // if(appDelegate.user_type==USER_ROLE_CUSTOMER) { // Customer
  750. // if ([Singleton sharedInstance].global_lock) { // Order list 被锁
  751. // [RAUtils message_alert:@"App is locked,You can't view the order Detail" title:@"Warning" controller:self];
  752. // return;
  753. // }
  754. // }
  755. //
  756. // NSString* orderid= [self.content_data[indexPath.row] valueForKey:@"order_id"];
  757. // OrderDetailViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"OrderDetailViewController" ];
  758. //
  759. // // int i =[[self.content_data[indexPath.row] valueForKey:@"order_code"];
  760. // dvc.selectOrder=^(NSMutableDictionary* order_detail){
  761. //
  762. // [self.navigationController popViewControllerAnimated:false];
  763. // if(self.selectOrder)
  764. // self.selectOrder(order_detail);
  765. //
  766. //
  767. //
  768. // };
  769. // NSString* order_code =[self.content_data[indexPath.row] valueForKey:@"order_code"];
  770. //
  771. // dvc.is_shoporder=(self.orderType == 0);
  772. // dvc.order_code = order_code;
  773. // dvc.order_status =[[self.content_data[indexPath.row] valueForKey:@"orderStatus"] intValue];
  774. // // bool temp_order = false ;
  775. // // NSString* order_status=[self.content_data[indexPath.row] valueForKey:@"order_status"];
  776. // // if([order_status isEqualToString:@"Saved"]||[order_status isEqualToString:@"Quoted"])
  777. // // temp_order=true;
  778. // //
  779. // // dvc.isTempOrder = temp_order;
  780. //
  781. // // dvc
  782. //
  783. // dvc.orderid=orderid;
  784. // // dvc.category_id=nil;
  785. // // dvc.ispush=true;
  786. // // [dvc reload];
  787. // [self.navigationController pushViewController:dvc animated:true];
  788. }
  789. - (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
  790. {
  791. __weak typeof (self) weekself=self;
  792. __weak NSIndexPath* weekindex = indexPath;
  793. NSDictionary * item_json = self.table_data[indexPath.row];
  794. NSString* notes = item_json[@"notes"];
  795. NSString* doc_number = item_json[@"doc_number"];
  796. NSString* pdfurl =item_json[@"pdf_path1"];
  797. NSString* jsonurl =item_json[@"json_path1"];
  798. NSString* md51 =item_json[@"pdf_md5_str"];
  799. NSMutableArray* arr_doc = [item_json[@"documents"] mutableCopy];
  800. UITableViewRowAction *docAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Documents"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
  801. DebugLog(@"Documents click");
  802. [tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
  803. ExtDocumentsViewController * docVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"ExtDocumentsViewController"];
  804. docVC.docNumber = doc_number;
  805. docVC.arr_documents =arr_doc;
  806. docVC.closeExtDoc=^(bool refresh){
  807. if(refresh)
  808. {
  809. self.reset_result=true;
  810. // self.norefresh=true;
  811. [self loadpage];
  812. }
  813. // [weekself.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:weekindex, nil] withRowAnimation:UITableViewRowAnimationAutomatic];
  814. };
  815. // notesVC.docNotes = notes;
  816. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:docVC] ;
  817. navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  818. [self presentViewController:navi animated:YES completion:^{
  819. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  820. DebugLog(@"filter present.........");
  821. // self.btop = false;
  822. // <#code#>
  823. }];
  824. }];
  825. docAction.backgroundColor = UIColorFromRGB(0xff9933);
  826. UITableViewRowAction *modifyAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@" Modify " handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
  827. [tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
  828. __weak typeof(self) weakSelf = self;
  829. DebugLog(@"modify click");
  830. PopWaitAlert* pop =[RAUtils waiting_pop:@"Download contract" completion:nil];
  831. // __block UIAlertController * waitalert = [RAUtils waiting_alert:self title:@"Download contract" completion:^{
  832. dispatch_async(dispatch_get_global_queue(0, 0), ^{
  833. NSData* jsondata= [NSData dataWithContentsOfURL:[NSURL URLWithString:jsonurl]];
  834. NSData* pdfdata= [NSData dataWithContentsOfURL:[NSURL URLWithString:pdfurl]];
  835. dispatch_async(dispatch_get_main_queue(), ^{
  836. // [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
  837. // [waitalert dismissViewControllerAnimated:YES completion:^{
  838. [pop hide];
  839. if(jsondata==nil||pdfdata==nil)
  840. {
  841. // [RAUtils message_alert:@"Please try again." title:@"Can not download contract" controller:self];
  842. [RAUtils message_box:@"Can not download contract" message:@"Please try again." completion:nil];
  843. return;
  844. }
  845. NSString* tempDir = NSTemporaryDirectory();
  846. NSString* jsonpath=[tempDir stringByAppendingPathComponent:@"json.json"];
  847. NSString* pdfpath=[tempDir stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.pdf",item_json[@"doc_number"]]];
  848. [jsondata writeToFile:jsonpath atomically:true];
  849. [pdfdata writeToFile:pdfpath atomically:true];
  850. NSString* md52 = [RAUtils md5WithFile:pdfpath];
  851. if(md51.length>0&&![md51 isEqualToString:md52])
  852. {
  853. // [RAUtils message_alert:@"Please try again." title:@"Can not download contract" controller:self];
  854. [RAUtils message_box:@"Can not download contract" message:@"Please try again." completion:nil];
  855. return;
  856. }
  857. DocumentPageViewController* dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DocumentPageViewController" ];
  858. // dvc.templateName = @"debug.json";
  859. dvc.templatePath = jsonpath;
  860. dvc.pdfPath = pdfpath;
  861. dvc.action = PDFEditActionModify;
  862. dvc.docment_id = item_json[@"doc_number"];
  863. dvc.OnSave=^(NSString* file, NSString* subject)
  864. {
  865. [weakSelf previewPDF:file title:item_json[@"doc_number"] subject:subject islocal:true];
  866. };
  867. [self.navigationController pushViewController:dvc animated:true];
  868. // }];
  869. });
  870. });
  871. // }];
  872. // [tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
  873. // DocnotesViewController * notesVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"DocnotesViewController"];
  874. //
  875. // notesVC.docNumber = doc_number;
  876. // notesVC.docNotes = notes;
  877. //
  878. // UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:notesVC] ;
  879. //
  880. //
  881. //
  882. //
  883. //
  884. //
  885. // navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  886. // [self presentViewController:navi animated:YES completion:^{
  887. //
  888. // // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  889. //
  890. // DebugLog(@"filter present.........");
  891. //
  892. // // self.btop = false;
  893. // // <#code#>
  894. // }];
  895. }];
  896. modifyAction.backgroundColor = UIColorFromRGB(0x9BBF5A);
  897. UITableViewRowAction *noteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@" Note " handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
  898. DebugLog(@"note click");
  899. [tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
  900. DocnotesViewController * notesVC =[ self.storyboard instantiateViewControllerWithIdentifier:@"DocnotesViewController"];
  901. notesVC.docNumber = doc_number;
  902. notesVC.docNotes = notes;
  903. UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:notesVC] ;
  904. navi.modalPresentationStyle = UIModalPresentationFormSheet;//有三种状态,自己看看是哪种
  905. [self presentViewController:navi animated:YES completion:^{
  906. // navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
  907. DebugLog(@"filter present.........");
  908. // self.btop = false;
  909. // <#code#>
  910. }];
  911. }];
  912. noteAction.backgroundColor = UIColorFromRGB(0x336699);
  913. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  914. if(jsonurl.length>0)
  915. return @[modifyAction,docAction,noteAction];
  916. else
  917. return @[docAction,noteAction];
  918. }
  919. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
  920. // if(indexPath.row==self.content_data.count)
  921. // return NO;
  922. //
  923. // if(self.init_style==OL_OPEN)
  924. // return NO;
  925. //
  926. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  927. // // NSString* order_status= [self.content_data[indexPath.row] valueForKey:@"order_status"];
  928. // NSInteger statusCode = [[self.content_data[indexPath.row] valueForKey:@"orderStatus"] integerValue];
  929. //
  930. // if(appDelegate.user_type==USER_ROLE_CUSTOMER) {
  931. // // saved && ((type==0 && merge_permission) || type == 1 || can_cancel)
  932. //
  933. // BOOL isSavedOrder = /*[order_status isEqualToString:@"Saved Order"]*/statusCode == 1;
  934. // switch (self.orderType) {
  935. // case 0:{ // Shop Order
  936. //
  937. // if (!isSavedOrder) {
  938. // return NO;
  939. // } else {
  940. // if ([Singleton sharedInstance].permissions_merge_order || appDelegate.can_cancel_order) {
  941. // return YES;
  942. // } else {
  943. // return NO;
  944. // }
  945. // }
  946. //
  947. // }
  948. // break;
  949. // case 1:{ // Sales Order
  950. // if (isSavedOrder && appDelegate.can_cancel_order) {
  951. // return YES;
  952. // }
  953. // return NO;
  954. // }
  955. // break;
  956. //
  957. // default:
  958. // break;
  959. // }
  960. //
  961. // } else {
  962. // return YES;
  963. // }
  964. return YES;
  965. }
  966. - (void)tableView:(UITableView *)tableView
  967. commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  968. }
  969. - (UITableViewCellEditingStyle)tableView:(UITableView *)tv editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
  970. return UITableViewCellEditingStyleDelete;
  971. // if(indexPath.row==self.content_data.count)
  972. // return UITableViewCellEditingStyleNone;
  973. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  974. // bool offline_edit =[[self.content_data[indexPath.row] valueForKey:@"offline_edit"] boolValue];
  975. //
  976. // // NSString* order_status= [self.content_data[indexPath.row] valueForKey:@"order_status"];
  977. // NSInteger statusCode = [[self.content_data[indexPath.row] valueForKey:@"orderStatus"] integerValue];
  978. // if(/*![order_status isEqualToString:@"Saved Order"]&&! [order_status isEqualToString:@"Quote Saved"]*/statusCode != 1 && statusCode != 0)
  979. // return UITableViewCellEditingStyleNone;
  980. // else
  981. // {
  982. // if(appDelegate.offline_mode==false||offline_edit)
  983. // return UITableViewCellEditingStyleDelete;
  984. // else
  985. // return UITableViewCellEditingStyleNone;
  986. // }
  987. }
  988. @end