You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2551 lines
140 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_autocomplete] Script Date: 11/24/2023 9:49:45 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. ALTER PROC [dbo].[proc_autocomplete] (
  9. @category VARCHAR(50)
  10. ,@searchText VARCHAR(50)
  11. ,@param1 VARCHAR(50) = NULL
  12. ,@param2 VARCHAR(50) = NULL
  13. ,@param3 VARCHAR(50) = NULL
  14. )
  15. AS
  16. -----------------------------------------
  17. --July 12 --> added flags (remit- searchCustomerDeleteKYC)
  18. --July 13 --> searchCustomerDeleteKYC remove aprove flag
  19. --July 13 --> JME 556 SearchCustomer Flag: Receiver
  20. -->#511 @category='referralCodeNew' - Fix inactive
  21. -->618 enable customer filter not appearing
  22. --> Add new filer @category: searchCustomerforMobileActivation
  23. -- Added new @category = searchCustomerEmail
  24. -- Added new @category = referralForCashCollect
  25. -- show only teller for cash collect & verify mobile txn
  26. -- #814 added new @category = 'MembershipId' for cash collect from agent
  27. -- #1006 -> enable search with id number in @category = 'CustomerName'
  28. -- #1030 -> added flag, searchCustomerForReport
  29. -- #-> added flag,searchCustomerForLawsonCard
  30. -- #1058 - added flag = 'CustomerForLawson' for lawson deposit mapping
  31. -- #1195 select lawson card in search field @category = 'searchCustomer','searchCustomerForLog', 'searchCustomerforMobileActivation', 'searchRejectedCustomer'
  32. -- #1262 chnage in @flag = 'searchCustomerForReport' for autocomplete in Customer Registration Status Report
  33. -- #1369 - @flag = 'searchCustomerForReport'
  34. -- #5968 - service charge revised , @flag = 'getAgentForFreeSC'
  35. -- #9490 - push notification for individual customer
  36. -- #17968 - replaced lawson card num with kyc status
  37. -- #18970 added new @category = 'searchCustomerForKYC' to show only mobile aproved customer in customerKyc page
  38. --------------------------------------------
  39. DECLARE @SQL AS VARCHAR(MAX)
  40. IF @category = 'user'
  41. BEGIN
  42. DECLARE @branchList TABLE (branchId INT)
  43. IF @param1 IS NULL
  44. BEGIN
  45. INSERT INTO @branchList
  46. SELECT agentId
  47. FROM agentMaster
  48. WHERE agentType = '2904'
  49. AND parentId = @param2
  50. AND ISNULL(isDeleted, 'N') <> 'Y'
  51. AND ISNULL(isActive, 'N') = 'Y'
  52. END
  53. IF @param1 IS NULL
  54. AND @param2 IS NULL
  55. BEGIN
  56. SELECT TOP 20 userID
  57. ,userName
  58. FROM applicationUsers
  59. WHERE userName LIKE ISNULL(@searchText, '') + '%'
  60. AND ISNULL(isDeleted, 'N') <> 'Y'
  61. AND ISNULL(isActive, 'N') = 'Y'
  62. ORDER BY userName ASC
  63. RETURN
  64. END
  65. IF @param1 IS NOT NULL
  66. AND @param2 IS NOT NULL
  67. BEGIN
  68. INSERT INTO @branchList
  69. SELECT @param1
  70. END
  71. SELECT TOP 20 userID
  72. ,userName
  73. FROM applicationUsers
  74. WHERE userName LIKE ISNULL(@searchText, '') + '%'
  75. AND agentId IN (
  76. SELECT branchId
  77. FROM @branchList
  78. )
  79. ORDER BY userName ASC
  80. RETURN
  81. END
  82. IF @category = 'menuSearchAdmin'
  83. BEGIN
  84. IF @param1 = 'admin'
  85. BEGIN
  86. SELECT TOP 20 linkPage
  87. ,menuName
  88. FROM dbo.applicationMenus WITH (NOLOCK)
  89. WHERE
  90. menuName LIKE ISNULL(@searchText, '') + '%'
  91. END
  92. ELSE
  93. BEGIN
  94. SELECT TOP 20 AM.linkPage
  95. ,AM.menuName
  96. FROM dbo.applicationUserRoles AR WITH (NOLOCK)
  97. INNER JOIN dbo.applicationRoleFunctions AF WITH (NOLOCK) ON AF.roleId = AR.roleId
  98. INNER JOIN dbo.applicationMenus AM WITH (NOLOCK) ON AM.functionId = AF.functionId
  99. INNER JOIN dbo.applicationUsers AU WITH (NOLOCK) ON AU.userId = AR.userId
  100. WHERE AU.userName = @param1
  101. AND AM.AgentMenuGroup IS NULL
  102. AND menuName LIKE ISNULL(@searchText, '') + '%';
  103. END
  104. END
  105. IF @category = 'agentRatingList'
  106. BEGIN
  107. SELECT TOP 20 agentId
  108. ,agentName
  109. FROM agentlistriskprofile
  110. WHERE agentName LIKE ISNULL(@searchText, '') + '%'
  111. ORDER BY agentName ASC
  112. RETURN
  113. END
  114. IF @category = 'menuSearchAgent'
  115. BEGIN
  116. SELECT TOP 20 AM.linkPage
  117. ,AM.menuName
  118. FROM dbo.applicationUserRoles AR WITH (NOLOCK)
  119. INNER JOIN dbo.applicationRoleFunctions AF WITH (NOLOCK) ON AF.roleId = AR.roleId
  120. INNER JOIN dbo.applicationMenus AM WITH (NOLOCK) ON AM.functionId = AF.functionId
  121. INNER JOIN dbo.applicationUsers AU WITH (NOLOCK) ON AU.userId = AR.userId
  122. WHERE AU.userName = @param1
  123. AND AM.AgentMenuGroup IS NOT NULL
  124. AND menuName LIKE ISNULL(@searchText, '') + '%';
  125. END
  126. IF @category = 'users'
  127. BEGIN
  128. IF @param1 IS NOT NULL
  129. BEGIN
  130. SELECT TOP 20 userID
  131. ,userName
  132. FROM applicationUsers WITH (NOLOCK)
  133. WHERE userName LIKE ISNULL(@searchText, '') + '%'
  134. AND agentId = @param1
  135. AND ISNULL(isDeleted, 'N') <> 'Y'
  136. AND ISNULL(isActive, 'N') = 'Y'
  137. ORDER BY userName ASC
  138. RETURN
  139. END
  140. SELECT TOP 20 userID
  141. ,userName
  142. FROM applicationUsers WITH (NOLOCK)
  143. WHERE userName LIKE ISNULL(@searchText, '') + '%'
  144. AND ISNULL(isDeleted, 'N') <> 'Y'
  145. AND ISNULL(isActive, 'N') = 'Y'
  146. ORDER BY userName ASC
  147. RETURN
  148. END
  149. IF @category = 'country'
  150. BEGIN
  151. SELECT TOP 20 countryId
  152. ,countryName
  153. FROM countryMaster
  154. WHERE countryName LIKE ISNULL(@searchText, '') + '%'
  155. AND ISNULL(isOperativeCountry, '') = 'Y'
  156. ORDER BY countryName ASC
  157. RETURN
  158. END
  159. IF @category = 'countryOp'
  160. BEGIN
  161. SELECT TOP 20 countryId
  162. ,countryName
  163. FROM countryMaster
  164. WHERE countryName LIKE ISNULL(@searchText, '') + '%'
  165. ORDER BY countryName ASC
  166. RETURN
  167. END
  168. IF @category = 'countrySend'
  169. BEGIN
  170. SELECT TOP 20 countryId
  171. ,countryName
  172. FROM countryMaster
  173. WHERE countryName LIKE ISNULL(@searchText, '') + '%'
  174. AND ISNULL(isOperativeCountry, '') = 'Y'
  175. AND ISNULL(operationType, 'B') IN (
  176. 'B'
  177. ,'S'
  178. ,'R'
  179. )
  180. ORDER BY countryName ASC
  181. RETURN
  182. END
  183. IF @category = 'countryPay'
  184. BEGIN
  185. SELECT TOP 20 countryId
  186. ,countryName
  187. FROM countryMaster
  188. WHERE countryName LIKE ISNULL(@searchText, '') + '%'
  189. AND ISNULL(isOperativeCountry, '') = 'Y'
  190. AND ISNULL(operationType, 'B') IN (
  191. 'B'
  192. ,'R'
  193. )
  194. ORDER BY countryName ASC
  195. RETURN
  196. END
  197. IF @category = 'branch'
  198. BEGIN
  199. SELECT TOP 20 agentId
  200. ,agentName
  201. FROM agentMaster
  202. WHERE agentType = '2904'
  203. AND parentId = @param1
  204. AND ISNULL(isDeleted, 'N') <> 'Y'
  205. AND agentName LIKE ISNULL(@searchText, '') + '%'
  206. ORDER BY agentName ASC
  207. RETURN
  208. END
  209. IF @category = 'branchExt' -- branch filter external or internal
  210. BEGIN
  211. IF RIGHT(@param1, 1) = 'I'
  212. BEGIN
  213. SELECT TOP 20 agentId
  214. ,agentName
  215. FROM agentMaster
  216. WHERE agentType = '2904'
  217. AND parentId = LEFT(@param1, LEN(@param1) - 1)
  218. AND ISNULL(isDeleted, 'N') <> 'Y'
  219. AND agentName LIKE ISNULL(@searchText, '') + '%'
  220. ORDER BY agentName ASC
  221. RETURN
  222. END
  223. IF RIGHT(@param1, 1) = 'E'
  224. BEGIN
  225. SELECT TOP 20 ebb.extBranchId agentId
  226. ,branchName agentName
  227. FROM externalBank eb
  228. LEFT JOIN externalBankBranch ebb ON eb.extBankId = ebb.extbankid
  229. WHERE eb.extBankId = LEFT(@param1, LEN(@param1) - 1)
  230. AND ebb.branchName LIKE ISNULL(@searchText, '') + '%'
  231. ORDER BY branchName
  232. RETURN
  233. END
  234. END
  235. IF @category = 'agentWiseUser' -- --@author:bibash; Select branch user according to the branch parent
  236. BEGIN
  237. IF @param1 IS NOT NULL
  238. AND @param2 IS NULL
  239. BEGIN
  240. SELECT TOP 20 userID
  241. ,userName
  242. FROM applicationUsers au WITH (NOLOCK)
  243. INNER JOIN agentMaster am WITH (NOLOCK) ON am.agentId = au.agentId
  244. WHERE userName LIKE ISNULL(@searchText, '') + '%'
  245. AND am.parentId = @param1
  246. AND ISNULL(au.isDeleted, 'N') <> 'Y'
  247. AND ISNULL(au.isActive, 'N') = 'Y'
  248. ORDER BY userName ASC
  249. RETURN
  250. END
  251. ELSE IF @param2 IS NOT NULL
  252. AND @param1 IS NULL
  253. BEGIN
  254. SELECT TOP 20 userID
  255. ,userName
  256. FROM applicationUsers au WITH (NOLOCK)
  257. INNER JOIN agentMaster am WITH (NOLOCK) ON am.agentId = au.agentId
  258. WHERE userName LIKE ISNULL(@searchText, '') + '%'
  259. AND am.agentCountryId = @param2
  260. AND ISNULL(au.isDeleted, 'N') <> 'Y'
  261. AND ISNULL(au.isActive, 'N') = 'Y'
  262. ORDER BY userName ASC
  263. RETURN
  264. END
  265. ELSE
  266. BEGIN
  267. SELECT TOP 20 userID
  268. ,userName
  269. FROM applicationUsers au WITH (NOLOCK)
  270. INNER JOIN agentMaster am WITH (NOLOCK) ON am.agentId = au.agentId
  271. WHERE userName LIKE ISNULL(@searchText, '') + '%'
  272. AND am.parentId = @param1
  273. AND am.agentCountryId = @param2
  274. AND ISNULL(au.isDeleted, 'N') <> 'Y'
  275. AND ISNULL(au.isActive, 'N') = 'Y'
  276. ORDER BY userName ASC
  277. RETURN
  278. END
  279. END
  280. IF @category = 's-r-agent' -- sending / receiving agent according to sending /receiving country
  281. BEGIN
  282. SELECT TOP 20 agentId
  283. ,agentName
  284. FROM agentMaster
  285. WHERE agentType = '2903'
  286. AND ISNULL(isDeleted, 'N') <> 'Y'
  287. AND agentName LIKE ISNULL(@searchText, '') + '%'
  288. AND agentCountryId = @param1
  289. ORDER BY agentName ASC
  290. RETURN
  291. END
  292. IF @category = 'agent'
  293. BEGIN
  294. SELECT TOP 20 a.agentId
  295. ,agentName agentName
  296. FROM (
  297. SELECT agentId
  298. ,agentName + ISNULL('(' + b.districtName + ')', '') agentName
  299. FROM agentMaster a WITH (NOLOCK)
  300. LEFT JOIN api_districtList b WITH (NOLOCK) ON a.agentLocation = b.districtCode
  301. WHERE
  302. ----(actAsBranch = 'Y' OR agentType = 2904) AND
  303. ISNULL(a.isDeleted, 'N') = 'N'
  304. AND ISNULL(a.isActive, 'N') = 'Y'
  305. AND ISNULL(agentBlock, 'U') <> 'B'
  306. AND a.parentId NOT IN (
  307. 1543
  308. ,5006
  309. )
  310. ) A
  311. WHERE A.agentName LIKE '%' + ISNULL(@searchText, '') + '%'
  312. ORDER BY A.agentName
  313. RETURN
  314. END
  315. IF @category = 'all-agent'
  316. BEGIN
  317. SELECT TOP 20 agentId
  318. ,agentName
  319. FROM agentMaster
  320. WHERE agentName LIKE ISNULL(@searchText, '') + '%'
  321. AND agentCountry = 'Nepal'
  322. AND ISNULL(isDeleted, 'N') = 'N'
  323. AND ISNULL(isActive, 'N') = 'Y'
  324. ORDER BY agentName ASC
  325. RETURN
  326. END
  327. IF @category = 'adminUser'
  328. BEGIN
  329. SELECT TOP 20 userID
  330. ,userName
  331. FROM applicationUsers
  332. WHERE userName LIKE ISNULL(@searchText, '') + '%'
  333. AND userType = 'HO'
  334. ORDER BY userName ASC
  335. RETURN
  336. END
  337. IF @category = 'internalBranch' -- --@author:bibash; Select internal branchName
  338. BEGIN
  339. SELECT TOP 20 branch.agentId
  340. ,branch.agentName
  341. FROM agentMaster agent WITH (NOLOCK)
  342. INNER JOIN agentMaster branch WITH (NOLOCK) ON branch.parentId = agent.agentId
  343. WHERE ISNULL(branch.isDeleted, 'N') <> 'Y'
  344. AND branch.agentType = '2904'
  345. AND agent.isInternal = 'Y'
  346. AND branch.agentName LIKE ISNULL(@searchText, '') + '%'
  347. ORDER BY branch.agentName ASC
  348. RETURN
  349. END
  350. --EXEC proc_autocomplete @category='benBankByCountryName', @searchText='PRIME', @param1='Bangladesh'
  351. IF @category = 'benBankByCountryName' -->> Beneficiary Bank By Country Name
  352. BEGIN
  353. SET @SQL = 'SELECT TOP 20 * FROM
  354. (
  355. SELECT agentId bankId,agentName+'' (Bank)'' BankName
  356. FROM agentMaster WITH(NOLOCK) WHERE agentType=2903 AND agentCountry = ''' + @param1 + '''
  357. UNION ALL
  358. SELECT extBankId bankId,bankName+'' (Ext. Bank)'' BankName
  359. FROM externalBank WITH(NOLOCK) WHERE country = ''' + @param1 + '''
  360. AND isnull(internalCode,'''') NOT IN (SELECT agentid FROM agentMaster WITH(NOLOCK) WHERE agentType=2903 AND agentCountry = ''' + @param1 + ''')
  361. )x WHERE BankName LIKE ''%' + @searchText + '%'''
  362. SET @SQL = @SQL + ' ORDER BY BankName ASC'
  363. PRINT (@SQL);
  364. EXEC (@SQL)
  365. END
  366. IF @category = 'sendAgentByCountryName' -->> Sending Agent By Country Name
  367. BEGIN
  368. SET @SQL = 'SELECT TOP 20 agentId, agentName
  369. FROM agentMaster WITH(NOLOCK)
  370. WHERE agentName LIKE ''%' + @searchText + '%'''
  371. IF @param1 IS NOT NULL
  372. SET @SQL = @SQL + ' AND agentCountry = ''' + @param1 + ''''
  373. SET @SQL = @SQL + ' ORDER BY agentName ASC'
  374. EXEC (@SQL)
  375. END
  376. IF @category = 'value' -- Select Values of ColumnName Accroding to TableName
  377. BEGIN
  378. SET @SQL = 'SELECT TOP 20 ' + @param2 + ' id, ' + @param2 + ' FROM ' + @param1 + ' WITH(NOLOCK) WHERE ' + @param2 + ' LIKE ''' + @searchText + '%'' ORDER BY ''' + @param2 + ''' ASC'
  379. PRINT @SQL
  380. EXEC (@SQL)
  381. RETURN
  382. END
  383. IF @category = 'allBranch' --@author:bibash; Select all branch name
  384. BEGIN
  385. SELECT TOP 20 branch.agentId
  386. ,branch.agentName
  387. FROM agentMaster agent WITH (NOLOCK)
  388. INNER JOIN agentMaster branch WITH (NOLOCK) ON branch.parentId = agent.agentId
  389. WHERE ISNULL(branch.isDeleted, 'N') <> 'Y'
  390. AND branch.agentType = '2904'
  391. AND branch.agentName LIKE ISNULL(@searchText, '') + '%'
  392. ORDER BY branch.agentName ASC
  393. RETURN
  394. END
  395. IF @category = 'pbranchByAgent' -- Select branchName List According to AgentName By pralhad
  396. BEGIN
  397. DECLARE @branchSelection VARCHAR(50)
  398. SELECT @branchSelection = ISNULL(branchSelection, 'A')
  399. FROM receiveTranLimit
  400. WHERE agentId = @param1
  401. SELECT TOP 20 agentId [serviceTypeId]
  402. ,agentName [typeTitle]
  403. ,@branchSelection [branchSelection]
  404. FROM agentMaster am WITH (NOLOCK)
  405. WHERE ISNULL(am.isDeleted, 'N') <> 'Y'
  406. AND am.agentType = '2904'
  407. AND am.parentId = @param1
  408. AND agentName LIKE @searchText + '%'
  409. ORDER BY agentName ASC
  410. RETURN
  411. END
  412. IF @category = 'internalAgentByExtBankId' -->> Selecting Agent by External Bank Id
  413. BEGIN
  414. DECLARE @countryId INT
  415. ,@countryName AS VARCHAR(200)
  416. SELECT @countryName = country
  417. FROM externalBank WITH (NOLOCK)
  418. WHERE extBankId = @param1
  419. SELECT @countryId = countryId
  420. FROM countryMaster WITH (NOLOCK)
  421. WHERE countryName = @countryName
  422. SELECT a.agentId
  423. ,a.agentName
  424. FROM agentMaster a WITH (NOLOCK)
  425. INNER JOIN (
  426. SELECT agentId
  427. FROM receiveTranLimit WITH (NOLOCK)
  428. WHERE countryId = ISNULL(@countryId, countryId)
  429. AND tranType = '3'
  430. ) b ON a.agentId = b.agentId
  431. WHERE ISNULL(a.isDeleted, 'N') <> 'Y'
  432. AND a.agentName LIKE ISNULL(@searchText, '') + '%'
  433. RETURN
  434. END
  435. IF @category = 'agent-a'
  436. BEGIN
  437. SELECT TOP 20 am.agentId
  438. ,am.agentName
  439. ,am.agentLocation
  440. ,am.agentCountry
  441. ,COALESCE(am.agentMobile1, am.agentMobile2, am.agentPhone1, am.agentPhone2) Phone
  442. ,pa.agentName parentName
  443. FROM agentMaster am WITH (NOLOCK)
  444. LEFT JOIN agentMaster pa WITH (NOLOCK) ON am.parentId = pa.agentId
  445. WHERE am.agentId = @searchText
  446. RETURN
  447. END
  448. IF @category = 'allBank'
  449. BEGIN
  450. SELECT TOP 20 bankId = extBankId
  451. ,bankName
  452. FROM externalBank
  453. WHERE internalCode IS NOT NULL
  454. RETURN
  455. END
  456. IF @category = 'ime-private-agent'
  457. BEGIN
  458. --SELECT TOP 20 a.agentId,agentName+'|'+CAST(agentId AS VARCHAR) agentName
  459. --FROM
  460. --(
  461. -- SELECT agentId,agentName+' '+b.districtName agentName
  462. -- FROM agentMaster a WITH(NOLOCK)
  463. -- LEFT JOIN api_districtList b WITH(NOLOCK) ON a.agentLocation=b.districtCode
  464. -- WHERE actAsBranch = 'Y'
  465. -- AND agentType = 2903
  466. -- AND ISNULL(a.isDeleted, 'N') = 'N'
  467. -- --AND ISNULL(a.isActive, 'N') = 'Y'
  468. -- OR (agentType = 2904 and parentId = 4618)
  469. -- OR (agentType = 2904 and parentId = 21107)
  470. -- OR (agentType = 2904 and parentId = 22194)
  471. -- OR a.agentId = 1194
  472. -- --OR (a.agentId = 20653)
  473. -- OR (agentType = 2904)
  474. --)A WHERE A.agentName LIKE '%'+@searchText+'%' ORDER BY A.agentName
  475. SELECT TOP 20 a.agentId
  476. ,agentName + '|' + CAST(agentId AS VARCHAR) agentName
  477. FROM (
  478. SELECT agentId
  479. ,agentName + ' ' + b.districtName agentName
  480. FROM agentMaster a WITH (NOLOCK)
  481. LEFT JOIN api_districtList b WITH (NOLOCK) ON a.agentLocation = b.districtCode
  482. WHERE agentGrp <> '4301'
  483. AND ISNULL(a.isDeleted, 'N') = 'N'
  484. AND (
  485. (
  486. agentType = 2903
  487. AND actAsBranch = 'Y'
  488. )
  489. OR agentType = 2904
  490. )
  491. ) A
  492. WHERE A.agentName LIKE '%' + @searchText + '%'
  493. ORDER BY A.agentName
  494. END
  495. IF @category = 'domestic-agent'
  496. BEGIN
  497. SELECT TOP 20 a.agentId
  498. ,agentName + '|' + CAST(agentId AS VARCHAR) agentName
  499. FROM (
  500. SELECT agentId
  501. ,agentName + ' ' + b.districtName agentName
  502. FROM agentMaster a WITH (NOLOCK)
  503. LEFT JOIN api_districtList b WITH (NOLOCK) ON a.agentLocation = b.districtCode
  504. WHERE agentType = 2903
  505. AND ISNULL(a.isDeleted, 'N') = 'N'
  506. AND ISNULL(a.isActive, 'N') = 'Y'
  507. ) A
  508. WHERE A.agentName LIKE '%' + @searchText + '%'
  509. ORDER BY A.agentName
  510. END
  511. IF @category = 'CountryAgentLogin'
  512. BEGIN
  513. SELECT TOP 20 agentId
  514. ,agentName
  515. FROM agentMaster
  516. WHERE agentName LIKE ISNULL(@searchText, '') + '%'
  517. AND agentCountryId = @param1
  518. AND ISNULL(isDeleted, 'N') = 'N'
  519. AND ISNULL(isActive, 'N') = 'Y'
  520. ORDER BY agentName ASC
  521. RETURN
  522. END
  523. IF @category = 'CountryAgentTxn'
  524. BEGIN
  525. SELECT TOP 20 agentId
  526. ,agentName
  527. FROM agentMaster
  528. WHERE agentName LIKE ISNULL(@searchText, '') + '%'
  529. AND agentCountry = @param1
  530. AND ISNULL(isDeleted, 'N') = 'N'
  531. AND ISNULL(isActive, 'N') = 'Y'
  532. ORDER BY agentName ASC
  533. RETURN
  534. END
  535. IF @category = 'AgentUser'
  536. BEGIN
  537. SELECT TOP 20 userId
  538. ,userName
  539. FROM applicationUsers
  540. WHERE userName LIKE ISNULL(@searchText, '') + '%'
  541. AND agentId = @param1
  542. AND ISNULL(isDeleted, 'N') = 'N'
  543. AND ISNULL(isActive, 'N') = 'Y'
  544. ORDER BY userName ASC
  545. RETURN
  546. END
  547. -------->>>>For transaction Analysis Report--------->>>>
  548. IF @category = 'zoneRpt'
  549. BEGIN
  550. SELECT TOP 20 stateId
  551. ,stateName
  552. FROM countryStateMaster a WITH (NOLOCK)
  553. INNER JOIN countryMaster b WITH (NOLOCK) ON a.countryId = b.countryId
  554. WHERE (
  555. b.countryName = @param1
  556. OR b.countryId = @param1
  557. )
  558. AND stateName LIKE '%' + @searchText + '%'
  559. AND ISNULL(A.isDeleted, 'N') <> 'Y'
  560. ORDER BY stateName
  561. RETURN
  562. END
  563. IF @category = 'districtRpt'
  564. BEGIN
  565. SELECT TOP 20 districtId
  566. ,districtName
  567. FROM zoneDistrictMap WITH (NOLOCK)
  568. WHERE zone = isnull(@param1, zone)
  569. AND ISNULL(isDeleted, 'N') <> 'Y'
  570. AND districtName LIKE '%' + @searchText + '%'
  571. ORDER BY districtName
  572. RETURN
  573. END
  574. IF @category = 'locationRpt'
  575. BEGIN
  576. SELECT DISTINCT TOP 20 locationId = districtCode
  577. ,locationName = districtName
  578. FROM api_districtList adl WITH (NOLOCK)
  579. LEFT JOIN apiLocationMapping alm WITH (NOLOCK) ON adl.districtCode = alm.apiDistrictCode
  580. WHERE ISNULL(isDeleted, 'N') = 'N'
  581. AND ISNULL(adl.isActive, 'Y') = 'Y'
  582. AND alm.districtId = ISNULL(@param1, alm.districtId)
  583. AND districtName LIKE '%' + @searchText + '%'
  584. ORDER BY districtName
  585. RETURN
  586. END
  587. IF @category = 'agentRpt'
  588. BEGIN
  589. SELECT TOP 20 agentId
  590. ,agentName
  591. FROM agentMaster WITH (NOLOCK)
  592. WHERE agentType = 2903
  593. AND agentCountry = 'Nepal'
  594. AND ISNULL(isDeleted, 'N') <> 'Y'
  595. --AND ISNULL(isActive, 'N') = 'Y'
  596. AND ISNULL(agentBlock, 'U') <> 'B'
  597. AND agentName LIKE '%' + @searchText + '%'
  598. AND agentGrp = isnull(@param1, agentGrp)
  599. ORDER BY agentName
  600. RETURN
  601. END
  602. IF @category = 'agentdistRpt'
  603. BEGIN
  604. SELECT TOP 20 agentId
  605. ,agentName
  606. FROM agentMaster WITH (NOLOCK)
  607. WHERE agentType = 2903
  608. AND agentCountry = 'Nepal'
  609. AND ISNULL(isDeleted, 'N') <> 'Y'
  610. --AND ISNULL(isActive, 'N') = 'Y'
  611. AND ISNULL(agentBlock, 'U') <> 'B'
  612. AND agentName LIKE '%' + @searchText + '%'
  613. AND agentDistrict = isnull(@param1, agentDistrict)
  614. ORDER BY agentName
  615. RETURN
  616. END
  617. IF @category = 'branchRpt'
  618. BEGIN
  619. SELECT TOP 20 agentId
  620. ,agentName
  621. FROM agentMaster WITH (NOLOCK)
  622. WHERE parentId = @param1
  623. AND agentName LIKE '%' + @searchText + '%'
  624. AND ISNULL(agentBlock, 'U') <> 'B'
  625. RETURN
  626. END
  627. IF @category = 'countryRptInt'
  628. BEGIN
  629. SELECT TOP 20 countryId
  630. ,countryName
  631. FROM countryMaster WITH (NOLOCK)
  632. WHERE countryName LIKE '%' + @searchText + '%'
  633. RETURN
  634. END
  635. IF @category = 'agentRptInt'
  636. BEGIN
  637. SELECT TOP 20 agentId
  638. ,agentName
  639. FROM agentMaster
  640. WHERE ISNULL(isSettlingAgent, 'N') = 'Y'
  641. AND ISNULL(isDeleted, 'N') <> 'Y'
  642. --AND ISNULL(isActive, 'N') = 'Y'
  643. AND ISNULL(agentBlock, 'U') <> 'B'
  644. AND agentName LIKE '%' + @searchText + '%'
  645. AND (
  646. agentCountry <> 'Nepal'
  647. OR agentId = 4734
  648. )
  649. AND agentCountryId = isnull(@param1, agentCountryId)
  650. ORDER BY agentName
  651. RETURN
  652. END
  653. IF @category = 'branchRptInt'
  654. BEGIN
  655. SELECT TOP 20 agentId
  656. ,agentName
  657. FROM agentMaster WITH (NOLOCK)
  658. WHERE parentId = @param1
  659. AND agentName LIKE '%' + @searchText + '%'
  660. AND parentId = @param1
  661. --AND ISNULL(isDeleted, 'N') <> 'Y'
  662. AND ISNULL(isActive, 'N') = 'Y'
  663. AND ISNULL(agentBlock, 'U') <> 'B'
  664. RETURN
  665. END
  666. IF @category = 'send-agent'
  667. BEGIN
  668. SELECT TOP 20 map_code
  669. ,agent_name
  670. FROM FastMoneyPro_account.dbo.agentTable WITH (NOLOCK)
  671. WHERE agent_status <> 'n'
  672. AND AGENT_TYPE = 'receiving'
  673. AND (
  674. IsMainAgent = 'y'
  675. OR ISNULL(central_sett, 'n') = 'n'
  676. )
  677. AND agent_name LIKE '%' + @searchText + '%'
  678. ORDER BY agent_name
  679. RETURN
  680. END
  681. IF @category = 'agentSummBal' -->>Agent summary Balance Rpt Ddl
  682. BEGIN
  683. SELECT TOP 20 mapcodeInt
  684. ,agentName
  685. FROM agentMaster am WITH (NOLOCK)
  686. WHERE agentName LIKE '%' + @searchText + '%'
  687. AND mapcodeInt IS NOT NULL
  688. AND ISNULL(agentBlock, 'U') <> 'B'
  689. ORDER BY agentName ASC
  690. RETURN
  691. END
  692. IF @category = 'd-agentname-only'
  693. BEGIN
  694. SELECT TOP 20 agentName
  695. FROM agentMaster a WITH (NOLOCK)
  696. WHERE agentCountry = 'Nepal'
  697. AND (
  698. actAsBranch = 'Y'
  699. OR agentType = 2904
  700. )
  701. AND ISNULL(a.isDeleted, 'N') = 'N'
  702. --AND ISNULL(a.isActive, 'N') = 'Y'
  703. AND ISNULL(agentBlock, 'U') <> 'B'
  704. AND A.agentName LIKE '%' + @searchText + '%'
  705. ORDER BY A.agentName
  706. END
  707. IF @category = 'd-agent-only'
  708. BEGIN
  709. SELECT TOP 20 a.agentId
  710. ,agentName
  711. FROM (
  712. SELECT agentId
  713. ,agentName + ' ' + b.districtName agentName
  714. FROM agentMaster a WITH (NOLOCK)
  715. LEFT JOIN api_districtList b WITH (NOLOCK) ON a.agentLocation = b.districtCode
  716. WHERE agentCountry = 'Nepal'
  717. AND (
  718. actAsBranch = 'Y'
  719. OR agentType = 2904
  720. )
  721. AND ISNULL(a.isDeleted, 'N') = 'N'
  722. --AND ISNULL(a.isActive, 'N') = 'Y'
  723. AND ISNULL(agentBlock, 'U') <> 'B'
  724. ) A
  725. WHERE A.agentName LIKE '%' + @searchText + '%'
  726. ORDER BY A.agentName
  727. END
  728. ---->>>>>For Customer report
  729. IF @category = 'sAgent'
  730. BEGIN
  731. SELECT TOP 20 agentId
  732. ,agentName
  733. FROM agentMaster WITH (NOLOCK)
  734. WHERE agentType = 2903
  735. AND agentCountry = 'Nepal'
  736. AND ISNULL(isDeleted, 'N') <> 'Y'
  737. --AND ISNULL(isActive, 'N') = 'Y'
  738. AND ISNULL(agentBlock, 'U') <> 'B'
  739. AND agentName LIKE '%' + @searchText + '%'
  740. AND agentState = isnull(@param1, agentState)
  741. ORDER BY agentName
  742. RETURN
  743. END
  744. IF @category = 'sZone'
  745. BEGIN
  746. SELECT TOP 20 stateId
  747. ,stateName
  748. FROM countryStateMaster a WITH (NOLOCK)
  749. INNER JOIN countryMaster b WITH (NOLOCK) ON a.countryId = b.countryId
  750. WHERE (
  751. b.countryName = 'Nepal'
  752. OR b.countryId = 151
  753. )
  754. AND ISNULL(A.isDeleted, 'N') <> 'Y'
  755. AND stateName LIKE '%' + @searchText + '%'
  756. ORDER BY stateName
  757. END
  758. IF @category = 'send-agent-regional'
  759. BEGIN
  760. SELECT TOP 20 map_code
  761. ,agent_name
  762. FROM FastMoneyPro_account.dbo.agentTable at WITH (NOLOCK)
  763. INNER JOIN userZoneMapping zp WITH (NOLOCK) ON at.agentZone = zp.zoneName
  764. WHERE agent_status <> 'n'
  765. AND AGENT_TYPE = 'receiving'
  766. AND (
  767. IsMainAgent = 'y'
  768. OR ISNULL(central_sett, 'n') = 'n'
  769. )
  770. AND zp.userName = @param1
  771. AND agent_name LIKE '%' + @searchText + '%'
  772. AND zp.isDeleted IS NULL
  773. ORDER BY agent_name
  774. RETURN
  775. END
  776. -- ## regional transaction analysis report
  777. IF @category = 'zone-r-rpt'
  778. BEGIN
  779. SELECT TOP 20 stateId
  780. ,stateName
  781. FROM countryStateMaster a WITH (NOLOCK)
  782. INNER JOIN countryMaster b WITH (NOLOCK) ON a.countryId = b.countryId
  783. INNER JOIN dbo.userZoneMapping zm WITH (NOLOCK) ON a.stateName = zm.zoneName
  784. WHERE (
  785. b.countryName = @param1
  786. OR b.countryId = @param1
  787. )
  788. AND stateName LIKE '%' + @searchText + '%'
  789. AND ISNULL(A.isDeleted, 'N') <> 'Y'
  790. AND zm.userName = @param2
  791. AND zm.isDeleted IS NULL
  792. ORDER BY stateName
  793. RETURN
  794. END
  795. IF @category = 'district-r-rpt'
  796. BEGIN
  797. SELECT TOP 20 districtId
  798. ,districtName
  799. FROM zoneDistrictMap d WITH (NOLOCK)
  800. INNER JOIN countryStateMaster z WITH (NOLOCK) ON d.zone = z.stateId
  801. INNER JOIN dbo.userZoneMapping zm WITH (NOLOCK) ON z.stateName = zm.zoneName
  802. WHERE d.zone = isnull(@param1, d.zone)
  803. AND ISNULL(d.isDeleted, 'N') <> 'Y'
  804. AND d.districtName LIKE '%' + @searchText + '%'
  805. AND zm.userName = @param2
  806. AND zm.isDeleted IS NULL
  807. ORDER BY districtName
  808. RETURN
  809. END
  810. IF @category = 'location-r-rpt'
  811. BEGIN
  812. SELECT DISTINCT locationId = adl.districtCode
  813. ,locationName = adl.districtName
  814. FROM api_districtList adl WITH (NOLOCK)
  815. LEFT JOIN apiLocationMapping alm WITH (NOLOCK) ON adl.districtCode = alm.apiDistrictCode
  816. LEFT JOIN zoneDistrictMap d WITH (NOLOCK) ON alm.districtId = d.districtId
  817. LEFT JOIN countryStateMaster z WITH (NOLOCK) ON d.zone = z.stateId
  818. LEFT JOIN dbo.userZoneMapping zm WITH (NOLOCK) ON z.stateName = zm.zoneName
  819. WHERE ISNULL(adl.isDeleted, 'N') = 'N'
  820. AND ISNULL(adl.isActive, 'Y') = 'Y'
  821. AND alm.districtId = ISNULL(@param1, alm.districtId)
  822. AND adl.districtName LIKE '%' + @searchText + '%'
  823. AND zm.userName = @param2
  824. AND zm.isDeleted IS NULL
  825. ORDER BY adl.districtName
  826. RETURN
  827. END
  828. IF @category = 'agent-r-rpt'
  829. BEGIN
  830. SELECT TOP 20 agentId
  831. ,agentName
  832. FROM agentMaster am WITH (NOLOCK)
  833. INNER JOIN dbo.userZoneMapping zm WITH (NOLOCK) ON am.agentState = zm.zoneName
  834. WHERE agentType = 2903
  835. AND agentCountry = 'Nepal'
  836. AND ISNULL(am.isDeleted, 'N') <> 'Y'
  837. AND ISNULL(agentBlock, 'U') <> 'B'
  838. AND agentName LIKE '%' + @searchText + '%'
  839. AND agentLocation = isnull(@param1, agentLocation)
  840. AND zm.userName = @param2
  841. AND zm.isDeleted IS NULL
  842. ORDER BY agentName
  843. RETURN
  844. END
  845. IF @category = 'branch-r-rpt'
  846. BEGIN
  847. SELECT TOP 20 agentId
  848. ,agentName
  849. FROM agentMaster am WITH (NOLOCK)
  850. INNER JOIN dbo.userZoneMapping zm WITH (NOLOCK) ON am.agentState = zm.zoneName
  851. WHERE am.parentId = @param1
  852. AND am.agentName LIKE '%' + @searchText + '%'
  853. AND ISNULL(am.isDeleted, 'N') <> 'Y'
  854. AND ISNULL(agentBlock, 'U') <> 'B'
  855. AND zm.userName = @param2
  856. AND zm.isDeleted IS NULL
  857. RETURN
  858. END
  859. IF @category = 'ext-bank'
  860. BEGIN
  861. SELECT TOP 20 bankId = extBankId
  862. ,bankName
  863. FROM externalBank ext
  864. WHERE ext.internalCode IS NOT NULL
  865. AND ISNULL(ext.isBlocked, 'N') <> 'Y'
  866. AND ISNULL(ext.isDeleted, 'N') <> 'Y'
  867. AND ext.bankName LIKE '%' + @searchText + '%'
  868. RETURN
  869. END
  870. IF @category = 'agent-sett'
  871. BEGIN
  872. SELECT TOP 20 am.agentId
  873. ,am.agentName
  874. FROM agentMaster am WITH (NOLOCK)
  875. WHERE ISNULL(am.isDeleted, 'N') <> 'Y'
  876. AND ISNULL(am.isActive, 'N') = 'Y'
  877. AND agentName LIKE '%' + @searchText + '%'
  878. AND agentType IN (2903)
  879. AND agentCountry = 'Nepal'
  880. ORDER BY agentName
  881. RETURN
  882. END
  883. IF @category = 'agentList'
  884. BEGIN
  885. SELECT TOP 20 agentId
  886. ,agentName
  887. FROM agentMaster am WITH (NOLOCK)
  888. WHERE agentName LIKE '%' + @searchText + '%'
  889. AND ISNULL(apiAgent, 'N') = 'N'
  890. AND ISNULL(ISACTIVE, 'Y') = 'Y'
  891. AND ISNULL(ISDELETED, 'N') = 'N'
  892. RETURN
  893. END
  894. IF @category = 'zoneagendistrictRpt'
  895. BEGIN
  896. IF @param1 IS NOT NULL
  897. AND @param2 IS NULL
  898. BEGIN
  899. SELECT TOP 20 agentId
  900. ,agentName
  901. FROM agentMaster WITH (NOLOCK)
  902. WHERE (
  903. agentType = '2904'
  904. OR (
  905. agentType = 2903
  906. AND actAsBranch = 'Y'
  907. )
  908. )
  909. AND agentCountry = 'Nepal'
  910. AND ISNULL(isDeleted, 'N') <> 'Y'
  911. --AND ISNULL(isActive, 'N') = 'Y'
  912. AND ISNULL(agentBlock, 'U') <> 'B'
  913. AND agentName LIKE '%' + @searchText + '%'
  914. AND agentState = isnull(@param1, agentState)
  915. ORDER BY agentName
  916. RETURN
  917. END
  918. IF @param2 IS NOT NULL
  919. AND @param1 IS NULL
  920. BEGIN
  921. SELECT TOP 20 agentId
  922. ,agentName
  923. FROM agentMaster WITH (NOLOCK)
  924. WHERE (
  925. agentType = '2904'
  926. OR (
  927. agentType = 2903
  928. AND actAsBranch = 'Y'
  929. )
  930. )
  931. AND agentCountry = 'Nepal'
  932. AND ISNULL(isDeleted, 'N') <> 'Y'
  933. --AND ISNULL(isActive, 'N') = 'Y'
  934. AND ISNULL(agentBlock, 'U') <> 'B'
  935. AND agentName LIKE '%' + @searchText + '%'
  936. AND agentDistrict = isnull(@param2, agentDistrict)
  937. ORDER BY agentName
  938. RETURN
  939. END
  940. IF @param1 IS NOT NULL
  941. AND @param2 IS NOT NULL
  942. BEGIN
  943. SELECT TOP 20 agentId
  944. ,agentName
  945. FROM agentMaster WITH (NOLOCK)
  946. WHERE (
  947. agentType = '2904'
  948. OR (
  949. agentType = 2903
  950. AND actAsBranch = 'Y'
  951. )
  952. )
  953. AND agentCountry = 'Nepal'
  954. AND ISNULL(isDeleted, 'N') <> 'Y'
  955. --AND ISNULL(isActive, 'N') = 'Y'
  956. AND ISNULL(agentBlock, 'U') <> 'B'
  957. AND agentName LIKE '%' + @searchText + '%'
  958. AND agentState = isnull(@param1, agentState)
  959. AND agentDistrict = isnull(@param2, agentDistrict)
  960. ORDER BY agentName
  961. RETURN
  962. END
  963. SELECT TOP 20 agentId
  964. ,agentName
  965. FROM agentMaster WITH (NOLOCK)
  966. WHERE (
  967. agentType = '2904'
  968. OR (
  969. agentType = 2903
  970. AND actAsBranch = 'Y'
  971. )
  972. )
  973. AND agentCountry = 'Nepal'
  974. AND ISNULL(isDeleted, 'N') <> 'Y'
  975. --AND ISNULL(isActive, 'N') = 'Y'
  976. AND ISNULL(agentBlock, 'U') <> 'B'
  977. AND agentName LIKE '%' + @searchText + '%'
  978. ORDER BY agentName
  979. END
  980. IF @category = 'cooperative'
  981. BEGIN
  982. SELECT TOP 20 agentId
  983. ,agentName
  984. ,agentType
  985. FROM agentMaster(NOLOCK)
  986. WHERE (
  987. agentGrp = '8026'
  988. OR agentGrp = '9906'
  989. )
  990. AND agentType = '2903'
  991. AND ISNULL(isDeleted, 'N') <> 'Y'
  992. AND agentName LIKE '%' + @searchText + '%'
  993. AND agentId <> @param1
  994. ORDER BY agentName ASC
  995. END
  996. IF @category = 'co-agent' -- cooperative branch list
  997. BEGIN
  998. IF EXISTS (
  999. SELECT 'x'
  1000. FROM agentMaster(NOLOCK)
  1001. WHERE ISNULL(isDeleted, 'N') <> 'Y'
  1002. AND parentId = @param1
  1003. )
  1004. BEGIN
  1005. SELECT TOP 20 agentId
  1006. ,agentName
  1007. ,agentType
  1008. ,parentId
  1009. FROM agentMaster(NOLOCK)
  1010. WHERE ISNULL(isDeleted, 'N') <> 'Y'
  1011. AND parentId = @param1
  1012. ORDER BY agentName ASC
  1013. RETURN
  1014. END
  1015. ELSE
  1016. BEGIN
  1017. SELECT TOP 20 agentId
  1018. ,agentName
  1019. ,agentType
  1020. ,parentId
  1021. FROM agentMaster(NOLOCK)
  1022. WHERE ISNULL(isDeleted, 'N') <> 'Y'
  1023. AND agentId = @param1
  1024. ORDER BY agentName ASC
  1025. RETURN
  1026. END
  1027. END
  1028. IF @category = 'Reconcil-agent'
  1029. BEGIN
  1030. SELECT TOP 20 agentId
  1031. ,agentName + '|' + CAST(agentId AS VARCHAR)
  1032. FROM agentMaster(NOLOCK)
  1033. WHERE ISNULL(isDeleted, 'N') <> 'Y'
  1034. AND agentName LIKE '%' + @searchText + '%'
  1035. ORDER BY agentName ASC
  1036. END
  1037. ELSE IF @category = 'agentByGrp'
  1038. BEGIN
  1039. SELECT TOP 20 agentId
  1040. ,agentName
  1041. FROM dbo.agentMaster(NOLOCK)
  1042. WHERE agentName LIKE @searchText + '%'
  1043. AND agentGrp = @param1
  1044. ORDER BY agentName
  1045. END
  1046. ELSE IF @category = 'locationRpt'
  1047. BEGIN
  1048. SELECT DISTINCT TOP 20 locationId = districtCode
  1049. ,locationName = districtName
  1050. FROM api_districtList adl WITH (NOLOCK)
  1051. LEFT JOIN apiLocationMapping alm WITH (NOLOCK) ON adl.districtCode = alm.apiDistrictCode
  1052. WHERE ISNULL(isDeleted, 'N') = 'N'
  1053. AND ISNULL(adl.isActive, 'Y') = 'Y'
  1054. AND alm.districtId = ISNULL(@param1, alm.districtId)
  1055. AND districtName LIKE '%' + @searchText + '%'
  1056. ORDER BY districtName
  1057. RETURN
  1058. END
  1059. ELSE IF @category = 'cityList'
  1060. BEGIN
  1061. SELECT cityName
  1062. ,cityName
  1063. FROM CityMaster(NOLOCK)
  1064. WHERE cityName LIKE '%' + @searchText + '%'
  1065. END
  1066. ELSE IF @category = 'CustomerInfo'
  1067. BEGIN
  1068. IF len(@searchText) < 2
  1069. BEGIN
  1070. SELECT TOP 35 idNumber
  1071. ,idNumber + ' | ' + fullName
  1072. FROM CustomerMaster(NOLOCK)
  1073. WHERE 1 = 2
  1074. RETURN
  1075. END
  1076. SELECT TOP 35 idNumber
  1077. ,idNumber + ' | ' + fullName + ' | ' + ISNULL(CONVERT(VARCHAR(10), DOB, 121), '') + ' | ' + isnull(mobile, '') + ' | ' + isnull(zipcode, '')
  1078. FROM CustomerMaster(NOLOCK)
  1079. WHERE idNumber LIKE @searchText + '%'
  1080. OR fullName LIKE @searchText + '%'
  1081. END
  1082. ELSE IF @category = 'CustomerEmail'
  1083. BEGIN
  1084. IF len(@searchText) < 2
  1085. BEGIN
  1086. SELECT TOP 35 customerId
  1087. ,email + ' | ' + ISNULL(mobile,'')
  1088. FROM CustomerMaster(NOLOCK)
  1089. WHERE 1 = 2
  1090. RETURN
  1091. END
  1092. SELECT TOP 35 customerId
  1093. ,email + ' | ' + ISNULL(mobile,'')
  1094. FROM CustomerMaster(NOLOCK)
  1095. WHERE email LIKE @searchText + '%'
  1096. END
  1097. ELSE IF @category = 'CustomerInfoWallet'
  1098. BEGIN
  1099. IF len(@searchText) < 2
  1100. BEGIN
  1101. SELECT TOP 35 walletAccountNo
  1102. ,walletAccountNo + ' | ' + fullName
  1103. FROM CustomerMaster(NOLOCK)
  1104. WHERE 1 = 2
  1105. RETURN
  1106. END
  1107. SELECT TOP 35 walletAccountNo
  1108. ,walletAccountNo + ' | ' + fullName
  1109. FROM CustomerMaster(NOLOCK)
  1110. WHERE walletAccountNo LIKE @searchText + '%'
  1111. OR fullName LIKE @searchText + '%'
  1112. END
  1113. IF @category = 'searchCustomer'
  1114. BEGIN
  1115. IF @param1 = 'receiverName'
  1116. BEGIN
  1117. IF LEN(@searchText) < 3
  1118. BEGIN
  1119. SELECT RECEIVERID
  1120. ,FULLNAME
  1121. FROM RECEIVERINFORMATION(NOLOCK)
  1122. WHERE 1 = 2
  1123. RETURN
  1124. END
  1125. SET @SQL = 'SELECT TOP 20 RI.RECEIVERID
  1126. , [detail] = ISNULL(RI.firstName,'''')
  1127. + ISNULL('' '' + RI.middleName,'''')
  1128. + ISNULL('' '' + RI.lastName1,'''')
  1129. + '' [CustomerName:'' + isnull(CM.FULLNAME, '''') + '']
  1130. [CustID: ''+ISNULL(cm.postalcode,cm.membershipId)+'']
  1131. [MOB:'' + isnull(RI.mobile, '''') + ''] ''+ISNULL(''|''+RI.email,'''')
  1132. FROM receiverInformation RI (NOLOCK)
  1133. INNER JOIN CUSTOMERMASTER CM ( NOLOCK) ON CM.CUSTOMERID = RI.CUSTOMERID
  1134. WHERE 1 = 1 '
  1135. SET @SQL += 'AND RI.FULLNAME LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1136. --PRINT @SQL
  1137. EXEC (@SQL)
  1138. END
  1139. ELSE
  1140. BEGIN
  1141. IF LEN(@searchText) < 3
  1142. BEGIN
  1143. SELECT CUSTOMERID
  1144. ,FULLNAME
  1145. FROM customerMaster(NOLOCK)
  1146. WHERE 1 = 2
  1147. RETURN
  1148. END
  1149. SET @SQL = 'SELECT TOP 20 customerId, [detail] = ISNULL(fullName, '''') + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''|''+email,'''') +''[KYC Status:'' + isnull(LawsonCardNo, '''') + '']''
  1150. FROM customerMaster (NOLOCK) WHERE 1 = 1
  1151. and ISNULL(isActive,''Y'')=''Y'' '
  1152. IF @param1 = 'name'
  1153. BEGIN
  1154. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1155. END
  1156. ELSE IF @param1 = 'email'
  1157. BEGIN
  1158. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1159. END
  1160. ELSE IF @param1 = 'membershipId'
  1161. BEGIN
  1162. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1163. END
  1164. ELSE IF @param1 = 'customerId'
  1165. BEGIN
  1166. SET @SQL += 'AND POSTALCODE = ''' + ISNULL(@searchText, '''') + ''''
  1167. END
  1168. ELSE IF @param1 = 'membershipId'
  1169. BEGIN
  1170. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1171. END
  1172. ELSE IF @param1 = 'dob'
  1173. BEGIN
  1174. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1175. END
  1176. ELSE IF @param1 = 'mobile'
  1177. BEGIN
  1178. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1179. END
  1180. ELSE IF @param1 = 'idNumber'
  1181. BEGIN
  1182. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1183. END
  1184. ELSE IF @param1 = 'LawsonCardNo'
  1185. BEGIN
  1186. SET @SQL += 'AND LawsonCardNo LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1187. END
  1188. --PRINT(@SQL)
  1189. EXEC (@SQL)
  1190. END
  1191. END;
  1192. IF @category = 'searchCustomerForKYC'
  1193. BEGIN
  1194. IF LEN(@searchText) < 3
  1195. BEGIN
  1196. SELECT CUSTOMERID
  1197. ,FULLNAME
  1198. FROM customerMaster(NOLOCK)
  1199. WHERE 1 = 2
  1200. RETURN
  1201. END
  1202. SET @SQL = 'SELECT TOP 20 customerId, [detail] = ISNULL(fullName, '''') + '' [ID:'' + ISNULL(postalCode, membershipid) + ''] [MOB:'' + ISNULL(mobile, '''') + ''] [DOB:'' + ISNULL(CONVERT(varchar, DOB, 102), '''') + ''] ''+ISNULL(''|''+email,'''') +''[KYC Status:'' + ISNULL(LawsonCardNo, '''') + '']''
  1203. FROM customerMaster (NOLOCK)
  1204. WHERE 1 = 1
  1205. --AND (approveddate IS NOT NULL )
  1206. AND ISNULL(isActive, ''Y'') = ''Y'' '
  1207. IF @param1 = 'name'
  1208. BEGIN
  1209. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1210. END
  1211. ELSE IF @param1 = 'email'
  1212. BEGIN
  1213. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1214. END
  1215. ELSE IF @param1 = 'membershipId'
  1216. BEGIN
  1217. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1218. END
  1219. ELSE IF @param1 = 'customerId'
  1220. BEGIN
  1221. SET @SQL += 'AND POSTALCODE = ''' + ISNULL(@searchText, '''') + ''''
  1222. END
  1223. ELSE IF @param1 = 'membershipId'
  1224. BEGIN
  1225. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1226. END
  1227. ELSE IF @param1 = 'dob'
  1228. BEGIN
  1229. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1230. END
  1231. ELSE IF @param1 = 'mobile'
  1232. BEGIN
  1233. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1234. END
  1235. ELSE IF @param1 = 'idNumber'
  1236. BEGIN
  1237. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1238. END
  1239. ELSE IF @param1 = 'LawsonCardNo'
  1240. BEGIN
  1241. SET @SQL += 'AND LawsonCardNo LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1242. END
  1243. PRINT(@SQL)
  1244. EXEC (@SQL)
  1245. END
  1246. IF @category = 'searchCustomerDeleteKYC'
  1247. BEGIN
  1248. IF LEN(@searchText) < 3
  1249. BEGIN
  1250. SELECT CUSTOMERID
  1251. ,FULLNAME
  1252. FROM customerMaster(NOLOCK)
  1253. WHERE 1 = 2
  1254. RETURN
  1255. END
  1256. SET @SQL = 'SELECT TOP 20 customerId, [detail] = ISNULL(fullName, '''') + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''|''+email,'''')
  1257. FROM customerMaster (NOLOCK) WHERE 1 = 1'
  1258. IF @param1 = 'name'
  1259. BEGIN
  1260. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1261. END
  1262. ELSE IF @param1 = 'email'
  1263. BEGIN
  1264. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1265. END
  1266. ELSE IF @param1 = 'membershipId'
  1267. BEGIN
  1268. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1269. END
  1270. ELSE IF @param1 = 'customerId'
  1271. BEGIN
  1272. SET @SQL += 'AND POSTALCODE = ''' + ISNULL(@searchText, '''') + ''''
  1273. END
  1274. ELSE IF @param1 = 'membershipId'
  1275. BEGIN
  1276. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1277. END
  1278. ELSE IF @param1 = 'dob'
  1279. BEGIN
  1280. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1281. END
  1282. ELSE IF @param1 = 'mobile'
  1283. BEGIN
  1284. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1285. END
  1286. ELSE IF @param1 = 'idNumber'
  1287. BEGIN
  1288. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1289. END
  1290. --PRINT(@SQL)
  1291. EXEC (@SQL)
  1292. RETURN
  1293. END;
  1294. IF @category = 'searchCustomerFromMobile'
  1295. BEGIN
  1296. IF @param1 = 'receiverName'
  1297. BEGIN
  1298. IF LEN(@searchText) < 3
  1299. BEGIN
  1300. SELECT RECEIVERID
  1301. ,FULLNAME
  1302. FROM RECEIVERINFORMATION(NOLOCK)
  1303. WHERE 1 = 2
  1304. RETURN
  1305. END
  1306. SET @SQL = 'SELECT TOP 20 RI.RECEIVERID, [detail] = ISNULL(RI.firstName,'''') + ISNULL('' '' + RI.middleName,'''') + ISNULL('' '' + RI.lastName1,'''') + '' [CustomerName:'' + isnull(CM.FULLNAME, '''') + ''] [CustID: ''+ISNULL(cm.postalcode,cm.membershi
  1307. pId)+''] [MOB:'' + isnull(RI.mobile, '''') + ''] ''+ISNULL(''|''+RI.email,'''')
  1308. FROM receiverInformation RI (NOLOCK)
  1309. INNER JOIN CUSTOMERMASTER CM ( NOLOCK) ON CM.CUSTOMERID = RI.CUSTOMERID
  1310. WHERE 1 = 1
  1311. '
  1312. SET @SQL += 'AND RI.FULLNAME LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1313. PRINT @SQL
  1314. EXEC (@SQL)
  1315. END
  1316. ELSE
  1317. BEGIN
  1318. IF LEN(@searchText) < 3
  1319. BEGIN
  1320. SELECT CUSTOMERID
  1321. ,FULLNAME
  1322. FROM customerMaster(NOLOCK)
  1323. WHERE 1 = 2
  1324. RETURN
  1325. END
  1326. SET @SQL = 'SELECT TOP 20 customerId, [detail] = ISNULL(fullName, '''') + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''|''+email,'''')
  1327. FROM customerMaster (NOLOCK) WHERE 1 = 1
  1328. and isActive=''Y''
  1329. and serviceUsedFor like ''%M%'''
  1330. IF @param1 = 'name'
  1331. BEGIN
  1332. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1333. END
  1334. ELSE IF @param1 = 'email'
  1335. BEGIN
  1336. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1337. END
  1338. ELSE IF @param1 = 'membershipId'
  1339. BEGIN
  1340. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1341. END
  1342. ELSE IF @param1 = 'customerId'
  1343. BEGIN
  1344. SET @SQL += 'AND POSTALCODE = ''' + ISNULL(@searchText, '''') + ''''
  1345. END
  1346. ELSE IF @param1 = 'membershipId'
  1347. BEGIN
  1348. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1349. END
  1350. ELSE IF @param1 = 'dob'
  1351. BEGIN
  1352. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1353. END
  1354. ELSE IF @param1 = 'mobile'
  1355. BEGIN
  1356. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1357. END
  1358. ELSE IF @param1 = 'idNumber'
  1359. BEGIN
  1360. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1361. END
  1362. --PRINT(@SQL)
  1363. EXEC (@SQL)
  1364. END
  1365. END;
  1366. IF @category = 'searchCustomerForSendPage'
  1367. BEGIN
  1368. IF LEN(@searchText) < 3
  1369. BEGIN
  1370. SELECT CUSTOMERID
  1371. ,FULLNAME
  1372. FROM customerMaster(NOLOCK)
  1373. WHERE 1 = 2
  1374. RETURN
  1375. END
  1376. SET @SQL = 'SELECT TOP 20 customerId, [detail] = fullName + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''[''+email,'''') + '']''
  1377. + ''['' + ISNULL(zipcode,'''') + ISNULL('','' + CSM.STATENAME,'''')+ISNULL('','' + street,'''')+ISNULL('','' + city,'''') +'']''
  1378. FROM customerMaster (NOLOCK) CM
  1379. LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CM.STATE
  1380. WHERE 1 = 1 AND CM.approvedDate IS NOT NULL and ISNULL(isactive, ''Y'') = ''y'' '
  1381. IF @param1 = 'name'
  1382. BEGIN
  1383. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1384. END
  1385. ELSE IF @param1 = 'email'
  1386. BEGIN
  1387. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1388. END
  1389. ELSE IF @param1 = 'membershipId'
  1390. BEGIN
  1391. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1392. END
  1393. ELSE IF @param1 = 'mobile'
  1394. BEGIN
  1395. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1396. END
  1397. ELSE IF @param1 = 'customerId'
  1398. BEGIN
  1399. SET @SQL += 'AND postalCode = ''' + ISNULL(@searchText, '''') + ''''
  1400. END
  1401. ELSE IF @param1 = 'dob'
  1402. BEGIN
  1403. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1404. END
  1405. ELSE IF @param1 = 'membershipId'
  1406. BEGIN
  1407. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1408. END
  1409. ELSE IF @param1 = 'idNumber'
  1410. BEGIN
  1411. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1412. END
  1413. PRINT(@SQL)
  1414. EXEC (@SQL)
  1415. END;
  1416. IF @category = 'searchCustomerForCollModeChange'
  1417. BEGIN
  1418. DECLARE @CUSTOMERID BIGINT
  1419. SELECT @CUSTOMERID = S.CUSTOMERID
  1420. FROM REMITTRAN R(NOLOCK)
  1421. INNER JOIN TRANSENDERS S(NOLOCK) ON S.TRANID = R.ID
  1422. WHERE R.CONTROLNO = DBO.FNAENCRYPTSTRING(@searchText)
  1423. IF @CUSTOMERID IS NULL
  1424. BEGIN
  1425. SELECT CUSTOMERID
  1426. ,FULLNAME
  1427. FROM customerMaster(NOLOCK)
  1428. WHERE 1 = 2
  1429. RETURN
  1430. END
  1431. SET @SQL = 'SELECT TOP 20 customerId, [detail] = fullName + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''[''+email,'''') + '']''
  1432. + ''['' + ISNULL(zipcode,'''') + ISNULL('','' + CSM.STATENAME,'''')+ISNULL('','' + street,'''')+ISNULL('','' + city,'''') +'']''
  1433. FROM customerMaster (NOLOCK) CM
  1434. LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CM.STATE
  1435. WHERE CM.CUSTOMERID = ''' + CAST(@CUSTOMERID AS VARCHAR) + ''''
  1436. --PRINT(@SQL)
  1437. EXEC (@SQL)
  1438. END;
  1439. IF @category = 'searchCustomerForLog'
  1440. BEGIN
  1441. IF LEN(@searchText) < 3
  1442. BEGIN
  1443. SELECT CUSTOMERID
  1444. ,FULLNAME
  1445. FROM customerMaster(NOLOCK)
  1446. WHERE 1 = 2
  1447. RETURN
  1448. END
  1449. SET @SQL = 'SELECT TOP 20 customerId, [detail] = fullName + '' [ID:'' + isnull(obpId, customerId) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''|''+email,'''') + ''[KYC Status:'' + isnull(LawsonCardNo, '''') + '']''
  1450. FROM customerMaster (NOLOCK) WHERE 1 = 1 AND approvedDate IS NOT NULL '
  1451. IF @param1 = 'name'
  1452. BEGIN
  1453. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1454. END
  1455. ELSE IF @param1 = 'email'
  1456. BEGIN
  1457. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1458. END
  1459. ELSE IF @param1 = 'customerId'
  1460. BEGIN
  1461. SET @SQL += 'AND obpid LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1462. END
  1463. ELSE IF @param1 = 'membershipId'
  1464. BEGIN
  1465. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1466. END
  1467. ELSE IF @param1 = 'mobile'
  1468. BEGIN
  1469. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1470. END
  1471. ELSE IF @param1 = 'dob'
  1472. BEGIN
  1473. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1474. END
  1475. ELSE IF @param1 = 'LawsonCardNo'
  1476. BEGIN
  1477. SET @SQL += 'AND LawsonCardNo LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1478. END
  1479. --PRINT(@SQL)
  1480. EXEC (@SQL)
  1481. END;
  1482. IF @category = 'searchCustomerNew'
  1483. BEGIN
  1484. IF @param1 = 'receiverName'
  1485. BEGIN
  1486. IF LEN(@searchText) < 3
  1487. BEGIN
  1488. SELECT RECEIVERID
  1489. ,FULLNAME
  1490. FROM RECEIVERINFORMATION(NOLOCK)
  1491. WHERE 1 = 2
  1492. RETURN
  1493. END
  1494. SET @SQL = 'SELECT TOP 20 RI.RECEIVERID, [detail] = ISNULL(RI.firstName,'''') + ISNULL('' '' + RI.middleName,'''') + ISNULL('' '' + RI.lastName1,'''') + '' [CustomerName:'' + isnull(CM.FULLNAME, '''') + ''] [CustID: ''+ISNULL(cm.postalcode,cm.membershipId)+''] [MOB:'' + isnull(RI.mobile, '''') + ''] ''+ISNULL(''|''+RI.email,'''')
  1495. FROM receiverInformation RI (NOLOCK)
  1496. INNER JOIN CUSTOMERMASTER CM ( NOLOCK) ON CM.CUSTOMERID = RI.CUSTOMERID
  1497. WHERE 1 = 1 '
  1498. SET @SQL += 'AND RI.FULLNAME LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1499. PRINT @SQL
  1500. EXEC (@SQL)
  1501. END
  1502. ELSE
  1503. BEGIN
  1504. IF LEN(@searchText) < 3
  1505. BEGIN
  1506. SELECT CUSTOMERID
  1507. ,FULLNAME
  1508. FROM customerMaster(NOLOCK)
  1509. WHERE 1 = 2
  1510. RETURN
  1511. END
  1512. SET @SQL = 'SELECT TOP 20 customerId, [detail] = fullName + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''|''+email,'''')
  1513. FROM customerMaster cm (NOLOCK) WHERE 1 = 1 AND CM.approvedDate IS NOT NULL
  1514. '
  1515. IF @param1 = 'name'
  1516. BEGIN
  1517. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1518. END
  1519. ELSE IF @param1 = 'email'
  1520. BEGIN
  1521. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1522. END
  1523. ELSE IF @param1 = 'membershipId'
  1524. BEGIN
  1525. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1526. END
  1527. ELSE IF @param1 = 'customerId'
  1528. BEGIN
  1529. SET @SQL += 'AND POSTALCODE = ''' + ISNULL(@searchText, '''') + ''''
  1530. END
  1531. ELSE IF @param1 = 'membershipId'
  1532. BEGIN
  1533. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1534. END
  1535. ELSE IF @param1 = 'dob'
  1536. BEGIN
  1537. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1538. END
  1539. ELSE IF @param1 = 'mobile'
  1540. BEGIN
  1541. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1542. END
  1543. ELSE IF @param1 = 'idNumber'
  1544. BEGIN
  1545. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1546. END
  1547. --PRINT(@SQL)
  1548. EXEC (@SQL)
  1549. END
  1550. END;
  1551. ELSE IF @category = 'referralCode'
  1552. BEGIN
  1553. IF LEN(@searchText) >= 3
  1554. BEGIN
  1555. SELECT TOP 30 REFERRAL_CODE
  1556. ,REFERRAL_NAME
  1557. FROM REFERRAL_AGENT_WISE(NOLOCK)
  1558. WHERE REFERRAL_CODE LIKE @searchText + '%'
  1559. OR REFERRAL_NAME LIKE @searchText + '%'
  1560. AND IS_ACTIVE = 1
  1561. --AND AGENT_ID = 0
  1562. --AND REFERRAL_TYPE_CODE <> 'RB'
  1563. RETURN;
  1564. END
  1565. SELECT TOP 30 REFERRAL_CODE
  1566. ,REFERRAL_NAME
  1567. FROM REFERRAL_AGENT_WISE(NOLOCK)
  1568. WHERE 1 = 2
  1569. RETURN;
  1570. END
  1571. ELSE IF @category = 'referralCodeNew'
  1572. BEGIN
  1573. IF LEN(@searchText) >= 3
  1574. BEGIN
  1575. SELECT TOP 30 REFERRAL_CODE
  1576. ,REFERRAL_NAME
  1577. FROM REFERRAL_AGENT_WISE(NOLOCK)
  1578. WHERE (
  1579. REFERRAL_CODE LIKE @searchText + '%'
  1580. OR REFERRAL_NAME LIKE @searchText + '%'
  1581. )
  1582. AND IS_ACTIVE = 1
  1583. AND ISNULL(STAFFRESIGN, 0) <> 1
  1584. --AND AGENT_ID = 0
  1585. --AND REFERRAL_TYPE_CODE <> 'RB'
  1586. RETURN;
  1587. END
  1588. SELECT TOP 30 REFERRAL_CODE
  1589. ,REFERRAL_NAME
  1590. FROM REFERRAL_AGENT_WISE(NOLOCK)
  1591. WHERE 1 = 2
  1592. RETURN;
  1593. END
  1594. ELSE IF @category = 'referralChange'
  1595. BEGIN
  1596. IF LEN(@searchText) >= 3
  1597. BEGIN
  1598. SELECT TOP 30 REFERRAL_CODE
  1599. ,REFERRAL_NAME
  1600. FROM REFERRAL_AGENT_WISE(NOLOCK)
  1601. WHERE REFERRAL_CODE LIKE @searchText + '%'
  1602. OR REFERRAL_NAME LIKE @searchText + '%'
  1603. AND IS_ACTIVE = 1
  1604. RETURN;
  1605. END
  1606. SELECT TOP 30 REFERRAL_CODE
  1607. ,REFERRAL_NAME
  1608. FROM REFERRAL_AGENT_WISE(NOLOCK)
  1609. WHERE 1 = 2
  1610. RETURN;
  1611. END
  1612. ELSE IF @category = 'CustomerName'
  1613. BEGIN
  1614. IF LEN(@searchText) < 3
  1615. BEGIN
  1616. SELECT TOP 30 customerId
  1617. ,[detail] = fullName + '[' + isnull(idNumber, '') + '] | ' + ISNULL(email, '')
  1618. FROM customerMaster WITH (NOLOCK)
  1619. WHERE 1 = 2
  1620. RETURN
  1621. END
  1622. SELECT TOP 30 customerId
  1623. ,[detail] = fullName + '[' + isnull(idNumber, '') + '] | ' + ISNULL(email, '')
  1624. FROM customerMaster WITH (NOLOCK)
  1625. WHERE fullName LIKE @searchText + '%' OR idNumber LIKE @searchText + '%'
  1626. RETURN
  1627. END
  1628. ELSE IF @category = 'MembershipId'
  1629. BEGIN
  1630. IF LEN(@searchText) < 3
  1631. BEGIN
  1632. SELECT TOP 30 customerId
  1633. , [detail] = ISNULL(fullName, '') + ' [ID:' + isnull(postalCode, membershipid) + '] [MOB:' + isnull(mobile, '') + '] [DOB:' + isnull(convert(varchar, DOB, 102), '') + '] [Email:'+ISNULL(email,'')+'] '
  1634. FROM customerMaster WITH (NOLOCK)
  1635. WHERE 1 = 2
  1636. RETURN
  1637. END
  1638. SELECT TOP 30 customerId
  1639. , [detail] = ISNULL(fullName, '') + ' [ID:' + isnull(postalCode, membershipid) + '] [MOB:' + isnull(mobile, '') + '] [DOB:' + isnull(convert(varchar, DOB, 102), '') + '] [Email:'+ISNULL(email,'')+'] '
  1640. FROM customerMaster WITH (NOLOCK)
  1641. WHERE membershipId LIKE @searchText + '%'
  1642. RETURN
  1643. END
  1644. ELSE IF @category = 'ReceiverName'
  1645. BEGIN
  1646. SELECT TOP 30 *
  1647. FROM (
  1648. SELECT receiverId
  1649. ,fullname = firstName + ISNULL(' ' + middleName, '') + ISNULL(' ' + lastName1, '') + ISNULL(' ' + lastName2, '')
  1650. FROM dbo.receiverInformation WITH (NOLOCK)
  1651. ) X
  1652. WHERE X.fullname LIKE @searchText + '%'
  1653. RETURN
  1654. END
  1655. ELSE IF @category = 'mapBankData'
  1656. BEGIN
  1657. IF LEN(@searchText) < 3
  1658. BEGIN
  1659. SELECT TOP 30 ROW_ID
  1660. ,[detail] = BANK_NAME
  1661. FROM API_BANK_LIST_TMP WITH (NOLOCK)
  1662. WHERE 1 = 2
  1663. RETURN
  1664. END
  1665. SELECT TOP 30 ROW_ID
  1666. ,[detail] = BANK_NAME + ISNULL(' | ' + BANK_CODE1, '')
  1667. FROM API_BANK_LIST_TMP WITH (NOLOCK)
  1668. WHERE BANK_NAME LIKE '%' + @searchText + '%'
  1669. RETURN
  1670. END
  1671. ELSE IF @category = 'CASHRPT'
  1672. BEGIN
  1673. IF LEN(@searchText) < 3
  1674. BEGIN
  1675. SELECT TOP 30 ROW_ID
  1676. ,[detail] = REFERRAL_NAME
  1677. FROM REFERRAL_AGENT_WISE WITH (NOLOCK)
  1678. WHERE 1 = 2
  1679. RETURN
  1680. END
  1681. SELECT TOP 30 REFERRAL_CODE
  1682. ,[detail] = REFERRAL_NAME
  1683. FROM REFERRAL_AGENT_WISE WITH (NOLOCK)
  1684. WHERE REFERRAL_NAME LIKE '%' + @searchText + '%'
  1685. AND REFERRAL_TYPE_CODE = 'RC'
  1686. RETURN
  1687. END
  1688. IF @category = 'searchCustomerIntroducerReport'
  1689. BEGIN
  1690. IF LEN(@searchText) < 3
  1691. BEGIN
  1692. SELECT CUSTOMERID
  1693. ,FULLNAME
  1694. FROM customerMaster(NOLOCK)
  1695. WHERE 1 = 2
  1696. RETURN
  1697. END
  1698. SET @SQL = '
  1699. SELECT TOP 20 cm.customerId, [detail] = cm.fullName + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''[''+email,'''') + '']''
  1700. + ''['' + ISNULL(zipcode,'''') + ISNULL('','' + CSM.STATENAME,'''')+ISNULL('','' + street,'''')+ISNULL('','' + city,'''') +'']''
  1701. FROM (
  1702. SELECT referelCode
  1703. FROM CustomerMaster (NOLOCK)
  1704. WHERE referelCode IS NOT NULL
  1705. )TMP
  1706. INNER JOIN customerMaster CM(NOLOCK) ON CM.membershipId = TMP.referelCode
  1707. LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CM.STATE
  1708. WHERE 1 = 1 AND CM.approvedDate IS NOT NULL and ISNULL(cm.isactive, ''Y'') = ''y'' '
  1709. IF @param1 = 'name'
  1710. BEGIN
  1711. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1712. END
  1713. ELSE IF @param1 = 'email'
  1714. BEGIN
  1715. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1716. END
  1717. ELSE IF @param1 = 'membershipId'
  1718. BEGIN
  1719. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1720. END
  1721. ELSE IF @param1 = 'mobile'
  1722. BEGIN
  1723. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1724. END
  1725. ELSE IF @param1 = 'customerId'
  1726. BEGIN
  1727. SET @SQL += 'AND postalCode = ''' + ISNULL(@searchText, '''') + ''''
  1728. END
  1729. ELSE IF @param1 = 'dob'
  1730. BEGIN
  1731. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1732. END
  1733. ELSE IF @param1 = 'membershipId'
  1734. BEGIN
  1735. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1736. END
  1737. ELSE IF @param1 = 'idNumber'
  1738. BEGIN
  1739. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1740. END
  1741. --PRINT(@SQL)
  1742. EXEC (@SQL)
  1743. END;
  1744. --IF @category = 'searchRejectedCustomer'
  1745. --BEGIN
  1746. -- IF LEN(@searchText) < 3
  1747. -- BEGIN
  1748. -- SELECT CUSTOMERID
  1749. -- ,FULLNAME
  1750. -- FROM customerMaster(NOLOCK)
  1751. -- WHERE 1 = 2
  1752. -- RETURN
  1753. -- END
  1754. -- SET @SQL = 'SELECT TOP 20 customerId, [detail] = fullName + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''|''+email,'''')
  1755. -- FROM customerMaster cm (NOLOCK) WHERE 1 = 1 AND CM.isActive = ''N''
  1756. -- '
  1757. -- IF @param1 = 'name'
  1758. -- BEGIN
  1759. -- SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1760. -- END
  1761. -- ELSE IF @param1 = 'email'
  1762. -- BEGIN
  1763. -- SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1764. -- END
  1765. -- ELSE IF @param1 = 'membershipId'
  1766. -- BEGIN
  1767. -- SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1768. -- END
  1769. -- ELSE IF @param1 = 'customerId'
  1770. -- BEGIN
  1771. -- SET @SQL += 'AND POSTALCODE = ''' + ISNULL(@searchText, '''') + ''''
  1772. -- END
  1773. -- ELSE IF @param1 = 'membershipId'
  1774. -- BEGIN
  1775. -- SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1776. -- END
  1777. -- ELSE IF @param1 = 'dob'
  1778. -- BEGIN
  1779. -- SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1780. -- END
  1781. -- ELSE IF @param1 = 'mobile'
  1782. -- BEGIN
  1783. -- SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1784. -- END
  1785. -- ELSE IF @param1 = 'idNumber'
  1786. -- BEGIN
  1787. -- SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1788. -- END
  1789. -- --PRINT(@SQL)
  1790. -- EXEC (@SQL)
  1791. -- END ;
  1792. IF @category = 'searchRejectedCustomer'
  1793. BEGIN
  1794. IF LEN(@searchText) < 3
  1795. BEGIN
  1796. SELECT CUSTOMERID
  1797. ,email
  1798. FROM customerMaster(NOLOCK)
  1799. WHERE 1 = 2
  1800. RETURN
  1801. END
  1802. SET @SQL = 'SELECT TOP 20 customerid , [detail] = isnull(fullName,'''') + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''|''+email,'''') + ''[KYC Status:'' + isnull(LawsonCardNo, '''') + '']''
  1803. --[detail]= email
  1804. FROM customerMaster cm (NOLOCK)
  1805. WHERE 1 = 1 AND ISNULL(CM.isActive,''N'') = ''N'''
  1806. IF @param1 = 'name'
  1807. BEGIN
  1808. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1809. END
  1810. ELSE IF @param1 = 'email'
  1811. BEGIN
  1812. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1813. END
  1814. ELSE IF @param1 = 'membershipId'
  1815. BEGIN
  1816. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1817. END
  1818. ELSE IF @param1 = 'customerId'
  1819. BEGIN
  1820. SET @SQL += 'AND POSTALCODE = ''' + ISNULL(@searchText, '''') + ''''
  1821. END
  1822. ELSE IF @param1 = 'membershipId'
  1823. BEGIN
  1824. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1825. END
  1826. ELSE IF @param1 = 'dob'
  1827. BEGIN
  1828. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1829. END
  1830. ELSE IF @param1 = 'mobile'
  1831. BEGIN
  1832. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1833. END
  1834. ELSE IF @param1 = 'idNumber'
  1835. BEGIN
  1836. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1837. END
  1838. ELSE IF @param1 = 'LawsonCardNo'
  1839. BEGIN
  1840. SET @SQL += 'AND LawsonCardNo LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1841. END
  1842. PRINT(@SQL)
  1843. EXEC (@SQL)
  1844. END;
  1845. IF @category = 'searchCustomerforMobileActivation'
  1846. BEGIN
  1847. IF LEN(@searchText) < 3
  1848. BEGIN
  1849. SELECT CUSTOMERID
  1850. ,FULLNAME
  1851. FROM customerMaster(NOLOCK)
  1852. WHERE 1 = 2
  1853. RETURN
  1854. END
  1855. SET @SQL = 'SELECT TOP 20 customerId, [detail] = ISNULL(fullName, '''') + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''|''+email,'''') + ''[KYC Status:'' + isnull(lawsonCardNo, '''') + '']''
  1856. FROM customerMaster (NOLOCK) WHERE 1 = 1
  1857. and ISNULL(isActive,''Y'')=''Y''
  1858. and createdFrom =''C''
  1859. AND username is null
  1860. AND mobileApprovedDate is null '
  1861. IF @param1 = 'name'
  1862. BEGIN
  1863. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1864. END
  1865. ELSE IF @param1 = 'email'
  1866. BEGIN
  1867. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1868. END
  1869. ELSE IF @param1 = 'membershipId'
  1870. BEGIN
  1871. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1872. END
  1873. ELSE IF @param1 = 'customerId'
  1874. BEGIN
  1875. SET @SQL += 'AND POSTALCODE = ''' + ISNULL(@searchText, '''') + ''''
  1876. END
  1877. ELSE IF @param1 = 'membershipId'
  1878. BEGIN
  1879. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1880. END
  1881. ELSE IF @param1 = 'dob'
  1882. BEGIN
  1883. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1884. END
  1885. ELSE IF @param1 = 'mobile'
  1886. BEGIN
  1887. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1888. END
  1889. ELSE IF @param1 = 'idNumber'
  1890. BEGIN
  1891. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1892. END
  1893. ELSE IF @param1 = 'LawsonCardNo'
  1894. BEGIN
  1895. SET @SQL += 'AND LawsonCardNo LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1896. END
  1897. PRINT (@SQL)
  1898. EXEC (@SQL)
  1899. END;
  1900. --EXEC proc_autocomplete @category='CustomerName', @searchText='dham'
  1901. IF @category = 'referralnew' -- Select branchName List According to CountryName and AgentName
  1902. BEGIN
  1903. --SELECT REFERRAL_CODE
  1904. -- ,--as referral,
  1905. -- REFERRAL_NAME -- as referralName
  1906. --FROM REFERRAL_AGENT_WISE am WITH (NOLOCK)
  1907. --WHERE am.IS_ACTIVE = 1
  1908. --UNION ALL
  1909. SELECT am.agentCode AS REFERRAL_CODE
  1910. ,userName AS REFERRAL_NAME
  1911. FROM applicationUsers AU WITH (NOLOCK)
  1912. INNER JOIN AGENTMASTER AM WITH (NOLOCK) ON am.agentCode = au.agentCode
  1913. WHERE am.agentCountry = 'JAPAN'
  1914. AND am.isActive = 'Y'
  1915. AND AU.isActive = 'Y'
  1916. ORDER BY REFERRAL_NAME ASC
  1917. RETURN
  1918. END
  1919. IF @category = 'referralForCashCollect'
  1920. BEGIN
  1921. IF LEN(@searchText) < 3
  1922. BEGIN
  1923. SELECT TOP 30 *
  1924. FROM (
  1925. --SELECT REFERRAL_CODE
  1926. -- ,REFERRAL_NAME
  1927. --FROM REFERRAL_AGENT_WISE am WITH (NOLOCK)
  1928. --WHERE am.IS_ACTIVE = 1
  1929. --UNION ALL
  1930. SELECT am.agentCode AS REFERRAL_CODE
  1931. ,userName AS REFERRAL_NAME
  1932. FROM applicationUsers AU WITH (NOLOCK)
  1933. INNER JOIN AGENTMASTER AM WITH (NOLOCK) ON am.agentCode = au.agentCode
  1934. WHERE am.agentCountry = 'JAPAN'
  1935. AND am.isActive = 'Y'
  1936. AND AU.isActive = 'Y'
  1937. ) X
  1938. WHERE 1 = 2
  1939. -- AND userName LIKE '%@searchText%'
  1940. ORDER BY REFERRAL_NAME ASC
  1941. RETURN
  1942. END
  1943. --SELECT REFERRAL_CODE
  1944. -- ,REFERRAL_NAME
  1945. --FROM REFERRAL_AGENT_WISE am WITH (NOLOCK)
  1946. --WHERE am.IS_ACTIVE = 1
  1947. -- AND REFERRAL_NAME LIKE @searchText + '%'
  1948. --UNION ALL
  1949. SELECT am.agentCode AS REFERRAL_CODE
  1950. ,userName AS REFERRAL_NAME
  1951. FROM applicationUsers AU WITH (NOLOCK)
  1952. INNER JOIN AGENTMASTER AM WITH (NOLOCK) ON am.agentCode = au.agentCode
  1953. WHERE am.agentCountry = 'JAPAN'
  1954. AND am.isActive = 'Y'
  1955. AND AU.isActive = 'Y'
  1956. AND userName LIKE @searchText + '%'
  1957. --AND au.agentId=0
  1958. ORDER BY REFERRAL_NAME ASC
  1959. RETURN
  1960. END
  1961. IF @category = 'searchCustomerForReport'
  1962. BEGIN
  1963. IF LEN(@searchText) < 3
  1964. BEGIN
  1965. SELECT CUSTOMERID
  1966. ,FULLNAME
  1967. FROM customerMaster(NOLOCK)
  1968. WHERE 1 = 2
  1969. RETURN
  1970. END
  1971. --SET @SQL = 'SELECT TOP 20 customerId, [detail] = ISNULL(fullName,'''') + '' [ID:'' + isnull(postalCode, ISNULL(membershipid,'''')) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''[''+email,'''') + '']''
  1972. -- FROM customerMaster (NOLOCK) CM
  1973. -- LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CM.STATE
  1974. -- LEFT JOIN staticDataValue (NOLOCK) sdv ON sdv.typeId = cm.idType
  1975. -- WHERE 1 = 1
  1976. -- --AND CM.approvedDate IS NOT NULL and ISNULL(cm.isactive, ''Y'') = ''y''
  1977. -- '
  1978. SET @SQL = 'SELECT TOP 20 * FROM
  1979. ( SELECT [customerId] = CAST(customerId AS VARCHAR) + ''|'' + ''master'' , [detail] = ISNULL(fullName,'''') + '' [ID:'' + isnull(idNumber, ISNULL(postalCode,'''')) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''[''+email,'''') + '']'' +ISNULL(''[''+membershipId,'''') + '']''
  1980. , email, membershipId, idNumber FROM customerMaster (NOLOCK) CM
  1981. LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CM.STATE
  1982. LEFT JOIN staticDataValue (NOLOCK) sdv ON sdv.typeId = cm.idType
  1983. WHERE 1 = 1
  1984. --AND CM.approvedDate IS NOT NULL and ISNULL(cm.isactive, ''Y'') = ''y''
  1985. UNION ALL
  1986. SELECT [customerId] = CAST(customerId AS VARCHAR) + ''|'' + ''temp'', [detail] = ISNULL(fullName,'''') + '' [ID:'' + isnull(idNumber,''N/A'') + '' ]'' +ISNULL(''[''+email,'''') + '']'' +ISNULL(''[''+membershipId,'''') + '']''
  1987. , email,membershipId,idNumber
  1988. FROM customerMasterTemp (NOLOCK) CT
  1989. )x where 1=1
  1990. '
  1991. IF @param1 = 'email'
  1992. BEGIN
  1993. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1994. END
  1995. ELSE IF @param1 = 'membershipId'
  1996. BEGIN
  1997. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1998. END
  1999. ELSE IF @param1 = 'membershipId'
  2000. BEGIN
  2001. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  2002. END
  2003. ELSE IF @param1 = 'idNumber'
  2004. BEGIN
  2005. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2006. END
  2007. PRINT @SQL
  2008. EXEC (@SQL)
  2009. END;
  2010. IF @category = 'searchCustomerForReportKyc'
  2011. BEGIN
  2012. IF LEN(@searchText) < 3
  2013. BEGIN
  2014. SELECT CUSTOMERID
  2015. ,FULLNAME
  2016. FROM customerMaster(NOLOCK)
  2017. WHERE 1 = 2
  2018. RETURN
  2019. END
  2020. SET @SQL = '
  2021. SELECT TOP 20 * FROM (
  2022. SELECT customerId, [detail] = fullName + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''[''+email,'''') + '']
  2023. +'' , email,membershipId,idNumber
  2024. FROM customerMaster (NOLOCK) CM
  2025. LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CM.STATE
  2026. LEFT JOIN staticDataValue (NOLOCK) sdv ON sdv.typeId = cm.idType
  2027. WHERE 1 = 1 AND CM.approvedDate IS NOT NULL and ISNULL(cm.isactive, ''Y'') = ''y''
  2028. UNION ALL
  2029. SELECT customerId, [detail] = ISNULL(fullName,'''') + '' [ID:'' + isnull(membershipid,''N/A'') + '' ]'' +ISNULL(''[''+email,'''') + '']''
  2030. , email,membershipId,idNumber
  2031. FROM customerMasterTemp (NOLOCK) CT
  2032. --LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CT.STATE
  2033. --LEFT JOIN staticDataValue (NOLOCK) sdv ON sdv.typeId = CT.idType
  2034. )x WHERE 1=1
  2035. '
  2036. IF @param1 = 'email'
  2037. BEGIN
  2038. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2039. END
  2040. ELSE IF @param1 = 'membershipId'
  2041. BEGIN
  2042. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2043. END
  2044. ELSE IF @param1 = 'idNumber'
  2045. BEGIN
  2046. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2047. END
  2048. PRINT(@SQL)
  2049. EXEC (@SQL)
  2050. END;
  2051. IF @category = 'searchCustomerForLawsonCard'
  2052. BEGIN
  2053. IF LEN(@searchText) < 3
  2054. BEGIN
  2055. SELECT CUSTOMERID
  2056. ,FULLNAME
  2057. FROM customerMaster(NOLOCK)
  2058. WHERE 1 = 2
  2059. RETURN
  2060. END
  2061. SET @SQL = 'SELECT TOP 20 customerId, [detail] = isnull(fullName,'''') + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''[''+email,'''') + '']''
  2062. + ''['' + ISNULL(zipcode,'''') + ISNULL('','' + CSM.STATENAME,'''')+ISNULL('','' + street,'''')+ISNULL('','' + city,'''') +'']''
  2063. FROM customerMaster (NOLOCK) CM
  2064. LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CM.STATE
  2065. LEFT JOIN staticDataValue (NOLOCK) sdv ON sdv.typeId = cm.idType
  2066. WHERE 1 = 1
  2067. AND CM.approvedDate IS NOT NULL and ISNULL(cm.isactive, ''Y'') = ''Y''
  2068. AND CM.lawsoncardNo IS NULL
  2069. '
  2070. PRINT @param1
  2071. IF @param1 = 'name'
  2072. BEGIN
  2073. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2074. END
  2075. ELSE IF @param1 = 'email'
  2076. BEGIN
  2077. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2078. END
  2079. ELSE IF @param1 = 'membershipId'
  2080. BEGIN
  2081. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2082. END
  2083. ELSE IF @param1 = 'mobile'
  2084. BEGIN
  2085. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2086. END
  2087. ELSE IF @param1 = 'customerId'
  2088. BEGIN
  2089. SET @SQL += 'AND postalCode = ''' + ISNULL(@searchText, '''') + ''''
  2090. END
  2091. ELSE IF @param1 = 'dob'
  2092. BEGIN
  2093. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  2094. END
  2095. ELSE IF @param1 = 'membershipId'
  2096. BEGIN
  2097. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  2098. END
  2099. ELSE IF @param1 = 'idNumber'
  2100. BEGIN
  2101. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2102. END
  2103. EXEC (@SQL)
  2104. END
  2105. ELSE IF @category = 'CustomerForLawson'
  2106. BEGIN
  2107. IF LEN(@searchText) < 3
  2108. BEGIN
  2109. SELECT TOP 30 customerId
  2110. ,[detail] = fullName + '[' + isnull(idNumber, '') + '] | ' + ISNULL(email, '') + ISNULL(lawsonCardNo, '')
  2111. FROM customerMaster WITH (NOLOCK)
  2112. WHERE 1 = 2
  2113. AND LawsonCardNo is not null
  2114. RETURN
  2115. END
  2116. SELECT TOP 30 customerId
  2117. ,[detail] = fullName + '[' + isnull(idNumber, '') + '] | ' + ISNULL(email, '') + ISNULL(lawsonCardNo, '')
  2118. FROM customerMaster WITH (NOLOCK)
  2119. WHERE LawsonCardNo is not null
  2120. AND (fullName LIKE @searchText + '%' OR lawsonCardNo LIKE @searchText + '%' )
  2121. RETURN
  2122. END
  2123. ELSE IF @category = 'getAgentForFreeSC'
  2124. BEGIN
  2125. IF LEN(@searchText) < 3
  2126. BEGIN
  2127. SELECT top 30 au.userId,
  2128. [detail] = au.username + ' | ' + AU.firstName + ISNULL(AU.middleName,'') + AU.lastName + '[' + AM.agentName + ']'
  2129. FROM applicationUsers(NOLOCK) AU
  2130. INNER JOIN agentMaster (NOLOCK) AM ON AM.AGENTID = AU.AGENTID
  2131. WHERE 1 = 2
  2132. AND AM.actAsBranch = 'Y' AND AU.isActive = 'Y'
  2133. RETURN
  2134. END
  2135. SELECT top 30 au.userId,
  2136. [detail] = au.username + ' | ' + AU.firstName + ' ' + + ISNULL(AU.middleName,'') + AU.lastName + '[' + AM.agentName + ']'
  2137. FROM applicationUsers(NOLOCK) AU
  2138. INNER JOIN agentMaster (NOLOCK) AM ON AM.AGENTID = AU.AGENTID
  2139. WHERE AM.actAsBranch = 'Y' AND AU.isActive = 'Y'
  2140. AND (firstName LIKE @searchText + '%')
  2141. RETURN
  2142. END
  2143. IF @category = 'searchCustomer-delete-mobile'
  2144. BEGIN
  2145. IF LEN(@searchText) < 3
  2146. BEGIN
  2147. SELECT CUSTOMERID
  2148. ,FULLNAME
  2149. FROM customerMaster(NOLOCK)
  2150. WHERE 1 = 2
  2151. RETURN
  2152. END
  2153. SET @SQL = 'SELECT TOP 20 * FROM
  2154. ( SELECT [customerId] = CAST(cm.customerId AS VARCHAR) + ''|'' + ''master'' , [detail] = ISNULL(fullName, '''') + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''|''+email,'''') + ''[KYC Status:'' + isnull(lawsonCardNo, '''') + '']''
  2155. ,fullName,membershipId,mobile,idNumber,email,LawsonCardNo FROM customerMaster (NOLOCK) cm
  2156. --INNER JOIN mobile_userRegistration(NOLOCK) mr ON mr.customerId = cm.customerId
  2157. --and cm.createdFrom =''M''
  2158. WHERE 1=1
  2159. --ISNULL(agreeYn,0) = 0
  2160. --AND mobileApprovedDate is null
  2161. UNION ALL
  2162. SELECT [customerId] = CAST(customerId AS VARCHAR) + ''|'' + ''temp'' , [detail] = ISNULL(fullName, '''') + '' [ID:'' + isnull( membershipid,'''') + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''|''+email,'''') + '']''
  2163. ,fullName,membershipId,mobile,idNumber,email,'''' LawsonCardNo FROM customerMasterTemp (NOLOCK) CT
  2164. )x where 1=1
  2165. '
  2166. --SET @SQL = 'SELECT TOP 20 cm.customerId, [detail] = ISNULL(fullName, '''') + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''|''+email,'''') + ''[Lawson Card No:'' + isnull(lawsonCardNo, '''') + '']''
  2167. -- FROM customerMaster (NOLOCK) cm
  2168. --INNER JOIN mobile_userRegistration(NOLOCK) mr ON mr.customerId = cm.customerId
  2169. --and cm.createdFrom =''M''
  2170. --WHERE 1=1 AND ISNULL(HasDeclare,0) = 0 AND ISNULL(agreeYn,0) = 0
  2171. --AND mobileApprovedDate is null '
  2172. IF @param1 = 'name'
  2173. BEGIN
  2174. SET @SQL += 'AND X.fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2175. END
  2176. ELSE IF @param1 = 'email'
  2177. BEGIN
  2178. SET @SQL += 'AND X.email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2179. END
  2180. ELSE IF @param1 = 'membershipId'
  2181. BEGIN
  2182. SET @SQL += 'AND X.membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2183. END
  2184. ELSE IF @param1 = 'cm.customerId'
  2185. BEGIN
  2186. SET @SQL += 'AND X.POSTALCODE = ''' + ISNULL(@searchText, '''') + ''''
  2187. END
  2188. ELSE IF @param1 = 'membershipId'
  2189. BEGIN
  2190. SET @SQL += 'AND X.membershipId = ''' + ISNULL(@searchText, '''') + ''''
  2191. END
  2192. ELSE IF @param1 = 'dob'
  2193. BEGIN
  2194. SET @SQL += 'AND CONVERT(VARCHAR(10), X.DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  2195. END
  2196. ELSE IF @param1 = 'X.mobile'
  2197. BEGIN
  2198. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2199. END
  2200. ELSE IF @param1 = 'X.idNumber'
  2201. BEGIN
  2202. SET @SQL += 'AND x.idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2203. END
  2204. ELSE IF @param1 = 'LawsonCardNo'
  2205. BEGIN
  2206. SET @SQL += 'AND X.LawsonCardNo LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2207. END
  2208. PRINT (@SQL)
  2209. EXEC (@SQL)
  2210. END
  2211. IF @category = 'searchCustomerForPushNotif'
  2212. BEGIN
  2213. IF LEN(@searchText) < 3
  2214. BEGIN
  2215. SELECT CUSTOMERID
  2216. ,FULLNAME
  2217. FROM customerMaster(NOLOCK)
  2218. WHERE 1 = 2
  2219. RETURN
  2220. END
  2221. SET @SQL = 'SELECT TOP 20 cm.customerId, [detail] = fullName + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''[''+email,'''') + '']''
  2222. + ''['' + ISNULL(zipcode,'''') + ISNULL('','' + CSM.STATENAME,'''')+ISNULL('','' + street,'''')+ISNULL('','' + city,'''') +'']''
  2223. FROM customerMaster (NOLOCK) CM
  2224. INNER JOIN mobile_userRegistration (NOLOCK) m on cm.customerid= m.customerid
  2225. LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CM.STATE
  2226. WHERE 1 = 1 AND m.deviceid IS NOT NULL and ISNULL(isactive, ''Y'') = ''y'' '
  2227. IF @param1 = 'name'
  2228. BEGIN
  2229. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2230. END
  2231. ELSE IF @param1 = 'email'
  2232. BEGIN
  2233. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2234. END
  2235. ELSE IF @param1 = 'membershipId'
  2236. BEGIN
  2237. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2238. END
  2239. ELSE IF @param1 = 'mobile'
  2240. BEGIN
  2241. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2242. END
  2243. ELSE IF @param1 = 'customerId'
  2244. BEGIN
  2245. SET @SQL += 'AND postalCode = ''' + ISNULL(@searchText, '''') + ''''
  2246. END
  2247. ELSE IF @param1 = 'dob'
  2248. BEGIN
  2249. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  2250. END
  2251. ELSE IF @param1 = 'membershipId'
  2252. BEGIN
  2253. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  2254. END
  2255. ELSE IF @param1 = 'idNumber'
  2256. BEGIN
  2257. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2258. END
  2259. PRINT(@SQL)
  2260. EXEC (@SQL)
  2261. END;