iSalesNetwork.m 100 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513
  1. //
  2. // iSalesNetwork.m
  3. // RedAnt ERP Mobile
  4. //
  5. // Created by Ray on 14-6-20.
  6. // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "iSalesNetwork.h"
  9. #import "RAUtils.h"
  10. #import "OLDataProvider.h"
  11. @implementation iSalesNetwork
  12. +(void) LoadImage:(NSString*) url into:(UIImageView*) container
  13. {
  14. DebugLog(@"LoadImage:(NSString*) url in:(UIImageView*) container");
  15. NSString* file_name=[url lastPathComponent];
  16. NSData* img_data = [iSalesDB load_cached_img:file_name];
  17. if(img_data==nil)
  18. {
  19. DebugLog(@"IMG NOT CACHED %@",file_name);
  20. img_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
  21. [iSalesDB cache_img:img_data :file_name ];
  22. //load from internet;
  23. }
  24. if(img_data!=nil)
  25. {
  26. UIImage * img =[UIImage imageWithData:img_data];
  27. if(img==nil)
  28. DebugLog(@"UIIMAGE IS NIL! %@",file_name);
  29. else
  30. container.image =img;
  31. }
  32. else
  33. {
  34. DebugLog(@"IMG DOWNLOAD FAILED! %@",file_name);
  35. }
  36. }
  37. //+(NSData*)fake_json:(NSString*) url
  38. //{
  39. // NSString* jsonfile = nil;
  40. // if([url isEqualToString:URL_UPDATE_AUTH])
  41. // {
  42. // jsonfile=@"login";
  43. //
  44. // }
  45. // else if([url isEqualToString:URL_REQUEST_CATMENU])
  46. // {
  47. // jsonfile=@"categorymenu";
  48. // }
  49. // else if([url isEqualToString:URL_LOAD_HOME])
  50. // {
  51. // jsonfile=@"homepage";
  52. // }
  53. // else if([url isEqualToString:URL_SEARCH])
  54. // {
  55. // jsonfile=@"search";
  56. // }
  57. // else if([url isEqualToString:URL_CATEGORY_LOADMORE])
  58. // {
  59. // jsonfile=@"category_more";
  60. // }else if([url isEqualToString:URL_ITEM_DETAIL])
  61. // {
  62. // jsonfile=@"detail";
  63. // }else if([url isEqualToString:URL_CART])
  64. // {
  65. // jsonfile=@"cart";
  66. // }else if([url isEqualToString:URL_ORDER_LIST])
  67. // {
  68. // jsonfile=@"orderlist";
  69. // }
  70. //// else if([url isEqualToString:URL_ORDER_INFO])
  71. //// {
  72. //// jsonfile=@"orderinfo";
  73. //// }
  74. //// else if([url isEqualToString:URL_ORDER_INFO])
  75. //// {
  76. //// jsonfile=@"orderinfo2label";
  77. //// }
  78. //
  79. //
  80. //
  81. // NSData* json =[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:jsonfile ofType:@"json" ]];
  82. // NSMutableString *result = [[NSMutableString alloc] initWithData:json encoding:NSUTF8StringEncoding];
  83. //
  84. // DebugLog(@"result: \n%@",result);
  85. // return json;
  86. //}
  87. +(NSData*)get_json : (NSString*) url parameters:(NSMutableDictionary *) params //delegate:(id < NSURLConnectionDelegate >)delegate
  88. {
  89. int retry = 0;
  90. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  91. if(appDelegate.user!=nil)
  92. [params setValue:appDelegate.user forKey:@"user"];
  93. if(appDelegate.password!=nil)
  94. [params setValue:appDelegate.password forKey:@"password"];
  95. if(appDelegate.ipad_perm!=nil)
  96. [params setValue:appDelegate.ipad_perm forKey:@"ipad_perm"];
  97. [params setValue:appDelegate.build forKey:@"app_ver"];
  98. UIDevice * dev = [UIDevice currentDevice];
  99. NSUUID* uuid =dev.identifierForVendor;
  100. [params setValue:uuid.UUIDString forKey:@"idfv"];
  101. repeat:{
  102. // return [self fake_json:url];
  103. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  104. //分界线的标识符
  105. NSString *TWITTERFON_FORM_BOUNDARY = @"AaB03x";
  106. //根据url初始化request
  107. NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
  108. cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
  109. timeoutInterval:JSON_TIMEOUT];
  110. //分界线 --AaB03x
  111. NSString *MPboundary=[[NSString alloc]initWithFormat:@"--%@",TWITTERFON_FORM_BOUNDARY];
  112. //结束符 AaB03x--
  113. NSString *endMPboundary=[[NSString alloc]initWithFormat:@"%@--",MPboundary];
  114. //要上传的图片
  115. // UIImage *image=[params objectForKey:@"pic"];
  116. //得到图片的data
  117. // NSData* data = UIImagePNGRepresentation(image);
  118. //http body的字符串
  119. NSMutableString *body=[[NSMutableString alloc]init];
  120. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  121. // [params setValue:@"handset_login" forKey:@"action"];
  122. // [headers setValue:[NSString stringWithFormat:@"%d",dataLength] forKey:@"Content-Length"];
  123. // [params setValue:appDelegate.sessionid forKey:@"sessionid"];
  124. // [params setValue:password forKey:@"password"];
  125. // [params setValue:[NSString stringWithFormat:@"%d",ver] forKey:@"auth_ver"];
  126. // [headers setValue:headQuerlString forKey:@"param"];
  127. //参数的集合的所有key的集合
  128. NSArray *keys= [params allKeys];
  129. DebugLog(@"================parms==================");
  130. //遍历keys
  131. for(int i=0;i<[keys count];i++)
  132. {
  133. //得到当前key
  134. NSString *key=[keys objectAtIndex:i];
  135. //如果key不是pic,说明value是字符类型,比如name:Boris
  136. if(![key isEqualToString:@"pic"])
  137. {
  138. //添加分界线,换行
  139. [body appendFormat:@"%@\r\n",MPboundary];
  140. //添加字段名称,换2行
  141. [body appendFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",key];
  142. //添加字段的值
  143. [body appendFormat:@"%@\r\n",[params objectForKey:key]];
  144. DebugLog(@"parameter: key=%@ value=%@",key,[params objectForKey:key]);
  145. }
  146. }
  147. DebugLog(@"================parms==================");
  148. ////添加分界线,换行
  149. [body appendFormat:@"%@\r\n",MPboundary];
  150. //声明pic字段,文件名为boris.png
  151. [body appendFormat:@"Content-Disposition: form-data; name=\"pic\"; filename=\"boris.png\"\r\n"];
  152. //声明上传文件的格式
  153. [body appendFormat:@"Content-Type: image/png\r\n\r\n"];
  154. //声明结束符:--AaB03x--
  155. NSString *end=[[NSString alloc]initWithFormat:@"\r\n%@",endMPboundary];
  156. //声明myRequestData,用来放入http body
  157. NSMutableData *myRequestData=[NSMutableData data];
  158. //将body字符串转化为UTF8格式的二进制
  159. [myRequestData appendData:[body dataUsingEncoding:NSUTF8StringEncoding]];
  160. //将image的data加入
  161. // [myRequestData appendData:data];
  162. //加入结束符--AaB03x--
  163. [myRequestData appendData:[end dataUsingEncoding:NSUTF8StringEncoding]];
  164. //设置HTTPHeader中Content-Type的值
  165. NSString *content=[[NSString alloc]initWithFormat:@"multipart/form-data; boundary=%@",TWITTERFON_FORM_BOUNDARY];
  166. //设置HTTPHeader
  167. [request setValue:content forHTTPHeaderField:@"Content-Type"];
  168. // 关闭keep alive
  169. [request setValue:@"close" forHTTPHeaderField:@"Connection"];
  170. //设置Content-Length
  171. [request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[myRequestData length]] forHTTPHeaderField:@"Content-Length"];
  172. //设置http body
  173. [request setHTTPBody:myRequestData];
  174. //http method
  175. [request setHTTPMethod:@"POST"];
  176. NSHTTPURLResponse* urlResponse = nil;
  177. NSError *error = [[NSError alloc] init];
  178. NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
  179. DebugLog(@"url: %@",url);
  180. DebugLog(@"response: %@",[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode]);
  181. if (responseData==nil) {
  182. DebugLog(@"response error:%@", [error localizedDescription]);
  183. NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
  184. //#define RESULT_FALSE 0
  185. //#define RESULT_TRUE 2
  186. //#define RESULT_NET_ERROR -3
  187. //#define RESULT_NET_NOTAVAILABLE -4
  188. //#define RESULT_ERROR -5
  189. //#define RESULT_LOCALFILE_ERROR -7
  190. //#define RESULT_USERAUTH_ERROR -9
  191. //#define RESULT_UPDATE_USERAUTH_ERROR -11
  192. //#define RESULT_SESSION_EXPIRED -13
  193. //#define RESULT_VER_LOW
  194. // NSString * moreinfo = error.description ;
  195. NSString* err_msg = [error localizedDescription];
  196. //-----------------retry 3 times for error code -1005------------------------
  197. if(error.code==-1005&&retry<3)
  198. {
  199. retry++;
  200. goto repeat;
  201. }
  202. //-----------------end retry 3 times for error code -1005------------------------
  203. NSDictionary* error_json = [RAUtils error_dict:error];
  204. [ret setObject:error_json forKey:@"err_obj"];
  205. NSString* resp_msg= nil;
  206. if(err_msg.length==0)
  207. {
  208. err_msg =[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode];
  209. resp_msg = err_msg;
  210. }
  211. [ret setValue:[NSString stringWithFormat:@"%d",RESULT_NET_ERROR] forKey:@"result"];
  212. [ret setValue:err_msg forKey:@"err_msg"];
  213. [ret setValue:resp_msg forKey:@"resp_msg"];
  214. [ret setValue:[NSString stringWithFormat:@"%ld",(long)urlResponse.statusCode] forKey:@"resp_code"];
  215. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:ret
  216. options:0
  217. error:nil];
  218. if(![url isEqualToString:URL_ERR_LOG])
  219. {
  220. [iSalesNetwork err_log:[RAUtils base64en:[RAUtils dict2string:params]] result:[RAUtils base64en:[RAUtils dict2string:ret]] module:url];
  221. }
  222. return jsonData;
  223. }
  224. else
  225. {
  226. NSMutableString *str = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
  227. DebugLog(@"data string: %@",str);
  228. NSError *error1 = [[NSError alloc] init];
  229. NSMutableDictionary* jsobj = [[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error1] mutableCopy];
  230. if(jsobj==nil)// 服务器返回不是json
  231. {
  232. jsobj=[[NSMutableDictionary alloc] init];
  233. [jsobj setValue:@"1" forKey:@"result"];
  234. }
  235. int result=[[jsobj valueForKey:@"result"] intValue];
  236. UIApplication * app = [UIApplication sharedApplication];
  237. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  238. NSString* mode =[jsobj valueForKey:@"mode"];
  239. [appDelegate SetMode:mode];
  240. switch (result) {
  241. case 0:
  242. [jsobj setValue:MSG_USERAUTH_ERROR forKey:@"err_msg"];
  243. break;
  244. case 1:
  245. [jsobj setValue:MSG_ERROR forKey:@"err_msg"];
  246. break;
  247. case 2:
  248. [jsobj setValue:MSG_SUCCESS forKey:@"err_msg"];
  249. break;
  250. case 8:
  251. [jsobj setValue:[jsobj valueForKey:@"msg"] forKey:@"err_msg"];
  252. break;
  253. case 9:
  254. [jsobj setValue:[jsobj valueForKey:@"msg"] forKey:@"err_msg"];
  255. break;
  256. default:
  257. [jsobj setValue:MSG_ERROR forKey:@"err_msg"];
  258. break;
  259. }
  260. if([appDelegate.build intValue]< [[jsobj valueForKey:@"min_ver"]intValue])
  261. {
  262. [jsobj setValue:@"9" forKey:@"result"];
  263. [jsobj setValue:MSG_VER_LOW forKey:@"err_msg"];
  264. }
  265. if(![url isEqualToString:URL_ERR_LOG]&&result!=2)
  266. {
  267. [iSalesNetwork err_log:[RAUtils base64en:[RAUtils dict2string:params]] result:[RAUtils base64en:str] module:url];
  268. }
  269. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsobj
  270. options:0
  271. error:nil];
  272. return jsonData;
  273. }
  274. return responseData;
  275. }
  276. }
  277. +(NSString*)DataTOjsonString:(id)object
  278. {
  279. NSString *jsonString = nil;
  280. NSError *error;
  281. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:object
  282. options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string
  283. error:&error];
  284. if (! jsonData) {
  285. NSLog(@"Got an error: %@", error);
  286. } else {
  287. jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  288. }
  289. return jsonString;
  290. }
  291. //+(NSDictionary*)request_Editor:(NSString*) sourceid editor:(NSString*)editor
  292. //{
  293. //
  294. //}
  295. +(NSDictionary*) portfolio_remove:(NSString* ) item_ids
  296. {
  297. if(![self IsNetworkAvailable])
  298. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  299. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  300. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  301. if(appDelegate.user!=nil)
  302. [params setValue:appDelegate.user forKey:@"user"];
  303. if(appDelegate.contact_id!=nil)
  304. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  305. if(appDelegate.password!=nil)
  306. [params setValue:appDelegate.password forKey:@"password"];
  307. [params setValue:item_ids forKey:@"portfolioId"];
  308. // [params setValue:editor forKey:@"editor"];
  309. NSData* json=[self get_json:URL_PORTFOLIO_REMOVE parameters:params];
  310. if(json!=nil)
  311. {
  312. NSError *error=nil;
  313. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  314. int result = [[jsobj valueForKey:@"result"] intValue];
  315. if (result==2)
  316. {
  317. appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  318. [appDelegate update_count_mark];
  319. }
  320. return jsobj;
  321. }
  322. else
  323. return nil;
  324. }
  325. +(NSDictionary*) watchlist_remove:(NSString* ) item_ids
  326. {
  327. if(![self IsNetworkAvailable])
  328. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  329. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  330. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  331. if(appDelegate.user!=nil)
  332. [params setValue:appDelegate.user forKey:@"user"];
  333. if(appDelegate.contact_id!=nil)
  334. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  335. if(appDelegate.password!=nil)
  336. [params setValue:appDelegate.password forKey:@"password"];
  337. [params setValue:item_ids forKey:@"collectId"];
  338. // [params setValue:editor forKey:@"editor"];
  339. NSData* json=[self get_json:URL_WATCHLIST_REMOVE parameters:params];
  340. if(json!=nil)
  341. {
  342. NSError *error=nil;
  343. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  344. int result = [[jsobj valueForKey:@"result"] intValue];
  345. if (result==2)
  346. {
  347. //appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  348. appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  349. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  350. [appDelegate update_count_mark];
  351. }
  352. return jsobj;
  353. }
  354. else
  355. return nil;
  356. }
  357. +(NSDictionary*) move_cart2wish:(NSString* ) item_ids
  358. {
  359. if(![self IsNetworkAvailable])
  360. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  361. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  362. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  363. if(appDelegate.user!=nil)
  364. [params setValue:appDelegate.user forKey:@"user"];
  365. if(appDelegate.contact_id!=nil)
  366. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  367. if(appDelegate.password!=nil)
  368. [params setValue:appDelegate.password forKey:@"password"];
  369. if(appDelegate.order_code!=nil)
  370. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  371. [params setValue:item_ids forKey:@"cartItemId"];
  372. // [params setValue:editor forKey:@"editor"];
  373. NSData* json=[self get_json:URL_CART2WISH parameters:params];
  374. if(json!=nil)
  375. {
  376. NSError *error=nil;
  377. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  378. int result = [[jsobj valueForKey:@"result"] intValue];
  379. if (result==2)
  380. {
  381. //appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  382. appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  383. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  384. [appDelegate update_count_mark];
  385. }
  386. return jsobj;
  387. }
  388. else
  389. return nil;
  390. }
  391. +(NSDictionary*) move_wish2cart:(NSString* ) item_ids
  392. {
  393. if(![self IsNetworkAvailable])
  394. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  395. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  396. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  397. if(appDelegate.user!=nil)
  398. [params setValue:appDelegate.user forKey:@"user"];
  399. if(appDelegate.contact_id!=nil)
  400. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  401. if(appDelegate.password!=nil)
  402. [params setValue:appDelegate.password forKey:@"password"];
  403. if(appDelegate.order_code!=nil)
  404. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  405. [params setValue:item_ids forKey:@"collectId"];
  406. // [params setValue:editor forKey:@"editor"];
  407. NSData* json=[self get_json:URL_WISH2CART parameters:params];
  408. if(json!=nil)
  409. {
  410. NSError *error=nil;
  411. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  412. int result = [[jsobj valueForKey:@"result"] intValue];
  413. if (result==2)
  414. {
  415. //appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  416. appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  417. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  418. [appDelegate update_count_mark];
  419. }
  420. return jsobj;
  421. }
  422. else
  423. return nil;
  424. }
  425. +(NSDictionary*) cart_remove:(NSString* ) item_ids
  426. {
  427. if(![self IsNetworkAvailable])
  428. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  429. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  430. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  431. if(appDelegate.user!=nil)
  432. [params setValue:appDelegate.user forKey:@"user"];
  433. if(appDelegate.contact_id!=nil)
  434. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  435. if(appDelegate.password!=nil)
  436. [params setValue:appDelegate.password forKey:@"password"];
  437. if(appDelegate.order_code!=nil)
  438. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  439. [params setValue:item_ids forKey:@"cartItemId"];
  440. // [params setValue:editor forKey:@"editor"];
  441. NSData* json=[self get_json:URL_CART_REMOVE parameters:params];
  442. if(json!=nil)
  443. {
  444. NSError *error=nil;
  445. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  446. int result = [[jsobj valueForKey:@"result"] intValue];
  447. if (result==2)
  448. {
  449. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  450. [appDelegate update_count_mark];
  451. }
  452. return jsobj;
  453. }
  454. else
  455. return nil;
  456. }
  457. +(NSDictionary*) cart_check:(NSString* ) item_ids
  458. {
  459. return nil;
  460. if(![self IsNetworkAvailable])
  461. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  462. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  463. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  464. if(appDelegate.user!=nil)
  465. [params setValue:appDelegate.user forKey:@"user"];
  466. if(appDelegate.contact_id!=nil)
  467. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  468. if(appDelegate.password!=nil)
  469. [params setValue:appDelegate.password forKey:@"password"];
  470. [params setValue:item_ids forKey:@"cartItemId"];
  471. // [params setValue:editor forKey:@"editor"];
  472. NSData* json=[self get_json:URL_CART_CHECK parameters:params];
  473. if(json!=nil)
  474. {
  475. NSError *error=nil;
  476. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  477. return jsobj;
  478. }
  479. else
  480. return nil;
  481. }
  482. +(NSDictionary*)create_Address:(NSMutableDictionary*)params
  483. {
  484. if(![self IsNetworkAvailable])
  485. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  486. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  487. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  488. if(appDelegate.user!=nil)
  489. [params setValue:appDelegate.user forKey:@"user"];
  490. if(appDelegate.contact_id!=nil)
  491. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  492. if(appDelegate.password!=nil)
  493. [params setValue:appDelegate.password forKey:@"password"];
  494. // [params setValue:sourceid forKey:@"sourceid"];
  495. // [params setValue:editor forKey:@"editor"];
  496. NSData* json=[self get_json:URL_ADDRESS_SAVE parameters:params];
  497. if(json!=nil)
  498. {
  499. NSError *error=nil;
  500. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  501. return jsobj;
  502. }
  503. else
  504. return nil;
  505. }
  506. +(NSDictionary*)copy_Order:(NSString*) order_code
  507. {
  508. if(![self IsNetworkAvailable])
  509. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  510. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  511. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  512. if(appDelegate.user!=nil)
  513. [params setValue:appDelegate.user forKey:@"user"];
  514. if(appDelegate.contact_id!=nil)
  515. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  516. if(appDelegate.password!=nil)
  517. [params setValue:appDelegate.password forKey:@"password"];
  518. // NSString* ssaved = @"false";
  519. // if(saved)
  520. // ssaved=@"true";
  521. // [params setValue:@"true" forKey:@"saved"];
  522. [params setValue:order_code forKey:@"code"];
  523. // [params setValue:sourceid forKey:@"sourceid"];
  524. // [params setValue:editor forKey:@"editor"];
  525. NSData* json=[self get_json:URL_COPY_ORDER parameters:params];
  526. if(json!=nil)
  527. {
  528. NSError *error=nil;
  529. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  530. return jsobj;
  531. }
  532. else
  533. return nil;
  534. }
  535. +(NSDictionary*)sign_Order:(NSString*) order_code path:(NSString*)path
  536. {
  537. if(![self IsNetworkAvailable])
  538. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  539. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  540. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  541. if(appDelegate.user!=nil)
  542. [params setValue:appDelegate.user forKey:@"user"];
  543. if(appDelegate.contact_id!=nil)
  544. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  545. if(appDelegate.password!=nil)
  546. [params setValue:appDelegate.password forKey:@"password"];
  547. // NSString* ssaved = @"false";
  548. // if(saved)
  549. // ssaved=@"true";
  550. // [params setValue:@"true" forKey:@"saved"];
  551. [params setValue:order_code forKey:@"orderCode"];
  552. [params setValue:path forKey:@"picpath"];
  553. // [params setValue:sourceid forKey:@"sourceid"];
  554. // [params setValue:editor forKey:@"editor"];
  555. NSData* json=[self get_json:URL_SIGN_ORDER parameters:params];
  556. if(json!=nil)
  557. {
  558. NSError *error=nil;
  559. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  560. return jsobj;
  561. }
  562. else
  563. return nil;
  564. }
  565. +(NSDictionary*)commit_Order:(NSString*) order_code //saved:(bool) saved
  566. {
  567. if(![self IsNetworkAvailable])
  568. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  569. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  570. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  571. if(appDelegate.user!=nil)
  572. [params setValue:appDelegate.user forKey:@"user"];
  573. if(appDelegate.contact_id!=nil)
  574. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  575. if(appDelegate.password!=nil)
  576. [params setValue:appDelegate.password forKey:@"password"];
  577. // NSString* ssaved = @"false";
  578. // if(saved)
  579. // ssaved=@"true";
  580. [params setValue:@"true" forKey:@"saved"];
  581. [params setValue:order_code forKey:@"orderCode"];
  582. // [params setValue:sourceid forKey:@"sourceid"];
  583. // [params setValue:editor forKey:@"editor"];
  584. NSData* json=[self get_json:URL_COMMIT_ORDER parameters:params];
  585. if(json!=nil)
  586. {
  587. NSError *error=nil;
  588. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  589. return jsobj;
  590. }
  591. else
  592. return nil;
  593. }
  594. +(NSDictionary*)open_Order:(NSString*) order_code
  595. {
  596. if(![self IsNetworkAvailable])
  597. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  598. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  599. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  600. if(appDelegate.user!=nil)
  601. [params setValue:appDelegate.user forKey:@"user"];
  602. // if(appDelegate.contact_id!=nil)
  603. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  604. if(appDelegate.password!=nil)
  605. [params setValue:appDelegate.password forKey:@"password"];
  606. [params setValue:order_code forKey:@"orderCode"];
  607. // [params setValue:sourceid forKey:@"sourceid"];
  608. // [params setValue:editor forKey:@"editor"];
  609. NSData* json=[self get_json:URL_OPEN_ORDER parameters:params];
  610. if(json!=nil)
  611. {
  612. NSError *error=nil;
  613. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  614. int result = [[jsobj valueForKey:@"result"] intValue];
  615. if (result==2)
  616. {
  617. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  618. //appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  619. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  620. [appDelegate update_count_mark];
  621. }
  622. return jsobj;
  623. }
  624. else
  625. return nil;
  626. }
  627. +(NSDictionary*)delete_Order:(NSString*) order_id
  628. {
  629. if(![self IsNetworkAvailable])
  630. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  631. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  632. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  633. if(appDelegate.user!=nil)
  634. [params setValue:appDelegate.user forKey:@"user"];
  635. // if(appDelegate.contact_id!=nil)
  636. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  637. if(appDelegate.password!=nil)
  638. [params setValue:appDelegate.password forKey:@"password"];
  639. [params setValue:order_id forKey:@"orderId"];
  640. // [params setValue:sourceid forKey:@"sourceid"];
  641. // [params setValue:editor forKey:@"editor"];
  642. NSData* json=[self get_json:URL_DELETE_ORDER parameters:params];
  643. if(json!=nil)
  644. {
  645. NSError *error=nil;
  646. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  647. return jsobj;
  648. }
  649. else
  650. return nil;
  651. }
  652. +(NSDictionary*)cancel_Order:(NSString*) order_id
  653. {
  654. if(![self IsNetworkAvailable])
  655. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  656. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  657. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  658. if(appDelegate.user!=nil)
  659. [params setValue:appDelegate.user forKey:@"user"];
  660. // if(appDelegate.contact_id!=nil)
  661. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  662. if(appDelegate.password!=nil)
  663. [params setValue:appDelegate.password forKey:@"password"];
  664. [params setValue:order_id forKey:@"orderId"];
  665. // [params setValue:sourceid forKey:@"sourceid"];
  666. // [params setValue:editor forKey:@"editor"];
  667. NSData* json=[self get_json:URL_CANCEL_ORDER parameters:params];
  668. if(json!=nil)
  669. {
  670. NSError *error=nil;
  671. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  672. return jsobj;
  673. }
  674. else
  675. return nil;
  676. }
  677. +(NSDictionary*)release_Order:(NSString*) order_code
  678. {
  679. if(![self IsNetworkAvailable])
  680. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  681. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  682. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  683. if(appDelegate.user!=nil)
  684. [params setValue:appDelegate.user forKey:@"user"];
  685. // if(appDelegate.contact_id!=nil)
  686. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  687. if(appDelegate.password!=nil)
  688. [params setValue:appDelegate.password forKey:@"password"];
  689. [params setValue:order_code forKey:@"orderCode"];
  690. // [params setValue:sourceid forKey:@"sourceid"];
  691. // [params setValue:editor forKey:@"editor"];
  692. NSData* json=[self get_json:URL_RELEASE_ORDER parameters:params];
  693. if(json!=nil)
  694. {
  695. NSError *error=nil;
  696. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  697. if([[jsobj valueForKey:@"result"]intValue]==2)
  698. { [appDelegate SetSo:nil];
  699. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  700. //appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  701. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  702. [appDelegate update_count_mark];
  703. }
  704. return jsobj;
  705. }
  706. else
  707. return nil;
  708. }
  709. +(NSDictionary*)update_OrderCustomer:(NSString*) order_code customerinfo:(NSMutableDictionary*)info
  710. {
  711. if(![self IsNetworkAvailable])
  712. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  713. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  714. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  715. if(appDelegate.user!=nil)
  716. [info setValue:appDelegate.user forKey:@"user"];
  717. // if(appDelegate.contact_id!=nil)
  718. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  719. if(appDelegate.password!=nil)
  720. [info setValue:appDelegate.password forKey:@"password"];
  721. [info setValue:order_code forKey:@"orderCode"];
  722. // [params setValue:sourceid forKey:@"sourceid"];
  723. // [params setValue:editor forKey:@"editor"];
  724. NSData* json=[self get_json:URL_UPDATE_ORDERCUSTOMER parameters:info];
  725. if(json!=nil)
  726. {
  727. NSError *error=nil;
  728. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  729. return jsobj;
  730. }
  731. else
  732. return nil;
  733. }
  734. +(NSDictionary*)saveandcommit_Order:(NSMutableDictionary*)params
  735. {
  736. if(![self IsNetworkAvailable])
  737. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  738. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  739. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  740. if(appDelegate.user!=nil)
  741. [params setValue:appDelegate.user forKey:@"user"];
  742. if(appDelegate.contact_id!=nil)
  743. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  744. if(appDelegate.password!=nil)
  745. [params setValue:appDelegate.password forKey:@"password"];
  746. if(appDelegate.order_code!=nil)
  747. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  748. // NSDictionary* customerinfo= appDelegate.customerInfo;
  749. //
  750. // NSArray* keys=[customerinfo allKeys];
  751. // for(int i=0;i<keys.count;i++)
  752. // {
  753. // [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  754. // }
  755. //
  756. // [params setValue:sourceid forKey:@"sourceid"];
  757. // [params setValue:editor forKey:@"editor"];
  758. NSData* json=[self get_json:URL_COMMIT_ORDER parameters:params];
  759. if(json!=nil)
  760. {
  761. NSError *error=nil;
  762. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  763. if([[jsobj valueForKey:@"result"]intValue]==2)
  764. [appDelegate SetSo:nil];
  765. return jsobj;
  766. }
  767. else
  768. return nil;
  769. }
  770. +(NSDictionary*)update_Customer:(NSMutableDictionary*)params
  771. {
  772. if(![self IsNetworkAvailable])
  773. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  774. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  775. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  776. if(appDelegate.user!=nil)
  777. [params setValue:appDelegate.user forKey:@"user"];
  778. // if(![appDelegate.order_customer_id isEqualToString: appDelegate.contact_id]&& appDelegate.order_customer_id!=nil)
  779. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  780. // else
  781. if(appDelegate.contact_id!=nil)
  782. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  783. if(appDelegate.password!=nil)
  784. [params setValue:appDelegate.password forKey:@"password"];
  785. // NSDictionary* customerinfo=nil;
  786. // if(![[appDelegate.customerInfo valueForKey:@"customer_cid" ] isEqualToString: [appDelegate.customerInfo valueForKey:@"customer_cid" ]]&& appDelegate.order_customer_id!=nil)
  787. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  788. // else
  789. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  790. //
  791. // appDelegate.customerInfo;
  792. // NSArray* keys=[customerinfo allKeys];
  793. // for(int i=0;i<keys.count;i++)
  794. // {
  795. // [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  796. // }
  797. // [params setValue:sourceid forKey:@"sourceid"];
  798. // [params setValue:editor forKey:@"editor"];
  799. NSData* json=[self get_json:URL_CUSTOMER_UPDATE parameters:params];
  800. if(json!=nil)
  801. {
  802. NSError *error=nil;
  803. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  804. return jsobj;
  805. }
  806. else
  807. return nil;
  808. }
  809. +(NSDictionary*)save_newCustomer:(NSMutableDictionary*)params
  810. {
  811. if(![self IsNetworkAvailable])
  812. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  813. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  814. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  815. if(appDelegate.user!=nil)
  816. [params setValue:appDelegate.user forKey:@"user"];
  817. // if(![appDelegate.order_customer_id isEqualToString: appDelegate.contact_id]&& appDelegate.order_customer_id!=nil)
  818. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  819. // else
  820. if(appDelegate.contact_id!=nil)
  821. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  822. if(appDelegate.password!=nil)
  823. [params setValue:appDelegate.password forKey:@"password"];
  824. // NSDictionary* customerinfo=nil;
  825. // if(![[appDelegate.customerInfo valueForKey:@"customer_cid" ] isEqualToString: [appDelegate.customerInfo valueForKey:@"customer_cid" ]]&& appDelegate.order_customer_id!=nil)
  826. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  827. // else
  828. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  829. //
  830. // appDelegate.customerInfo;
  831. // NSArray* keys=[customerinfo allKeys];
  832. // for(int i=0;i<keys.count;i++)
  833. // {
  834. // [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  835. // }
  836. // [params setValue:sourceid forKey:@"sourceid"];
  837. // [params setValue:editor forKey:@"editor"];
  838. NSData* json=[self get_json:URL_CUSTOMER_SAVE parameters:params];
  839. if(json!=nil)
  840. {
  841. NSError *error=nil;
  842. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  843. return jsobj;
  844. }
  845. else
  846. return nil;
  847. }
  848. +(NSDictionary*)save_Order:(NSMutableDictionary*)params
  849. {
  850. if(![self IsNetworkAvailable])
  851. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  852. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  853. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  854. if(appDelegate.user!=nil)
  855. [params setValue:appDelegate.user forKey:@"user"];
  856. // if(![appDelegate.order_customer_id isEqualToString: appDelegate.contact_id]&& appDelegate.order_customer_id!=nil)
  857. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  858. // else
  859. if(appDelegate.contact_id!=nil)
  860. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  861. if(appDelegate.password!=nil)
  862. [params setValue:appDelegate.password forKey:@"password"];
  863. if(appDelegate.order_code!=nil)
  864. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  865. // NSDictionary* customerinfo=nil;
  866. // if(![[appDelegate.customerInfo valueForKey:@"customer_cid" ] isEqualToString: [appDelegate.customerInfo valueForKey:@"customer_cid" ]]&& appDelegate.order_customer_id!=nil)
  867. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  868. // else
  869. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  870. //
  871. // appDelegate.customerInfo;
  872. // NSArray* keys=[customerinfo allKeys];
  873. // for(int i=0;i<keys.count;i++)
  874. // {
  875. // [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  876. // }
  877. // [params setValue:sourceid forKey:@"sourceid"];
  878. // [params setValue:editor forKey:@"editor"];
  879. NSData* json=[self get_json:URL_SAVE_ORDER parameters:params];
  880. if(json!=nil)
  881. {
  882. NSError *error=nil;
  883. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  884. [appDelegate SetSo:[jsobj valueForKey:@"so#"]];
  885. return jsobj;
  886. }
  887. else
  888. return nil;
  889. }
  890. +(NSDictionary*)request_Editor:(NSString*) request_url params:(NSMutableDictionary*)params
  891. {
  892. if(![self IsNetworkAvailable])
  893. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  894. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  895. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  896. if(appDelegate.user!=nil)
  897. [params setValue:appDelegate.user forKey:@"user"];
  898. // if(![appDelegate.order_customer_id isEqualToString: appDelegate.contact_id]&& appDelegate.order_customer_id!=nil)
  899. // [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  900. // else
  901. if(appDelegate.contact_id!=nil)
  902. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  903. if(appDelegate.password!=nil)
  904. [params setValue:appDelegate.password forKey:@"password"];
  905. if(appDelegate.order_code!=nil)
  906. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  907. // [params setValue:sourceid forKey:@"sourceid"];
  908. // [params setValue:editor forKey:@"editor"];
  909. NSData* json=[self get_json:request_url parameters:params];
  910. if(json!=nil)
  911. {
  912. NSError *error=nil;
  913. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  914. return jsobj;
  915. }
  916. else
  917. return nil;
  918. }
  919. //+(NSDictionary*)request_OrderInfo:(NSString*) orderid
  920. //{
  921. // if(![self IsNetworkAvailable])
  922. // return nil;
  923. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  924. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  925. // if(appDelegate.user!=nil)
  926. // [params setValue:appDelegate.user forKey:@"user"];
  927. // if(appDelegate.password!=nil)
  928. // [params setValue:appDelegate.password forKey:@"password"];
  929. // [params setValue:orderid forKey:@"orderid"];
  930. // NSData* json=[self get_json:URL_ORDER_INFO parameters:params];
  931. // NSError *error=nil;
  932. // NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  933. // return jsobj;
  934. //}
  935. +(NSDictionary*)request_OrderList:(int ) offset limit :(int)limit keywords :(NSString* ) keywords status:(NSString*) status_code customer:(NSString*) customer
  936. {
  937. if(![self IsNetworkAvailable])
  938. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  939. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  940. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  941. if(appDelegate.user!=nil)
  942. [params setValue:appDelegate.user forKey:@"user"];
  943. if(appDelegate.contact_id!=nil)
  944. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  945. if(appDelegate.password!=nil)
  946. [params setValue:appDelegate.password forKey:@"password"];
  947. [params setValue:[NSString stringWithFormat:@"%d",offset ] forKey:@"offset"];
  948. [params setValue:[NSString stringWithFormat:@"%d",limit ] forKey:@"limit"];
  949. [params setValue:keywords forKey:@"keyWord"];
  950. [params setValue:customer forKey:@"customer_filter"];
  951. [params setValue:status_code forKey:@"orderStatus"];
  952. NSData* json=[self get_json:URL_ORDER_LIST parameters:params];
  953. if(json==nil)
  954. return nil;
  955. NSError *error=nil;
  956. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  957. return jsobj;
  958. }
  959. +(NSDictionary*)request_PDFList:(int ) offset limit:(int)limit keywords:(NSString* ) keywords
  960. {
  961. if(![self IsNetworkAvailable])
  962. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  963. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  964. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  965. if(appDelegate.user!=nil)
  966. [params setValue:appDelegate.user forKey:@"user"];
  967. if(appDelegate.contact_id!=nil)
  968. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  969. if(appDelegate.password!=nil)
  970. [params setValue:appDelegate.password forKey:@"password"];
  971. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  972. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  973. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  974. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  975. // [params setValue:filter forKey:@"filter"];
  976. [params setValue:keywords forKey:@"keyWord"];
  977. [params setValue:[NSString stringWithFormat:@"%d",limit] forKey:@"limit"];
  978. [params setValue:[NSString stringWithFormat:@"%d",offset] forKey:@"offset"];
  979. NSData* json=[self get_json:URL_DM_LIST parameters:params];
  980. if(json==nil)
  981. return nil;
  982. NSError *error=nil;
  983. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  984. return jsobj;
  985. }
  986. +(NSDictionary*)direct_save_TearSheet:(NSString*) request_url name:(NSString*)name delete:(NSString* )ids
  987. {
  988. if(![self IsNetworkAvailable])
  989. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  990. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  991. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  992. if(appDelegate.user!=nil)
  993. [params setValue:appDelegate.user forKey:@"user"];
  994. if(appDelegate.contact_id!=nil)
  995. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  996. if(appDelegate.password!=nil)
  997. [params setValue:appDelegate.password forKey:@"password"];
  998. [params setValue:request_url forKey:@"pdfUrl"];
  999. [params setValue:name forKey:@"pdfName"];
  1000. [params setValue:ids forKey:@"itemIds"];
  1001. NSData* json=[self get_json:URL_REQUEST_DM parameters:params];
  1002. if(json==nil)
  1003. return nil;
  1004. NSError *error=nil;
  1005. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1006. return jsobj;
  1007. }
  1008. +(NSDictionary*)request_TearSheet:(NSString*) request_url
  1009. {
  1010. if(![self IsNetworkAvailable])
  1011. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1012. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1013. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1014. if(appDelegate.user!=nil)
  1015. [params setValue:appDelegate.user forKey:@"user"];
  1016. if(appDelegate.contact_id!=nil)
  1017. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1018. if(appDelegate.password!=nil)
  1019. [params setValue:appDelegate.password forKey:@"password"];
  1020. [params setValue:request_url forKey:@"pdfUrl"];
  1021. NSData* json=[self get_json:URL_REQUEST_DM parameters:params];
  1022. if(json==nil)
  1023. return nil;
  1024. NSError *error=nil;
  1025. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1026. return jsobj;
  1027. }
  1028. +(NSDictionary*)save_TearSheet:(NSString*) path name:(NSString*)name delete:(NSString* )ids
  1029. {
  1030. if(![self IsNetworkAvailable])
  1031. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1032. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1033. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1034. if(appDelegate.user!=nil)
  1035. [params setValue:appDelegate.user forKey:@"user"];
  1036. if(appDelegate.contact_id!=nil)
  1037. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1038. if(appDelegate.password!=nil)
  1039. [params setValue:appDelegate.password forKey:@"password"];
  1040. [params setValue:path forKey:@"pdfPath"];
  1041. [params setValue:name forKey:@"pdfName"];
  1042. [params setValue:ids forKey:@"itemIds"];
  1043. NSData* json=[self get_json:URL_SAVE_DM parameters:params];
  1044. if(json==nil)
  1045. return nil;
  1046. NSError *error=nil;
  1047. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1048. return jsobj;
  1049. }
  1050. +(NSDictionary*)err_log:(NSString*) up_params result:(NSString*)result module:(NSString*) module //device:(NSString*) device
  1051. {
  1052. if(![self IsNetworkAvailable])
  1053. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1054. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1055. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1056. if(appDelegate.user!=nil)
  1057. [params setValue:appDelegate.user forKey:@"user"];
  1058. [params setValue:up_params forKey:@"upparam"];
  1059. [params setValue:result forKey:@"result"];
  1060. [params setValue:module forKey:@"interfac"];
  1061. [params setValue:[RAUtils base64en:[RAUtils dict2string: [RAUtils device_info]]] forKey:@"device"];
  1062. // [params setValue:module forKey:@"module"];
  1063. // [[UIDevice currentDevice] name];
  1064. NSData* json=[self get_json:URL_ERR_LOG parameters:params];
  1065. if(json==nil)
  1066. return nil;
  1067. NSError *error=nil;
  1068. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1069. return jsobj;
  1070. }
  1071. +(NSDictionary*)request_ContactList:(int) offset limit:(int)limit keywords:(NSString*) keywords type:(NSString*) contact_type adv_search:(NSDictionary*)upparams
  1072. {
  1073. if(![self IsNetworkAvailable])
  1074. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1075. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1076. if(upparams!=nil)
  1077. params = [upparams mutableCopy];
  1078. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1079. if(appDelegate.user!=nil)
  1080. [params setValue:appDelegate.user forKey:@"user"];
  1081. if(![appDelegate.order_customer_id isEqualToString: appDelegate.contact_id]&& appDelegate.order_customer_id!=nil)
  1082. [params setValue:appDelegate.order_customer_id forKey:@"contactId"];
  1083. else
  1084. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1085. if(appDelegate.password!=nil)
  1086. [params setValue:appDelegate.password forKey:@"password"];
  1087. [params setValue:[NSString stringWithFormat:@"%d",offset ] forKey:@"offset"];
  1088. [params setValue:[NSString stringWithFormat:@"%d",limit ] forKey:@"limit"];
  1089. [params setValue:contact_type forKey:@"contactType"];
  1090. [params setValue:keywords forKey:@"keyword"];
  1091. NSString* url=nil;
  1092. if([contact_type isEqualToString:@"Sales_Order_Ship_To"])
  1093. url=URL_SHIPTO_LIST;
  1094. else
  1095. url=URL_CONTACT_LIST;
  1096. NSData* json=[self get_json:url parameters:params];
  1097. if(json==nil)
  1098. return nil;
  1099. NSError *error=nil;
  1100. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1101. return jsobj;
  1102. }
  1103. +(NSDictionary*)request_OrderDetail:(NSString* ) orderid
  1104. {
  1105. if(![self IsNetworkAvailable])
  1106. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1107. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1108. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1109. if(appDelegate.user!=nil)
  1110. [params setValue:appDelegate.user forKey:@"user"];
  1111. if(appDelegate.contact_id!=nil)
  1112. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1113. if(appDelegate.password!=nil)
  1114. [params setValue:appDelegate.password forKey:@"password"];
  1115. [params setValue:orderid forKey:@"orderId"];
  1116. // [params setValue:[NSString stringWithFormat:@"%d",limit ] forKey:@"limit"];
  1117. NSData* json=[self get_json:URL_ORDER_DETAIL parameters:params];
  1118. if(json==nil)
  1119. return nil;
  1120. NSError *error=nil;
  1121. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1122. return jsobj;
  1123. }
  1124. +(NSDictionary*) add_toCart:(NSString* ) item_id count:(int) count
  1125. {
  1126. if(![self IsNetworkAvailable])
  1127. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1128. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1129. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1130. if(appDelegate.user!=nil)
  1131. [params setValue:appDelegate.user forKey:@"user"];
  1132. if(appDelegate.contact_id!=nil)
  1133. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1134. if(appDelegate.password!=nil)
  1135. [params setValue:appDelegate.password forKey:@"password"];
  1136. if(appDelegate.order_code!=nil)
  1137. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1138. [params setValue:item_id forKey:@"product_id"];
  1139. [params setValue:[NSString stringWithFormat:@"%d",count] forKey:@"count"];
  1140. NSDictionary* customerinfo= appDelegate.customerInfo;
  1141. NSArray* keys=[customerinfo allKeys];
  1142. for(int i=0;i<keys.count;i++)
  1143. {
  1144. [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1145. }
  1146. NSData* json=[self get_json:URL_ADD_TO_CART parameters:params];
  1147. if(json==nil)
  1148. return nil;
  1149. NSError *error=nil;
  1150. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1151. int result = [[jsobj valueForKey:@"result"] intValue];
  1152. if (result==2)
  1153. {
  1154. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1155. // appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1156. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1157. [appDelegate update_count_mark];
  1158. }
  1159. return jsobj;
  1160. }
  1161. +(NSDictionary*) add_toCart_byName:(NSString* ) model_name
  1162. {
  1163. if(![self IsNetworkAvailable])
  1164. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1165. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1166. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1167. if(appDelegate.user!=nil)
  1168. [params setValue:appDelegate.user forKey:@"user"];
  1169. if(appDelegate.contact_id!=nil)
  1170. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1171. if(appDelegate.password!=nil)
  1172. [params setValue:appDelegate.password forKey:@"password"];
  1173. if(appDelegate.order_code!=nil)
  1174. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1175. [params setValue:model_name forKey:@"product_name"];
  1176. [params setValue:[NSString stringWithFormat:@"%d",-1] forKey:@"count"];
  1177. NSDictionary* customerinfo= appDelegate.customerInfo;
  1178. NSArray* keys=[customerinfo allKeys];
  1179. for(int i=0;i<keys.count;i++)
  1180. {
  1181. [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1182. }
  1183. NSData* json=[self get_json:URL_ADD_TO_CART parameters:params];
  1184. if(json==nil)
  1185. return nil;
  1186. NSError *error=nil;
  1187. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1188. int result = [[jsobj valueForKey:@"result"] intValue];
  1189. if (result==2||result==8)
  1190. {
  1191. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1192. // appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1193. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1194. [appDelegate update_count_mark];
  1195. }
  1196. return jsobj;
  1197. }
  1198. //+(NSDictionary*) new_Customer
  1199. //{
  1200. // if(![self IsNetworkAvailable])
  1201. // return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1202. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1203. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1204. // if(appDelegate.user!=nil)
  1205. // [params setValue:appDelegate.user forKey:@"user"];
  1206. //// if(appDelegate.contact_id!=nil)
  1207. //// [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1208. // if(appDelegate.password!=nil)
  1209. // [params setValue:appDelegate.password forKey:@"password"];
  1210. //
  1211. //// if(appDelegate.order_code!=nil)
  1212. //// [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1213. //
  1214. //
  1215. // NSDictionary* customerinfo= appDelegate.customerInfo;
  1216. //
  1217. // NSArray* keys=[customerinfo allKeys];
  1218. // for(int i=0;i<keys.count;i++)
  1219. // {
  1220. // [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1221. // }
  1222. //
  1223. // NSData* json=[self get_json:URL_CUSTOMER_EDIT parameters:params];
  1224. // if(json==nil)
  1225. // return nil;
  1226. // NSError *error=nil;
  1227. // NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1228. // return jsobj;
  1229. //}
  1230. +(NSDictionary*) new_Order
  1231. {
  1232. if(![self IsNetworkAvailable])
  1233. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1234. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1235. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1236. if(appDelegate.user!=nil)
  1237. [params setValue:appDelegate.user forKey:@"user"];
  1238. if(appDelegate.contact_id!=nil)
  1239. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1240. if(appDelegate.password!=nil)
  1241. [params setValue:appDelegate.password forKey:@"password"];
  1242. if(appDelegate.order_code!=nil)
  1243. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1244. NSDictionary* customerinfo= appDelegate.customerInfo;
  1245. NSArray* keys=[customerinfo allKeys];
  1246. for(int i=0;i<keys.count;i++)
  1247. {
  1248. [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
  1249. }
  1250. NSData* json=[self get_json:URL_NEW_ORDER parameters:params];
  1251. if(json==nil)
  1252. return nil;
  1253. NSError *error=nil;
  1254. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1255. int result = [[jsobj valueForKey:@"result"] intValue];
  1256. if (result==2)
  1257. {
  1258. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1259. //appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1260. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1261. [appDelegate update_count_mark];
  1262. }
  1263. [appDelegate SetSo:[jsobj valueForKey:@"soId"]];
  1264. return jsobj;
  1265. }
  1266. +(NSDictionary*) add_toPortfolio:(NSString* ) item_id
  1267. {
  1268. if(![self IsNetworkAvailable])
  1269. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1270. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1271. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1272. if(appDelegate.user!=nil)
  1273. [params setValue:appDelegate.user forKey:@"user"];
  1274. if(appDelegate.contact_id!=nil)
  1275. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1276. if(appDelegate.password!=nil)
  1277. [params setValue:appDelegate.password forKey:@"password"];
  1278. [params setValue:item_id forKey:@"product_id"];
  1279. NSData* json=[self get_json:URL_ADD_TO_PORTFOLIO parameters:params];
  1280. if(json==nil)
  1281. return nil;
  1282. NSError *error=nil;
  1283. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1284. int result = [[jsobj valueForKey:@"result"] intValue];
  1285. if (result==2)
  1286. {
  1287. // appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1288. // appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1289. appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1290. [appDelegate update_count_mark];
  1291. }
  1292. return jsobj;
  1293. }
  1294. +(NSDictionary*) add_toWatchList:(NSString* ) item_id
  1295. {
  1296. if(![self IsNetworkAvailable])
  1297. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1298. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1299. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1300. if(appDelegate.user!=nil)
  1301. [params setValue:appDelegate.user forKey:@"user"];
  1302. if(appDelegate.contact_id!=nil)
  1303. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1304. if(appDelegate.password!=nil)
  1305. [params setValue:appDelegate.password forKey:@"password"];
  1306. [params setValue:item_id forKey:@"product_id"];
  1307. NSData* json=[self get_json:URL_ADD_TO_WATCHLIST parameters:params];
  1308. if(json==nil)
  1309. return nil;
  1310. NSError *error=nil;
  1311. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1312. int result = [[jsobj valueForKey:@"result"] intValue];
  1313. if (result==2)
  1314. {
  1315. //appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1316. appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1317. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1318. [appDelegate update_count_mark];
  1319. }
  1320. return jsobj;
  1321. }
  1322. +(NSDictionary*) cart_setPrice:(NSString*) cart_id price:(float) price discount:(float) discount notes:(NSString*) notes
  1323. {
  1324. if(![self IsNetworkAvailable])
  1325. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1326. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1327. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1328. if(appDelegate.user!=nil)
  1329. [params setValue:appDelegate.user forKey:@"user"];
  1330. if(appDelegate.contact_id!=nil)
  1331. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1332. if(appDelegate.password!=nil)
  1333. [params setValue:appDelegate.password forKey:@"password"];
  1334. [params setValue:cart_id forKey:@"cartitem_id"];
  1335. [params setValue:notes forKey:@"item_note"];
  1336. [params setValue:[NSString stringWithFormat:@"%f",price] forKey:@"price"];
  1337. [params setValue:[NSString stringWithFormat:@"%f",discount] forKey:@"discount"];
  1338. NSData* json=[self get_json:URL_CART_SET_PRICE parameters:params];
  1339. if(json==nil)
  1340. return nil;
  1341. NSError *error=nil;
  1342. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1343. return jsobj;
  1344. }
  1345. +(NSDictionary*) portfolio_setPrice:(NSString*) watchlist_id price:(float) price discount:(float) discount
  1346. {
  1347. if(![self IsNetworkAvailable])
  1348. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1349. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1350. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1351. if(appDelegate.user!=nil)
  1352. [params setValue:appDelegate.user forKey:@"user"];
  1353. if(appDelegate.contact_id!=nil)
  1354. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1355. if(appDelegate.password!=nil)
  1356. [params setValue:appDelegate.password forKey:@"password"];
  1357. [params setValue:watchlist_id forKey:@"item_id"];
  1358. [params setValue:[NSString stringWithFormat:@"%f",price] forKey:@"price"];
  1359. [params setValue:[NSString stringWithFormat:@"%f",discount] forKey:@"discount"];
  1360. NSData* json=[self get_json:URL_PORTFOLIO_SET_PRICE parameters:params];
  1361. if(json==nil)
  1362. return nil;
  1363. NSError *error=nil;
  1364. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1365. return jsobj;
  1366. }
  1367. +(NSDictionary*) cart_setGeneralNote:(NSString*) order_code notes:(NSString*) notes
  1368. {
  1369. if(![self IsNetworkAvailable])
  1370. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1371. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1372. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1373. if(appDelegate.user!=nil)
  1374. [params setValue:appDelegate.user forKey:@"user"];
  1375. if(appDelegate.contact_id!=nil)
  1376. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1377. if(appDelegate.password!=nil)
  1378. [params setValue:appDelegate.password forKey:@"password"];
  1379. [params setValue:order_code forKey:@"orderCode"];
  1380. if(notes.length==0)
  1381. notes=@"";
  1382. [params setValue:notes forKey:@"comments"];
  1383. NSData* json=[self get_json:URL_CART_GENERAL_NOTES parameters:params];
  1384. if(json==nil)
  1385. return nil;
  1386. NSError *error=nil;
  1387. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1388. return jsobj;
  1389. }
  1390. +(NSDictionary*) cart_setItemNote:(NSString*) cart_id notes:(NSString*) notes
  1391. {
  1392. if(![self IsNetworkAvailable])
  1393. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1394. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1395. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1396. if(appDelegate.user!=nil)
  1397. [params setValue:appDelegate.user forKey:@"user"];
  1398. if(appDelegate.contact_id!=nil)
  1399. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1400. if(appDelegate.password!=nil)
  1401. [params setValue:appDelegate.password forKey:@"password"];
  1402. [params setValue:cart_id forKey:@"cartitem_id"];
  1403. if(notes.length==0)
  1404. notes=@"";
  1405. [params setValue:notes forKey:@"notes"];
  1406. NSData* json=[self get_json:URL_CART_ITEM_NOTES parameters:params];
  1407. if(json==nil)
  1408. return nil;
  1409. NSError *error=nil;
  1410. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1411. return jsobj;
  1412. }
  1413. +(NSDictionary*) cart_setFree:(NSString*) cart_id isfree:(bool) isfree
  1414. {
  1415. if(![self IsNetworkAvailable])
  1416. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1417. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1418. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1419. if(appDelegate.user!=nil)
  1420. [params setValue:appDelegate.user forKey:@"user"];
  1421. if(appDelegate.contact_id!=nil)
  1422. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1423. if(appDelegate.password!=nil)
  1424. [params setValue:appDelegate.password forKey:@"password"];
  1425. [params setValue:cart_id forKey:@"cartitem_id"];
  1426. NSString* free=nil;
  1427. if(isfree)
  1428. free=@"true";
  1429. else
  1430. free=@"false";
  1431. [params setValue:free forKey:@"free_giveaway"];
  1432. NSData* json=[self get_json:URL_CART_SET_PRICE parameters:params];
  1433. if(json==nil)
  1434. return nil;
  1435. NSError *error=nil;
  1436. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1437. return jsobj;
  1438. }
  1439. +(NSDictionary*) cart_setQTY:(NSString*) cart_id value:(int) value
  1440. {
  1441. if(![self IsNetworkAvailable])
  1442. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1443. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1444. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1445. if(appDelegate.user!=nil)
  1446. [params setValue:appDelegate.user forKey:@"user"];
  1447. if(appDelegate.contact_id!=nil)
  1448. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1449. if(appDelegate.password!=nil)
  1450. [params setValue:appDelegate.password forKey:@"password"];
  1451. [params setValue:cart_id forKey:@"cartitem_id"];
  1452. [params setValue:[NSString stringWithFormat:@"%d",value] forKey:@"inputInt"];
  1453. NSData* json=[self get_json:URL_CART_INCRESEMENT parameters:params];
  1454. if(json==nil)
  1455. return nil;
  1456. NSError *error=nil;
  1457. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1458. return jsobj;
  1459. }
  1460. +(NSDictionary*) cart_incresement:(NSString*) cart_id increse:(bool) increse
  1461. {
  1462. if(![self IsNetworkAvailable])
  1463. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1464. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1465. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1466. if(appDelegate.user!=nil)
  1467. [params setValue:appDelegate.user forKey:@"user"];
  1468. if(appDelegate.contact_id!=nil)
  1469. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1470. if(appDelegate.password!=nil)
  1471. [params setValue:appDelegate.password forKey:@"password"];
  1472. [params setValue:cart_id forKey:@"cartitem_id"];
  1473. if(increse)
  1474. [params setValue:@"1" forKey:@"incrementType"];
  1475. else
  1476. [params setValue:@"0" forKey:@"incrementType"];
  1477. NSData* json=[self get_json:URL_CART_INCRESEMENT parameters:params];
  1478. if(json==nil)
  1479. return nil;
  1480. NSError *error=nil;
  1481. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1482. return jsobj;
  1483. }
  1484. +(NSDictionary*)request_Cart
  1485. {
  1486. NSLog(@"iSalesNetwork::request_Cart");
  1487. if(![self IsNetworkAvailable])
  1488. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1489. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1490. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1491. if(appDelegate.user!=nil)
  1492. [params setValue:appDelegate.user forKey:@"user"];
  1493. // if(appDelegate.contact_id!=nil)
  1494. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1495. if(appDelegate.password!=nil)
  1496. [params setValue:appDelegate.password forKey:@"password"];
  1497. if(appDelegate.order_code!=nil)
  1498. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1499. NSData* json=[self get_json:URL_CART parameters:params];
  1500. if(json==nil)
  1501. return nil;
  1502. NSError *error=nil;
  1503. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1504. int result = [[jsobj valueForKey:@"result"] intValue];
  1505. if (result==2)
  1506. {
  1507. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1508. //appDelegate.wish_count =[[jsobj valueForKey:@"count"] intValue];
  1509. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1510. [appDelegate update_count_mark];
  1511. }
  1512. return jsobj;
  1513. }
  1514. +(NSDictionary*)request_Portfolio
  1515. {
  1516. if(![self IsNetworkAvailable])
  1517. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1518. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1519. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1520. if(appDelegate.user!=nil)
  1521. [params setValue:appDelegate.user forKey:@"user"];
  1522. if(appDelegate.contact_id!=nil)
  1523. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1524. if(appDelegate.password!=nil)
  1525. [params setValue:appDelegate.password forKey:@"password"];
  1526. [params setValue:[NSString stringWithFormat:@"%d",0 ] forKey:@"offset"];
  1527. [params setValue:[NSString stringWithFormat:@"%d",9999 ] forKey:@"limit"];
  1528. NSData* json=[self get_json:URL_PORTFOLIO parameters:params];
  1529. if(json==nil)
  1530. return nil;
  1531. NSError *error=nil;
  1532. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1533. int result = [[jsobj valueForKey:@"result"] intValue];
  1534. if (result==2)
  1535. {
  1536. // appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1537. //appDelegate.wish_count =[[jsobj valueForKey:@"count"] intValue];
  1538. appDelegate.port_count =[[jsobj valueForKey:@"count"] intValue];
  1539. [appDelegate update_count_mark];
  1540. }
  1541. return jsobj;
  1542. }
  1543. +(NSDictionary*)request_WatchList
  1544. {
  1545. if(![self IsNetworkAvailable])
  1546. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1547. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1548. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1549. if(appDelegate.user!=nil)
  1550. [params setValue:appDelegate.user forKey:@"user"];
  1551. if(appDelegate.contact_id!=nil)
  1552. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1553. if(appDelegate.password!=nil)
  1554. [params setValue:appDelegate.password forKey:@"password"];
  1555. [params setValue:[NSString stringWithFormat:@"%d",0 ] forKey:@"offset"];
  1556. [params setValue:[NSString stringWithFormat:@"%d",9999 ] forKey:@"limit"];
  1557. NSData* json=[self get_json:URL_WATCHLIST parameters:params];
  1558. if(json==nil)
  1559. return nil;
  1560. NSError *error=nil;
  1561. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1562. int result = [[jsobj valueForKey:@"result"] intValue];
  1563. if (result==2)
  1564. {
  1565. // appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1566. appDelegate.wish_count =[[jsobj valueForKey:@"count"] intValue];
  1567. // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1568. [appDelegate update_count_mark];
  1569. }
  1570. return jsobj;
  1571. }
  1572. +(NSDictionary*)request_ItemDetail: (NSString* ) item_id model_name:(NSString*) model_name category_id:(NSString*) category_id use_name :(bool) use_name
  1573. {
  1574. if(![self IsNetworkAvailable])
  1575. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1576. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1577. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1578. if(appDelegate.user!=nil)
  1579. [params setValue:appDelegate.user forKey:@"user"];
  1580. if(appDelegate.contact_id!=nil)
  1581. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1582. if(appDelegate.password!=nil)
  1583. [params setValue:appDelegate.password forKey:@"password"];
  1584. if(appDelegate.order_code!=nil)
  1585. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1586. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  1587. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  1588. if(use_name)
  1589. [params setValue:model_name forKey:@"product_name"];
  1590. else
  1591. [params setValue:item_id forKey:@"product_id"];
  1592. [params setValue:category_id forKey:@"category"];
  1593. if(appDelegate.offline_mode)
  1594. return [OLDataProvider offline_model:params];
  1595. NSData* json=[self get_json:URL_ITEM_DETAIL parameters:params];
  1596. if(json==nil)
  1597. return nil;
  1598. NSError *error=nil;
  1599. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1600. return jsobj;
  1601. }
  1602. //+(NSDictionary*)category_LoadMore: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword offset:(int)offset
  1603. //{
  1604. // if(![self IsNetworkAvailable])
  1605. // return nil;
  1606. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1607. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1608. // if(appDelegate.user!=nil)
  1609. // [params setValue:appDelegate.user forKey:@"user"];
  1610. // if(appDelegate.contact_id!=nil)
  1611. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1612. // if(appDelegate.password!=nil)
  1613. // [params setValue:appDelegate.password forKey:@"password"];
  1614. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  1615. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  1616. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  1617. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  1618. // [params setValue:[NSString stringWithFormat:@"%d",offset] forKey:@"offset"];
  1619. // [params setValue:filter forKey:@"filter"];
  1620. // [params setValue:keyword forKey:@"keyword"];
  1621. //
  1622. //
  1623. // NSData* json=[self get_json:URL_CATEGORY_LOADMORE parameters:params];
  1624. // if(json==nil)
  1625. // return nil;
  1626. // NSError *error=nil;
  1627. // NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1628. // return jsobj;
  1629. //
  1630. //}
  1631. +(NSDictionary*)Category: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword offset:(long) offset limit:(long) limit alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price
  1632. {
  1633. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1634. if(![self IsNetworkAvailable])
  1635. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1636. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1637. if(appDelegate.user!=nil)
  1638. [params setValue:appDelegate.user forKey:@"user"];
  1639. if(appDelegate.contact_id!=nil)
  1640. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1641. if(appDelegate.password!=nil)
  1642. [params setValue:appDelegate.password forKey:@"password"];
  1643. if(appDelegate.order_code!=nil)
  1644. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1645. [params setValue:alert forKey:@"alert"];
  1646. [params setValue:qty forKey:@"sold_by_qty"];
  1647. [params setValue:available forKey:@"available"];
  1648. [params setValue:price forKey:@"price"];
  1649. [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  1650. [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  1651. [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  1652. [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  1653. [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  1654. [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
  1655. [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
  1656. [params setValue:filter forKey:@"filter"];
  1657. [params setValue:keyword forKey:@"keyword"];
  1658. if(appDelegate.offline_mode)
  1659. return [OLDataProvider offline_category:params];
  1660. NSData* json=[self get_json:URL_CATEGORY parameters:params];
  1661. if(json==nil)
  1662. return nil;
  1663. NSError *error=nil;
  1664. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1665. return jsobj;
  1666. }
  1667. +(NSDictionary*)Search:(long ) offset limit :(long)limit keywords :(NSString*) keywords
  1668. {
  1669. if(![self IsNetworkAvailable])
  1670. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1671. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1672. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1673. if(appDelegate.user!=nil)
  1674. [params setValue:appDelegate.user forKey:@"user"];
  1675. if(appDelegate.contact_id!=nil)
  1676. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1677. if(appDelegate.password!=nil)
  1678. [params setValue:appDelegate.password forKey:@"password"];
  1679. if(appDelegate.order_code!=nil)
  1680. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1681. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  1682. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  1683. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  1684. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  1685. // [params setValue:filter forKey:@"filter"];
  1686. [params setValue:keywords forKey:@"keyword"];
  1687. [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
  1688. [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
  1689. NSData* json=[self get_json:URL_SEARCH parameters:params];
  1690. if(json==nil)
  1691. return nil;
  1692. NSError *error=nil;
  1693. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1694. return jsobj;
  1695. }
  1696. +(NSDictionary*)ItemSearch:(long ) offset limit :(long)limit covertype:(NSString* ) covertype ctgid:(NSString*)ctgid modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip alert:(NSString*)alert available:(NSString*)available
  1697. {
  1698. // for debug
  1699. // return [RAUtils error_json:RESULT_NET_ERROR err_msg:nil];
  1700. //return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1701. if(![self IsNetworkAvailable])
  1702. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1703. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1704. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1705. if(appDelegate.user!=nil)
  1706. [params setValue:appDelegate.user forKey:@"user"];
  1707. if(appDelegate.contact_id!=nil)
  1708. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1709. if(appDelegate.password!=nil)
  1710. [params setValue:appDelegate.password forKey:@"password"];
  1711. if(appDelegate.order_code!=nil)
  1712. [params setValue:appDelegate.order_code forKey:@"orderCode"];
  1713. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  1714. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  1715. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  1716. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  1717. // [params setValue:filter forKey:@"filter"];
  1718. [params setValue:covertype forKey:@"covertype"];
  1719. [params setValue:ctgid forKey:@"ctgId"];
  1720. [params setValue:modelname forKey:@"modelName"];
  1721. [params setValue:modeldescrip forKey:@"modelDescription"];
  1722. [params setValue:alert forKey:@"alert"];
  1723. [params setValue:available forKey:@"available"];
  1724. [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
  1725. [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
  1726. NSData* json=[self get_json:URL_ITEM_SEARCH parameters:params];
  1727. if(json==nil)
  1728. return nil;
  1729. NSError *error=nil;
  1730. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1731. return jsobj;
  1732. }
  1733. //+(NSDictionary*)Search: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword
  1734. //{
  1735. // if(![self IsNetworkAvailable])
  1736. // return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1737. // NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1738. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1739. // if(appDelegate.user!=nil)
  1740. // [params setValue:appDelegate.user forKey:@"user"];
  1741. // if(appDelegate.contact_id!=nil)
  1742. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1743. // if(appDelegate.password!=nil)
  1744. // [params setValue:appDelegate.password forKey:@"password"];
  1745. // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  1746. // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  1747. // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
  1748. // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
  1749. // [params setValue:filter forKey:@"filter"];
  1750. // [params setValue:keyword forKey:@"keyword"];
  1751. //
  1752. //
  1753. // NSData* json=[self get_json:URL_SEARCH parameters:params];
  1754. // if(json==nil)
  1755. // return nil;
  1756. // NSError *error=nil;
  1757. // NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1758. // return jsobj;
  1759. //}
  1760. +(NSDictionary*)retrieve_password: (NSString*) user email:(NSString*) email
  1761. {
  1762. if(![self IsNetworkAvailable])
  1763. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1764. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1765. // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1766. // if(appDelegate.user!=nil)
  1767. // [params setValue:appDelegate.user forKey:@"user"];
  1768. // if(appDelegate.contact_id!=nil)
  1769. // [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1770. // if(appDelegate.password!=nil)
  1771. // [params setValue:appDelegate.password forKey:@"password"];
  1772. [params setValue:user forKey:@"username"];
  1773. [params setValue:email forKey:@"email"];
  1774. NSData* json=[self get_json:URL_RETRIEVE_PASS parameters:params];
  1775. if(json==nil)
  1776. return nil;
  1777. NSError *error=nil;
  1778. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1779. return jsobj;
  1780. }
  1781. +(NSDictionary*)load_HomePage:(int) price_template customid:(int) customid
  1782. {
  1783. if(![self IsNetworkAvailable])
  1784. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1785. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1786. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1787. if(appDelegate.user!=nil)
  1788. [params setValue:appDelegate.user forKey:@"user"];
  1789. if(appDelegate.contact_id!=nil)
  1790. [params setValue:appDelegate.contact_id forKey:@"contactId"];
  1791. if(appDelegate.password!=nil)
  1792. [params setValue:appDelegate.password forKey:@"password"];
  1793. [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
  1794. [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
  1795. NSData* json=[self get_json:URL_LOAD_HOME parameters:params];
  1796. if(json==nil)
  1797. return nil;
  1798. NSError *error=nil;
  1799. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1800. return jsobj;
  1801. }
  1802. +(NSDictionary*)logout
  1803. {
  1804. if(![self IsNetworkAvailable])
  1805. {
  1806. NSLog(@"NET ERR");
  1807. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1808. // return nil;
  1809. }
  1810. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1811. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1812. if(appDelegate.user!=nil)
  1813. [params setValue:appDelegate.user forKey:@"user"];
  1814. if(appDelegate.password!=nil)
  1815. [params setValue:appDelegate.password forKey:@"password"];
  1816. NSData* json=[self get_json:URL_LOGOUT parameters:params];
  1817. //if(json==nil)
  1818. if(json==nil)
  1819. return nil;
  1820. NSError *error=nil;
  1821. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1822. int result = [[jsobj valueForKey:@"result"] intValue];
  1823. if (result==2)
  1824. {
  1825. appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
  1826. appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
  1827. appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
  1828. [appDelegate update_count_mark];
  1829. appDelegate.can_show_price =false;
  1830. appDelegate.can_see_price =false;
  1831. appDelegate.can_create_portfolio =false;
  1832. appDelegate.can_create_order =false;
  1833. appDelegate.can_cancel_order =false;
  1834. appDelegate.can_set_cart_price =false;
  1835. appDelegate.can_delete_order =false;
  1836. appDelegate.can_submit_order =false;
  1837. appDelegate.can_set_tearsheet_price =false;
  1838. appDelegate.can_update_contact_info = false;
  1839. appDelegate.save_order_logout = false;
  1840. appDelegate.submit_order_logout = false;
  1841. appDelegate.alert_sold_in_quantities = false;
  1842. appDelegate.ipad_perm =nil ;
  1843. appDelegate.user_type = USER_ROLE_UNKNOWN;
  1844. [appDelegate SetSo:nil];
  1845. [appDelegate set_main_button_panel];
  1846. }
  1847. return jsobj;
  1848. }
  1849. +(NSDictionary*)request_Cagegory
  1850. {
  1851. // NSLog(@"@@@@@@@@@@@@@@@@@@@LOADING CATEGORY MENU");
  1852. if(![self IsNetworkAvailable])
  1853. {
  1854. NSLog(@"NET ERR");
  1855. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1856. // return nil;
  1857. }
  1858. NSData* json=[self get_json:URL_REQUEST_CATMENU parameters:nil];
  1859. //if(json==nil)
  1860. if(json==nil)
  1861. return nil;
  1862. NSError *error=nil;
  1863. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1864. return jsobj;
  1865. }
  1866. +(int)Authorize : (NSString*) user password:(NSString*) password{
  1867. if(![self IsNetworkAvailable])
  1868. return RESULT_NET_NOTAVAILABLE;
  1869. // if(![ApexMobileNetwork IsHostAvailable:URL_UPDATE_AUTH])
  1870. // return RESULT_NET_ERROR;
  1871. NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  1872. long ver =[defaults integerForKey:[NSString stringWithFormat:@"%@_Auth_InfoVer",user]];
  1873. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1874. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1875. if(appDelegate.duid !=nil)
  1876. [params setValue:appDelegate.duid forKey:@"udid"];
  1877. [params setValue:@"handset_login" forKey:@"action"];
  1878. // [headers setValue:[NSString stringWithFormat:@"%d",dataLength] forKey:@"Content-Length"];
  1879. [params setValue:user forKey:@"user"];
  1880. [params setValue:password forKey:@"password"];
  1881. [params setValue:[NSString stringWithFormat:@"%ld",ver] forKey:@"auth_ver"];
  1882. #ifdef TEST
  1883. [params setValue:@"true" forKey:@"is_debug"];
  1884. #else
  1885. [params setValue:@"false" forKey:@"is_debug"];
  1886. #endif
  1887. NSData* json= nil;
  1888. if(appDelegate.offline_mode)
  1889. {
  1890. json= [NSJSONSerialization dataWithJSONObject:[OLDataProvider offline_login:params] options:kNilOptions error:nil];
  1891. }
  1892. else
  1893. {
  1894. json =[self get_json:URL_UPDATE_AUTH parameters:params];
  1895. }
  1896. if(json==nil)
  1897. return RESULT_NET_ERROR;
  1898. int ret = [self parse_authinfo:json user:user password:password];
  1899. DebugLog(@"parse_authinfo return %d ",ret);
  1900. return ret;
  1901. }
  1902. +(NSDictionary*)update_customer_img: (NSString*) contactid img_url:(NSString*) url
  1903. {
  1904. if(![self IsNetworkAvailable])
  1905. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1906. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1907. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1908. if(appDelegate.user!=nil)
  1909. [params setValue:appDelegate.user forKey:@"user"];
  1910. // if(appDelegate.contact_id!=nil)
  1911. if(appDelegate.password!=nil)
  1912. [params setValue:appDelegate.password forKey:@"password"];
  1913. [params setValue:contactid forKey:@"contactId"];
  1914. [params setValue:url forKey:@"business_card"];
  1915. // [params setValue:[NSNumber numberWithInt:index ] forKey:@"index"];
  1916. NSData* json=[self get_json:URL_UPDATE_CUSTOMER_BCARD parameters:params];
  1917. if(json==nil)
  1918. return nil;
  1919. NSError *error=nil;
  1920. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1921. return jsobj;
  1922. }
  1923. +(NSDictionary*)request_PendingOrder:(NSString *)contactid
  1924. {
  1925. if(![self IsNetworkAvailable])
  1926. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1927. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1928. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1929. if(appDelegate.user!=nil)
  1930. [params setValue:appDelegate.user forKey:@"user"];
  1931. // if(appDelegate.contact_id!=nil)
  1932. if(appDelegate.password!=nil)
  1933. [params setValue:appDelegate.password forKey:@"password"];
  1934. [params setValue:contactid forKey:@"contactId"];
  1935. NSData* json=[self get_json:URL_CUSTOMER_PENDINGORDER parameters:params];
  1936. if(json==nil)
  1937. return nil;
  1938. NSError *error=nil;
  1939. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1940. return jsobj;
  1941. }
  1942. +(NSDictionary*)request_CustomerInfo:(NSString* ) contactid
  1943. {
  1944. if(![self IsNetworkAvailable])
  1945. return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
  1946. NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
  1947. AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  1948. if(appDelegate.user!=nil)
  1949. [params setValue:appDelegate.user forKey:@"user"];
  1950. // if(appDelegate.contact_id!=nil)
  1951. if(appDelegate.password!=nil)
  1952. [params setValue:appDelegate.password forKey:@"password"];
  1953. [params setValue:contactid forKey:@"contactId"];
  1954. NSData* json=[self get_json:URL_CUSTOMER_INFO parameters:params];
  1955. if(json==nil)
  1956. return nil;
  1957. NSError *error=nil;
  1958. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1959. return jsobj;
  1960. }
  1961. +(int)parse_authinfo : (NSData *) json user:(NSString*) user password:(NSString*) password
  1962. {
  1963. DebugLog(@"parse_authinfo");
  1964. NSError *error=nil;
  1965. NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
  1966. if(jsobj)
  1967. {
  1968. UIApplication * app = [UIApplication sharedApplication];
  1969. AppDelegate *appDelegate = (AppDelegate *)[app delegate];
  1970. int result = [[jsobj valueForKey:@"result"] intValue];
  1971. if (result<0)
  1972. return result;
  1973. if(result!=AP_USER_AUTH&& result!=9)
  1974. {
  1975. DebugLog(@"USER NOT AUTHORIZED CODE=%d ",result);
  1976. [appDelegate Logout];
  1977. return RESULT_FALSE;
  1978. }
  1979. NSDictionary* objheader = [jsobj objectForKey:@"header"];
  1980. NSString* required_ver=[jsobj objectForKey:@"min_ver"] ;
  1981. user=[objheader objectForKey:@"username"] ;
  1982. DebugLog(@"required_ver=%@ ",required_ver);
  1983. // NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
  1984. // NSString* versionNum =[infoDict valueForKey:@"CFBundleVersion"];
  1985. // versionNum = [NSString stringWithFormat:@"A%@",versionNum];
  1986. int ibadge = [[objheader valueForKey:@"badge"] intValue];
  1987. // if([ibadge isEqual:[NSNull null]])
  1988. // strbadge=@"0";
  1989. // if(ibadge==nil)
  1990. // ibadge=@"0";
  1991. // if([strbadge isEqualToString:@"null"])
  1992. // strbadge=@"0";
  1993. app.applicationIconBadgeNumber = ibadge;//[strbadge intValue];
  1994. // BOOL bigger = [appDelegate.build compare:required_ver] ;
  1995. if([appDelegate.build intValue]<[required_ver intValue])
  1996. return RESULT_VER_LOW;
  1997. // appDelegate.sessionid = [objheader valueForKey:@"sessionid"];
  1998. appDelegate.user = user;
  1999. appDelegate.password = password;
  2000. appDelegate.user_type = [[objheader valueForKey:@"user_type"] intValue];
  2001. appDelegate.user_icon =[objheader valueForKey:@"user_img"] ;
  2002. appDelegate.bLogin = true;
  2003. if(appDelegate.user_type==USER_ROLE_CUSTOMER)
  2004. {
  2005. appDelegate.customerInfo = [objheader objectForKeyedSubscript:@"customerInfo"];
  2006. appDelegate.contact_id = [objheader valueForKey:@"customer_cid"];
  2007. appDelegate.order_code =[objheader valueForKey:@"orderCode"];
  2008. }
  2009. NSString* mode =[jsobj valueForKey:@"mode"] ;
  2010. [appDelegate SetMode:mode];
  2011. appDelegate.cart_count = [[objheader valueForKey:@"cart_count"] intValue];
  2012. appDelegate.wish_count =[[objheader valueForKey:@"wish_count"] intValue];
  2013. appDelegate.port_count =[[objheader valueForKey:@"portfolio_count"] intValue];
  2014. [appDelegate update_count_mark];
  2015. appDelegate.can_show_price =[[objheader valueForKey:@"can_show_price"] boolValue];
  2016. appDelegate.can_see_price =[[objheader valueForKey:@"can_see_price"] boolValue];
  2017. appDelegate.can_create_portfolio =[[objheader valueForKey:@"can_create_portfolio"] boolValue];
  2018. appDelegate.can_create_order =[[objheader valueForKey:@"can_create_order"] boolValue];
  2019. appDelegate.can_cancel_order =[[objheader valueForKey:@"can_cancel_order"] boolValue];
  2020. appDelegate.can_set_cart_price =[[objheader valueForKey:@"can_set_cart_price"] boolValue];
  2021. appDelegate.can_delete_order =[[objheader valueForKey:@"can_delete_order"] boolValue];
  2022. appDelegate.can_update_contact_info =[[objheader valueForKey:@"can_update_contact_info"] boolValue];
  2023. appDelegate.can_submit_order =[[objheader valueForKey:@"can_submit_order"] boolValue];
  2024. appDelegate.can_set_tearsheet_price =[[objheader valueForKey:@"can_set_tearsheet_price"] boolValue];
  2025. appDelegate.save_order_logout =[[objheader valueForKey:@"save_order_logout"] boolValue];
  2026. appDelegate.submit_order_logout =[[objheader valueForKey:@"submit_order_logout"] boolValue];
  2027. appDelegate.alert_sold_in_quantities = [[objheader valueForKey:@"alert_sold_in_quantities"] boolValue];
  2028. appDelegate.ipad_perm =[objheader valueForKey:@"ipad_perm"] ;
  2029. [appDelegate set_main_button_panel];
  2030. // DebugLog(@"sessionid=%@ ",appDelegate.sessionid);
  2031. // if ([[objheader valueForKey:@"update"] boolValue]==false)
  2032. // {
  2033. // // no update on the server;
  2034. // return RESULT_TRUE;
  2035. // }
  2036. // int Auth_InfoVer = [[objheader valueForKey:@"ver"] intValue];
  2037. // NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
  2038. // [defaults removeObjectForKey:[NSString stringWithFormat:@"%@_Auth_InfoVer",user]];
  2039. // [defaults setInteger:Auth_InfoVer forKey:[NSString stringWithFormat:@"%@_Auth_InfoVer",user]];
  2040. // [defaults synchronize];
  2041. //
  2042. // NSDictionary* objfuncs = [jsobj objectForKey:@"functions"];
  2043. // NSArray* keys= [objfuncs allKeys];
  2044. /*
  2045. db.setTransactionSuccessful();
  2046. db.endTransaction();
  2047. */
  2048. return RESULT_TRUE;
  2049. }
  2050. // NSDictionary *weatherInfo = [jsobj objectForKey:@"weatherinfo"];
  2051. // txtView.text = [NSString stringWithFormat:@"今天是 %@ %@ %@ 的天气状况是:%@ %@ ",[weatherInfo objectForKey:@"date_y"],[weatherInfo objectForKey:@"week"],[weatherInfo objectForKey:@"city"], [weatherInfo objectForKey:@"weather1"], [weatherInfo objectForKey:@"temp1"]];
  2052. // DebugLog(@"weatherInfo字典里面的内容为--》%@", weatherDic );
  2053. return RESULT_USERAUTH_ERROR;
  2054. }
  2055. +(bool) IsNetworkAvailable
  2056. {
  2057. if (([Reachability reachabilityForInternetConnection].currentReachabilityStatus == NotReachable) &&
  2058. ([Reachability reachabilityForLocalWiFi].currentReachabilityStatus == NotReachable))
  2059. return false;
  2060. return true;
  2061. }
  2062. //+(NSString *)flattenHTML:(NSString *)html trimWhiteSpace:(BOOL)trim
  2063. //{
  2064. // NSScanner *theScanner = [NSScanner scannerWithString:html];
  2065. // NSString *text = nil;
  2066. //
  2067. // while ([theScanner isAtEnd] == NO) {
  2068. // // find start of tag
  2069. // [theScanner scanUpToString:@"<" intoString:NULL] ;
  2070. // // find end of tag
  2071. // [theScanner scanUpToString:@">" intoString:&text] ;
  2072. // // replace the found tag with a space
  2073. // //(you can filter multi-spaces out later if you wish)
  2074. // html = [html stringByReplacingOccurrencesOfString:
  2075. // [ NSString stringWithFormat:@"%@>", text]
  2076. // withString:@""];
  2077. // }
  2078. //
  2079. // return trim ? [html stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] : html;
  2080. //}
  2081. //
  2082. //+(NSString *)flattenURL:(NSString *)url trimWhiteSpace:(BOOL)trim
  2083. //{
  2084. // NSScanner *theScanner = [NSScanner scannerWithString:url];
  2085. // NSString *text = nil;
  2086. //
  2087. // while ([theScanner isAtEnd] == NO) {
  2088. // // find start of tag
  2089. // [theScanner scanUpToString:@"/" intoString:NULL] ;
  2090. // // find end of tag
  2091. // [theScanner scanUpToString:@"/" intoString:&text] ;
  2092. // // replace the found tag with a space
  2093. // //(you can filter multi-spaces out later if you wish)
  2094. // url = [url stringByReplacingOccurrencesOfString:
  2095. // [ NSString stringWithFormat:@"%@", text]
  2096. // withString:@""];
  2097. // }
  2098. //
  2099. // return trim ? [url stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] : url;
  2100. //}
  2101. @end