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.

2550 lines
141 KiB

  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_autocomplete] Script Date: 9/25/2023 9:36:43 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 (mobileApprovedDate IS NOT NULL OR createdFrom = ''C'')
  1206. AND ISNULL(isActive, ''Y'') = ''Y''
  1207. AND (createdFrom != ''M'' OR mobileApprovedDate IS NOT NULL)'
  1208. IF @param1 = 'name'
  1209. BEGIN
  1210. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1211. END
  1212. ELSE IF @param1 = 'email'
  1213. BEGIN
  1214. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1215. END
  1216. ELSE IF @param1 = 'membershipId'
  1217. BEGIN
  1218. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1219. END
  1220. ELSE IF @param1 = 'customerId'
  1221. BEGIN
  1222. SET @SQL += 'AND POSTALCODE = ''' + ISNULL(@searchText, '''') + ''''
  1223. END
  1224. ELSE IF @param1 = 'membershipId'
  1225. BEGIN
  1226. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1227. END
  1228. ELSE IF @param1 = 'dob'
  1229. BEGIN
  1230. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1231. END
  1232. ELSE IF @param1 = 'mobile'
  1233. BEGIN
  1234. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1235. END
  1236. ELSE IF @param1 = 'idNumber'
  1237. BEGIN
  1238. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1239. END
  1240. ELSE IF @param1 = 'LawsonCardNo'
  1241. BEGIN
  1242. SET @SQL += 'AND LawsonCardNo LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1243. END
  1244. --PRINT(@SQL)
  1245. EXEC (@SQL)
  1246. END
  1247. IF @category = 'searchCustomerDeleteKYC'
  1248. BEGIN
  1249. IF LEN(@searchText) < 3
  1250. BEGIN
  1251. SELECT CUSTOMERID
  1252. ,FULLNAME
  1253. FROM customerMaster(NOLOCK)
  1254. WHERE 1 = 2
  1255. RETURN
  1256. END
  1257. SET @SQL = 'SELECT TOP 20 customerId, [detail] = ISNULL(fullName, '''') + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''|''+email,'''')
  1258. FROM customerMaster (NOLOCK) WHERE 1 = 1'
  1259. IF @param1 = 'name'
  1260. BEGIN
  1261. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1262. END
  1263. ELSE IF @param1 = 'email'
  1264. BEGIN
  1265. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1266. END
  1267. ELSE IF @param1 = 'membershipId'
  1268. BEGIN
  1269. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1270. END
  1271. ELSE IF @param1 = 'customerId'
  1272. BEGIN
  1273. SET @SQL += 'AND POSTALCODE = ''' + ISNULL(@searchText, '''') + ''''
  1274. END
  1275. ELSE IF @param1 = 'membershipId'
  1276. BEGIN
  1277. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1278. END
  1279. ELSE IF @param1 = 'dob'
  1280. BEGIN
  1281. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1282. END
  1283. ELSE IF @param1 = 'mobile'
  1284. BEGIN
  1285. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1286. END
  1287. ELSE IF @param1 = 'idNumber'
  1288. BEGIN
  1289. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1290. END
  1291. --PRINT(@SQL)
  1292. EXEC (@SQL)
  1293. RETURN
  1294. END;
  1295. IF @category = 'searchCustomerFromMobile'
  1296. BEGIN
  1297. IF @param1 = 'receiverName'
  1298. BEGIN
  1299. IF LEN(@searchText) < 3
  1300. BEGIN
  1301. SELECT RECEIVERID
  1302. ,FULLNAME
  1303. FROM RECEIVERINFORMATION(NOLOCK)
  1304. WHERE 1 = 2
  1305. RETURN
  1306. END
  1307. 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
  1308. pId)+''] [MOB:'' + isnull(RI.mobile, '''') + ''] ''+ISNULL(''|''+RI.email,'''')
  1309. FROM receiverInformation RI (NOLOCK)
  1310. INNER JOIN CUSTOMERMASTER CM ( NOLOCK) ON CM.CUSTOMERID = RI.CUSTOMERID
  1311. WHERE 1 = 1
  1312. '
  1313. SET @SQL += 'AND RI.FULLNAME LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1314. PRINT @SQL
  1315. EXEC (@SQL)
  1316. END
  1317. ELSE
  1318. BEGIN
  1319. IF LEN(@searchText) < 3
  1320. BEGIN
  1321. SELECT CUSTOMERID
  1322. ,FULLNAME
  1323. FROM customerMaster(NOLOCK)
  1324. WHERE 1 = 2
  1325. RETURN
  1326. END
  1327. SET @SQL = 'SELECT TOP 20 customerId, [detail] = ISNULL(fullName, '''') + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''|''+email,'''')
  1328. FROM customerMaster (NOLOCK) WHERE 1 = 1
  1329. and isActive=''Y''
  1330. and serviceUsedFor like ''%M%'''
  1331. IF @param1 = 'name'
  1332. BEGIN
  1333. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1334. END
  1335. ELSE IF @param1 = 'email'
  1336. BEGIN
  1337. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1338. END
  1339. ELSE IF @param1 = 'membershipId'
  1340. BEGIN
  1341. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1342. END
  1343. ELSE IF @param1 = 'customerId'
  1344. BEGIN
  1345. SET @SQL += 'AND POSTALCODE = ''' + ISNULL(@searchText, '''') + ''''
  1346. END
  1347. ELSE IF @param1 = 'membershipId'
  1348. BEGIN
  1349. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1350. END
  1351. ELSE IF @param1 = 'dob'
  1352. BEGIN
  1353. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1354. END
  1355. ELSE IF @param1 = 'mobile'
  1356. BEGIN
  1357. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1358. END
  1359. ELSE IF @param1 = 'idNumber'
  1360. BEGIN
  1361. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1362. END
  1363. --PRINT(@SQL)
  1364. EXEC (@SQL)
  1365. END
  1366. END;
  1367. IF @category = 'searchCustomerForSendPage'
  1368. BEGIN
  1369. IF LEN(@searchText) < 3
  1370. BEGIN
  1371. SELECT CUSTOMERID
  1372. ,FULLNAME
  1373. FROM customerMaster(NOLOCK)
  1374. WHERE 1 = 2
  1375. RETURN
  1376. END
  1377. SET @SQL = 'SELECT TOP 20 customerId, [detail] = fullName + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''[''+email,'''') + '']''
  1378. + ''['' + ISNULL(zipcode,'''') + ISNULL('','' + CSM.STATENAME,'''')+ISNULL('','' + street,'''')+ISNULL('','' + city,'''') +'']''
  1379. FROM customerMaster (NOLOCK) CM
  1380. LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CM.STATE
  1381. WHERE 1 = 1 AND CM.approvedDate IS NOT NULL and ISNULL(isactive, ''Y'') = ''y'' '
  1382. IF @param1 = 'name'
  1383. BEGIN
  1384. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1385. END
  1386. ELSE IF @param1 = 'email'
  1387. BEGIN
  1388. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1389. END
  1390. ELSE IF @param1 = 'membershipId'
  1391. BEGIN
  1392. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1393. END
  1394. ELSE IF @param1 = 'mobile'
  1395. BEGIN
  1396. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1397. END
  1398. ELSE IF @param1 = 'customerId'
  1399. BEGIN
  1400. SET @SQL += 'AND postalCode = ''' + ISNULL(@searchText, '''') + ''''
  1401. END
  1402. ELSE IF @param1 = 'dob'
  1403. BEGIN
  1404. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1405. END
  1406. ELSE IF @param1 = 'membershipId'
  1407. BEGIN
  1408. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1409. END
  1410. ELSE IF @param1 = 'idNumber'
  1411. BEGIN
  1412. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1413. END
  1414. PRINT(@SQL)
  1415. EXEC (@SQL)
  1416. END;
  1417. IF @category = 'searchCustomerForCollModeChange'
  1418. BEGIN
  1419. DECLARE @CUSTOMERID BIGINT
  1420. SELECT @CUSTOMERID = S.CUSTOMERID
  1421. FROM REMITTRAN R(NOLOCK)
  1422. INNER JOIN TRANSENDERS S(NOLOCK) ON S.TRANID = R.ID
  1423. WHERE R.CONTROLNO = DBO.FNAENCRYPTSTRING(@searchText)
  1424. IF @CUSTOMERID IS NULL
  1425. BEGIN
  1426. SELECT CUSTOMERID
  1427. ,FULLNAME
  1428. FROM customerMaster(NOLOCK)
  1429. WHERE 1 = 2
  1430. RETURN
  1431. END
  1432. SET @SQL = 'SELECT TOP 20 customerId, [detail] = fullName + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''[''+email,'''') + '']''
  1433. + ''['' + ISNULL(zipcode,'''') + ISNULL('','' + CSM.STATENAME,'''')+ISNULL('','' + street,'''')+ISNULL('','' + city,'''') +'']''
  1434. FROM customerMaster (NOLOCK) CM
  1435. LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CM.STATE
  1436. WHERE CM.CUSTOMERID = ''' + CAST(@CUSTOMERID AS VARCHAR) + ''''
  1437. --PRINT(@SQL)
  1438. EXEC (@SQL)
  1439. END;
  1440. IF @category = 'searchCustomerForLog'
  1441. BEGIN
  1442. IF LEN(@searchText) < 3
  1443. BEGIN
  1444. SELECT CUSTOMERID
  1445. ,FULLNAME
  1446. FROM customerMaster(NOLOCK)
  1447. WHERE 1 = 2
  1448. RETURN
  1449. END
  1450. 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, '''') + '']''
  1451. FROM customerMaster (NOLOCK) WHERE 1 = 1 AND approvedDate IS NOT NULL '
  1452. IF @param1 = 'name'
  1453. BEGIN
  1454. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1455. END
  1456. ELSE IF @param1 = 'email'
  1457. BEGIN
  1458. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1459. END
  1460. ELSE IF @param1 = 'customerId'
  1461. BEGIN
  1462. SET @SQL += 'AND obpid LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1463. END
  1464. ELSE IF @param1 = 'membershipId'
  1465. BEGIN
  1466. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1467. END
  1468. ELSE IF @param1 = 'mobile'
  1469. BEGIN
  1470. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1471. END
  1472. ELSE IF @param1 = 'dob'
  1473. BEGIN
  1474. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1475. END
  1476. ELSE IF @param1 = 'LawsonCardNo'
  1477. BEGIN
  1478. SET @SQL += 'AND LawsonCardNo LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1479. END
  1480. --PRINT(@SQL)
  1481. EXEC (@SQL)
  1482. END;
  1483. IF @category = 'searchCustomerNew'
  1484. BEGIN
  1485. IF @param1 = 'receiverName'
  1486. BEGIN
  1487. IF LEN(@searchText) < 3
  1488. BEGIN
  1489. SELECT RECEIVERID
  1490. ,FULLNAME
  1491. FROM RECEIVERINFORMATION(NOLOCK)
  1492. WHERE 1 = 2
  1493. RETURN
  1494. END
  1495. 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,'''')
  1496. FROM receiverInformation RI (NOLOCK)
  1497. INNER JOIN CUSTOMERMASTER CM ( NOLOCK) ON CM.CUSTOMERID = RI.CUSTOMERID
  1498. WHERE 1 = 1 '
  1499. SET @SQL += 'AND RI.FULLNAME LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1500. PRINT @SQL
  1501. EXEC (@SQL)
  1502. END
  1503. ELSE
  1504. BEGIN
  1505. IF LEN(@searchText) < 3
  1506. BEGIN
  1507. SELECT CUSTOMERID
  1508. ,FULLNAME
  1509. FROM customerMaster(NOLOCK)
  1510. WHERE 1 = 2
  1511. RETURN
  1512. END
  1513. SET @SQL = 'SELECT TOP 20 customerId, [detail] = fullName + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''|''+email,'''')
  1514. FROM customerMaster cm (NOLOCK) WHERE 1 = 1 AND CM.approvedDate IS NOT NULL
  1515. '
  1516. IF @param1 = 'name'
  1517. BEGIN
  1518. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1519. END
  1520. ELSE IF @param1 = 'email'
  1521. BEGIN
  1522. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1523. END
  1524. ELSE IF @param1 = 'membershipId'
  1525. BEGIN
  1526. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1527. END
  1528. ELSE IF @param1 = 'customerId'
  1529. BEGIN
  1530. SET @SQL += 'AND POSTALCODE = ''' + ISNULL(@searchText, '''') + ''''
  1531. END
  1532. ELSE IF @param1 = 'membershipId'
  1533. BEGIN
  1534. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1535. END
  1536. ELSE IF @param1 = 'dob'
  1537. BEGIN
  1538. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1539. END
  1540. ELSE IF @param1 = 'mobile'
  1541. BEGIN
  1542. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1543. END
  1544. ELSE IF @param1 = 'idNumber'
  1545. BEGIN
  1546. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1547. END
  1548. --PRINT(@SQL)
  1549. EXEC (@SQL)
  1550. END
  1551. END;
  1552. ELSE IF @category = 'referralCode'
  1553. BEGIN
  1554. IF LEN(@searchText) >= 3
  1555. BEGIN
  1556. SELECT TOP 30 REFERRAL_CODE
  1557. ,REFERRAL_NAME
  1558. FROM REFERRAL_AGENT_WISE(NOLOCK)
  1559. WHERE REFERRAL_CODE LIKE @searchText + '%'
  1560. OR REFERRAL_NAME LIKE @searchText + '%'
  1561. AND IS_ACTIVE = 1
  1562. --AND AGENT_ID = 0
  1563. --AND REFERRAL_TYPE_CODE <> 'RB'
  1564. RETURN;
  1565. END
  1566. SELECT TOP 30 REFERRAL_CODE
  1567. ,REFERRAL_NAME
  1568. FROM REFERRAL_AGENT_WISE(NOLOCK)
  1569. WHERE 1 = 2
  1570. RETURN;
  1571. END
  1572. ELSE IF @category = 'referralCodeNew'
  1573. BEGIN
  1574. IF LEN(@searchText) >= 3
  1575. BEGIN
  1576. SELECT TOP 30 REFERRAL_CODE
  1577. ,REFERRAL_NAME
  1578. FROM REFERRAL_AGENT_WISE(NOLOCK)
  1579. WHERE (
  1580. REFERRAL_CODE LIKE @searchText + '%'
  1581. OR REFERRAL_NAME LIKE @searchText + '%'
  1582. )
  1583. AND IS_ACTIVE = 1
  1584. AND ISNULL(STAFFRESIGN, 0) <> 1
  1585. --AND AGENT_ID = 0
  1586. --AND REFERRAL_TYPE_CODE <> 'RB'
  1587. RETURN;
  1588. END
  1589. SELECT TOP 30 REFERRAL_CODE
  1590. ,REFERRAL_NAME
  1591. FROM REFERRAL_AGENT_WISE(NOLOCK)
  1592. WHERE 1 = 2
  1593. RETURN;
  1594. END
  1595. ELSE IF @category = 'referralChange'
  1596. BEGIN
  1597. IF LEN(@searchText) >= 3
  1598. BEGIN
  1599. SELECT TOP 30 REFERRAL_CODE
  1600. ,REFERRAL_NAME
  1601. FROM REFERRAL_AGENT_WISE(NOLOCK)
  1602. WHERE REFERRAL_CODE LIKE @searchText + '%'
  1603. OR REFERRAL_NAME LIKE @searchText + '%'
  1604. AND IS_ACTIVE = 1
  1605. RETURN;
  1606. END
  1607. SELECT TOP 30 REFERRAL_CODE
  1608. ,REFERRAL_NAME
  1609. FROM REFERRAL_AGENT_WISE(NOLOCK)
  1610. WHERE 1 = 2
  1611. RETURN;
  1612. END
  1613. ELSE IF @category = 'CustomerName'
  1614. BEGIN
  1615. IF LEN(@searchText) < 3
  1616. BEGIN
  1617. SELECT TOP 30 customerId
  1618. ,[detail] = fullName + '[' + isnull(idNumber, '') + '] | ' + ISNULL(email, '')
  1619. FROM customerMaster WITH (NOLOCK)
  1620. WHERE 1 = 2
  1621. RETURN
  1622. END
  1623. SELECT TOP 30 customerId
  1624. ,[detail] = fullName + '[' + isnull(idNumber, '') + '] | ' + ISNULL(email, '')
  1625. FROM customerMaster WITH (NOLOCK)
  1626. WHERE fullName LIKE @searchText + '%' OR idNumber LIKE @searchText + '%'
  1627. RETURN
  1628. END
  1629. ELSE IF @category = 'MembershipId'
  1630. BEGIN
  1631. IF LEN(@searchText) < 3
  1632. BEGIN
  1633. SELECT TOP 30 customerId
  1634. , [detail] = ISNULL(fullName, '') + ' [ID:' + isnull(postalCode, membershipid) + '] [MOB:' + isnull(mobile, '') + '] [DOB:' + isnull(convert(varchar, DOB, 102), '') + '] [Email:'+ISNULL(email,'')+'] '
  1635. FROM customerMaster WITH (NOLOCK)
  1636. WHERE 1 = 2
  1637. RETURN
  1638. END
  1639. SELECT TOP 30 customerId
  1640. , [detail] = ISNULL(fullName, '') + ' [ID:' + isnull(postalCode, membershipid) + '] [MOB:' + isnull(mobile, '') + '] [DOB:' + isnull(convert(varchar, DOB, 102), '') + '] [Email:'+ISNULL(email,'')+'] '
  1641. FROM customerMaster WITH (NOLOCK)
  1642. WHERE membershipId LIKE @searchText + '%'
  1643. RETURN
  1644. END
  1645. ELSE IF @category = 'ReceiverName'
  1646. BEGIN
  1647. SELECT TOP 30 *
  1648. FROM (
  1649. SELECT receiverId
  1650. ,fullname = firstName + ISNULL(' ' + middleName, '') + ISNULL(' ' + lastName1, '') + ISNULL(' ' + lastName2, '')
  1651. FROM dbo.receiverInformation WITH (NOLOCK)
  1652. ) X
  1653. WHERE X.fullname LIKE @searchText + '%'
  1654. RETURN
  1655. END
  1656. ELSE IF @category = 'mapBankData'
  1657. BEGIN
  1658. IF LEN(@searchText) < 3
  1659. BEGIN
  1660. SELECT TOP 30 ROW_ID
  1661. ,[detail] = BANK_NAME
  1662. FROM API_BANK_LIST_TMP WITH (NOLOCK)
  1663. WHERE 1 = 2
  1664. RETURN
  1665. END
  1666. SELECT TOP 30 ROW_ID
  1667. ,[detail] = BANK_NAME + ISNULL(' | ' + BANK_CODE1, '')
  1668. FROM API_BANK_LIST_TMP WITH (NOLOCK)
  1669. WHERE BANK_NAME LIKE '%' + @searchText + '%'
  1670. RETURN
  1671. END
  1672. ELSE IF @category = 'CASHRPT'
  1673. BEGIN
  1674. IF LEN(@searchText) < 3
  1675. BEGIN
  1676. SELECT TOP 30 ROW_ID
  1677. ,[detail] = REFERRAL_NAME
  1678. FROM REFERRAL_AGENT_WISE WITH (NOLOCK)
  1679. WHERE 1 = 2
  1680. RETURN
  1681. END
  1682. SELECT TOP 30 REFERRAL_CODE
  1683. ,[detail] = REFERRAL_NAME
  1684. FROM REFERRAL_AGENT_WISE WITH (NOLOCK)
  1685. WHERE REFERRAL_NAME LIKE '%' + @searchText + '%'
  1686. AND REFERRAL_TYPE_CODE = 'RC'
  1687. RETURN
  1688. END
  1689. IF @category = 'searchCustomerIntroducerReport'
  1690. BEGIN
  1691. IF LEN(@searchText) < 3
  1692. BEGIN
  1693. SELECT CUSTOMERID
  1694. ,FULLNAME
  1695. FROM customerMaster(NOLOCK)
  1696. WHERE 1 = 2
  1697. RETURN
  1698. END
  1699. SET @SQL = '
  1700. SELECT TOP 20 cm.customerId, [detail] = cm.fullName + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''[''+email,'''') + '']''
  1701. + ''['' + ISNULL(zipcode,'''') + ISNULL('','' + CSM.STATENAME,'''')+ISNULL('','' + street,'''')+ISNULL('','' + city,'''') +'']''
  1702. FROM (
  1703. SELECT referelCode
  1704. FROM CustomerMaster (NOLOCK)
  1705. WHERE referelCode IS NOT NULL
  1706. )TMP
  1707. INNER JOIN customerMaster CM(NOLOCK) ON CM.membershipId = TMP.referelCode
  1708. LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CM.STATE
  1709. WHERE 1 = 1 AND CM.approvedDate IS NOT NULL and ISNULL(cm.isactive, ''Y'') = ''y'' '
  1710. IF @param1 = 'name'
  1711. BEGIN
  1712. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1713. END
  1714. ELSE IF @param1 = 'email'
  1715. BEGIN
  1716. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1717. END
  1718. ELSE IF @param1 = 'membershipId'
  1719. BEGIN
  1720. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1721. END
  1722. ELSE IF @param1 = 'mobile'
  1723. BEGIN
  1724. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1725. END
  1726. ELSE IF @param1 = 'customerId'
  1727. BEGIN
  1728. SET @SQL += 'AND postalCode = ''' + ISNULL(@searchText, '''') + ''''
  1729. END
  1730. ELSE IF @param1 = 'dob'
  1731. BEGIN
  1732. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1733. END
  1734. ELSE IF @param1 = 'membershipId'
  1735. BEGIN
  1736. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1737. END
  1738. ELSE IF @param1 = 'idNumber'
  1739. BEGIN
  1740. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1741. END
  1742. --PRINT(@SQL)
  1743. EXEC (@SQL)
  1744. END;
  1745. --IF @category = 'searchRejectedCustomer'
  1746. --BEGIN
  1747. -- IF LEN(@searchText) < 3
  1748. -- BEGIN
  1749. -- SELECT CUSTOMERID
  1750. -- ,FULLNAME
  1751. -- FROM customerMaster(NOLOCK)
  1752. -- WHERE 1 = 2
  1753. -- RETURN
  1754. -- END
  1755. -- SET @SQL = 'SELECT TOP 20 customerId, [detail] = fullName + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''|''+email,'''')
  1756. -- FROM customerMaster cm (NOLOCK) WHERE 1 = 1 AND CM.isActive = ''N''
  1757. -- '
  1758. -- IF @param1 = 'name'
  1759. -- BEGIN
  1760. -- SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1761. -- END
  1762. -- ELSE IF @param1 = 'email'
  1763. -- BEGIN
  1764. -- SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1765. -- END
  1766. -- ELSE IF @param1 = 'membershipId'
  1767. -- BEGIN
  1768. -- SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1769. -- END
  1770. -- ELSE IF @param1 = 'customerId'
  1771. -- BEGIN
  1772. -- SET @SQL += 'AND POSTALCODE = ''' + ISNULL(@searchText, '''') + ''''
  1773. -- END
  1774. -- ELSE IF @param1 = 'membershipId'
  1775. -- BEGIN
  1776. -- SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1777. -- END
  1778. -- ELSE IF @param1 = 'dob'
  1779. -- BEGIN
  1780. -- SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1781. -- END
  1782. -- ELSE IF @param1 = 'mobile'
  1783. -- BEGIN
  1784. -- SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1785. -- END
  1786. -- ELSE IF @param1 = 'idNumber'
  1787. -- BEGIN
  1788. -- SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1789. -- END
  1790. -- --PRINT(@SQL)
  1791. -- EXEC (@SQL)
  1792. -- END ;
  1793. IF @category = 'searchRejectedCustomer'
  1794. BEGIN
  1795. IF LEN(@searchText) < 3
  1796. BEGIN
  1797. SELECT CUSTOMERID
  1798. ,email
  1799. FROM customerMaster(NOLOCK)
  1800. WHERE 1 = 2
  1801. RETURN
  1802. END
  1803. 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, '''') + '']''
  1804. --[detail]= email
  1805. FROM customerMaster cm (NOLOCK)
  1806. WHERE 1 = 1 AND CM.isActive = ''N'''
  1807. IF @param1 = 'name'
  1808. BEGIN
  1809. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1810. END
  1811. ELSE IF @param1 = 'email'
  1812. BEGIN
  1813. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1814. END
  1815. ELSE IF @param1 = 'membershipId'
  1816. BEGIN
  1817. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1818. END
  1819. ELSE IF @param1 = 'customerId'
  1820. BEGIN
  1821. SET @SQL += 'AND POSTALCODE = ''' + ISNULL(@searchText, '''') + ''''
  1822. END
  1823. ELSE IF @param1 = 'membershipId'
  1824. BEGIN
  1825. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1826. END
  1827. ELSE IF @param1 = 'dob'
  1828. BEGIN
  1829. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1830. END
  1831. ELSE IF @param1 = 'mobile'
  1832. BEGIN
  1833. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1834. END
  1835. ELSE IF @param1 = 'idNumber'
  1836. BEGIN
  1837. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1838. END
  1839. ELSE IF @param1 = 'LawsonCardNo'
  1840. BEGIN
  1841. SET @SQL += 'AND LawsonCardNo LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1842. END
  1843. --PRINT(@SQL)
  1844. EXEC (@SQL)
  1845. END;
  1846. IF @category = 'searchCustomerforMobileActivation'
  1847. BEGIN
  1848. IF LEN(@searchText) < 3
  1849. BEGIN
  1850. SELECT CUSTOMERID
  1851. ,FULLNAME
  1852. FROM customerMaster(NOLOCK)
  1853. WHERE 1 = 2
  1854. RETURN
  1855. END
  1856. 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, '''') + '']''
  1857. FROM customerMaster (NOLOCK) WHERE 1 = 1
  1858. and ISNULL(isActive,''Y'')=''Y''
  1859. and createdFrom =''C''
  1860. AND username is null
  1861. AND mobileApprovedDate is null '
  1862. IF @param1 = 'name'
  1863. BEGIN
  1864. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1865. END
  1866. ELSE IF @param1 = 'email'
  1867. BEGIN
  1868. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1869. END
  1870. ELSE IF @param1 = 'membershipId'
  1871. BEGIN
  1872. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1873. END
  1874. ELSE IF @param1 = 'customerId'
  1875. BEGIN
  1876. SET @SQL += 'AND POSTALCODE = ''' + ISNULL(@searchText, '''') + ''''
  1877. END
  1878. ELSE IF @param1 = 'membershipId'
  1879. BEGIN
  1880. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  1881. END
  1882. ELSE IF @param1 = 'dob'
  1883. BEGIN
  1884. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  1885. END
  1886. ELSE IF @param1 = 'mobile'
  1887. BEGIN
  1888. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1889. END
  1890. ELSE IF @param1 = 'idNumber'
  1891. BEGIN
  1892. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1893. END
  1894. ELSE IF @param1 = 'LawsonCardNo'
  1895. BEGIN
  1896. SET @SQL += 'AND LawsonCardNo LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1897. END
  1898. PRINT (@SQL)
  1899. EXEC (@SQL)
  1900. END;
  1901. --EXEC proc_autocomplete @category='CustomerName', @searchText='dham'
  1902. IF @category = 'referralnew' -- Select branchName List According to CountryName and AgentName
  1903. BEGIN
  1904. --SELECT REFERRAL_CODE
  1905. -- ,--as referral,
  1906. -- REFERRAL_NAME -- as referralName
  1907. --FROM REFERRAL_AGENT_WISE am WITH (NOLOCK)
  1908. --WHERE am.IS_ACTIVE = 1
  1909. --UNION ALL
  1910. SELECT am.agentCode AS REFERRAL_CODE
  1911. ,userName AS REFERRAL_NAME
  1912. FROM applicationUsers AU WITH (NOLOCK)
  1913. INNER JOIN AGENTMASTER AM WITH (NOLOCK) ON am.agentCode = au.agentCode
  1914. WHERE am.agentCountry = 'JAPAN'
  1915. AND am.isActive = 'Y'
  1916. AND AU.isActive = 'Y'
  1917. ORDER BY REFERRAL_NAME ASC
  1918. RETURN
  1919. END
  1920. IF @category = 'referralForCashCollect'
  1921. BEGIN
  1922. IF LEN(@searchText) < 3
  1923. BEGIN
  1924. SELECT TOP 30 *
  1925. FROM (
  1926. --SELECT REFERRAL_CODE
  1927. -- ,REFERRAL_NAME
  1928. --FROM REFERRAL_AGENT_WISE am WITH (NOLOCK)
  1929. --WHERE am.IS_ACTIVE = 1
  1930. --UNION ALL
  1931. SELECT am.agentCode AS REFERRAL_CODE
  1932. ,userName AS REFERRAL_NAME
  1933. FROM applicationUsers AU WITH (NOLOCK)
  1934. INNER JOIN AGENTMASTER AM WITH (NOLOCK) ON am.agentCode = au.agentCode
  1935. WHERE am.agentCountry = 'JAPAN'
  1936. AND am.isActive = 'Y'
  1937. AND AU.isActive = 'Y'
  1938. ) X
  1939. WHERE 1 = 2
  1940. -- AND userName LIKE '%@searchText%'
  1941. ORDER BY REFERRAL_NAME ASC
  1942. RETURN
  1943. END
  1944. --SELECT REFERRAL_CODE
  1945. -- ,REFERRAL_NAME
  1946. --FROM REFERRAL_AGENT_WISE am WITH (NOLOCK)
  1947. --WHERE am.IS_ACTIVE = 1
  1948. -- AND REFERRAL_NAME LIKE @searchText + '%'
  1949. --UNION ALL
  1950. SELECT am.agentCode AS REFERRAL_CODE
  1951. ,userName AS REFERRAL_NAME
  1952. FROM applicationUsers AU WITH (NOLOCK)
  1953. INNER JOIN AGENTMASTER AM WITH (NOLOCK) ON am.agentCode = au.agentCode
  1954. WHERE am.agentCountry = 'JAPAN'
  1955. AND am.isActive = 'Y'
  1956. AND AU.isActive = 'Y'
  1957. AND userName LIKE @searchText + '%'
  1958. --AND au.agentId=0
  1959. ORDER BY REFERRAL_NAME ASC
  1960. RETURN
  1961. END
  1962. IF @category = 'searchCustomerForReport'
  1963. BEGIN
  1964. IF LEN(@searchText) < 3
  1965. BEGIN
  1966. SELECT CUSTOMERID
  1967. ,FULLNAME
  1968. FROM customerMaster(NOLOCK)
  1969. WHERE 1 = 2
  1970. RETURN
  1971. END
  1972. --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,'''') + '']''
  1973. -- FROM customerMaster (NOLOCK) CM
  1974. -- LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CM.STATE
  1975. -- LEFT JOIN staticDataValue (NOLOCK) sdv ON sdv.typeId = cm.idType
  1976. -- WHERE 1 = 1
  1977. -- --AND CM.approvedDate IS NOT NULL and ISNULL(cm.isactive, ''Y'') = ''y''
  1978. -- '
  1979. SET @SQL = 'SELECT TOP 20 * FROM
  1980. ( 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,'''') + '']''
  1981. , email, membershipId, idNumber FROM customerMaster (NOLOCK) CM
  1982. LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CM.STATE
  1983. LEFT JOIN staticDataValue (NOLOCK) sdv ON sdv.typeId = cm.idType
  1984. WHERE 1 = 1
  1985. --AND CM.approvedDate IS NOT NULL and ISNULL(cm.isactive, ''Y'') = ''y''
  1986. UNION ALL
  1987. SELECT [customerId] = CAST(customerId AS VARCHAR) + ''|'' + ''temp'', [detail] = ISNULL(fullName,'''') + '' [ID:'' + isnull(idNumber,''N/A'') + '' ]'' +ISNULL(''[''+email,'''') + '']'' +ISNULL(''[''+membershipId,'''') + '']''
  1988. , email,membershipId,idNumber
  1989. FROM customerMasterTemp (NOLOCK) CT
  1990. )x where 1=1
  1991. '
  1992. IF @param1 = 'email'
  1993. BEGIN
  1994. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1995. END
  1996. ELSE IF @param1 = 'membershipId'
  1997. BEGIN
  1998. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  1999. END
  2000. ELSE IF @param1 = 'membershipId'
  2001. BEGIN
  2002. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  2003. END
  2004. ELSE IF @param1 = 'idNumber'
  2005. BEGIN
  2006. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2007. END
  2008. PRINT @SQL
  2009. EXEC (@SQL)
  2010. END;
  2011. IF @category = 'searchCustomerForReportKyc'
  2012. BEGIN
  2013. IF LEN(@searchText) < 3
  2014. BEGIN
  2015. SELECT CUSTOMERID
  2016. ,FULLNAME
  2017. FROM customerMaster(NOLOCK)
  2018. WHERE 1 = 2
  2019. RETURN
  2020. END
  2021. SET @SQL = '
  2022. SELECT TOP 20 * FROM (
  2023. SELECT customerId, [detail] = fullName + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''[''+email,'''') + '']
  2024. +'' , email,membershipId,idNumber
  2025. FROM customerMaster (NOLOCK) CM
  2026. LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CM.STATE
  2027. LEFT JOIN staticDataValue (NOLOCK) sdv ON sdv.typeId = cm.idType
  2028. WHERE 1 = 1 AND CM.approvedDate IS NOT NULL and ISNULL(cm.isactive, ''Y'') = ''y''
  2029. UNION ALL
  2030. SELECT customerId, [detail] = ISNULL(fullName,'''') + '' [ID:'' + isnull(membershipid,''N/A'') + '' ]'' +ISNULL(''[''+email,'''') + '']''
  2031. , email,membershipId,idNumber
  2032. FROM customerMasterTemp (NOLOCK) CT
  2033. --LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CT.STATE
  2034. --LEFT JOIN staticDataValue (NOLOCK) sdv ON sdv.typeId = CT.idType
  2035. )x WHERE 1=1
  2036. '
  2037. IF @param1 = 'email'
  2038. BEGIN
  2039. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2040. END
  2041. ELSE IF @param1 = 'membershipId'
  2042. BEGIN
  2043. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2044. END
  2045. ELSE IF @param1 = 'idNumber'
  2046. BEGIN
  2047. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2048. END
  2049. PRINT(@SQL)
  2050. EXEC (@SQL)
  2051. END;
  2052. IF @category = 'searchCustomerForLawsonCard'
  2053. BEGIN
  2054. IF LEN(@searchText) < 3
  2055. BEGIN
  2056. SELECT CUSTOMERID
  2057. ,FULLNAME
  2058. FROM customerMaster(NOLOCK)
  2059. WHERE 1 = 2
  2060. RETURN
  2061. END
  2062. SET @SQL = 'SELECT TOP 20 customerId, [detail] = isnull(fullName,'''') + '' [ID:'' + isnull(postalCode, membershipid) + ''] [MOB:'' + isnull(mobile, '''') + ''] [DOB:'' + isnull(convert(varchar, DOB, 102), '''') + ''] ''+ISNULL(''[''+email,'''') + '']''
  2063. + ''['' + ISNULL(zipcode,'''') + ISNULL('','' + CSM.STATENAME,'''')+ISNULL('','' + street,'''')+ISNULL('','' + city,'''') +'']''
  2064. FROM customerMaster (NOLOCK) CM
  2065. LEFT JOIN COUNTRYSTATEMASTER CSM (NOLOCK) ON CSM.STATEID = CM.STATE
  2066. LEFT JOIN staticDataValue (NOLOCK) sdv ON sdv.typeId = cm.idType
  2067. WHERE 1 = 1
  2068. AND CM.approvedDate IS NOT NULL and ISNULL(cm.isactive, ''Y'') = ''Y''
  2069. AND CM.lawsoncardNo IS NULL
  2070. '
  2071. PRINT @param1
  2072. IF @param1 = 'name'
  2073. BEGIN
  2074. SET @SQL += 'AND fullName LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2075. END
  2076. ELSE IF @param1 = 'email'
  2077. BEGIN
  2078. SET @SQL += 'AND email LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2079. END
  2080. ELSE IF @param1 = 'membershipId'
  2081. BEGIN
  2082. SET @SQL += 'AND membershipId LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2083. END
  2084. ELSE IF @param1 = 'mobile'
  2085. BEGIN
  2086. SET @SQL += 'AND mobile LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2087. END
  2088. ELSE IF @param1 = 'customerId'
  2089. BEGIN
  2090. SET @SQL += 'AND postalCode = ''' + ISNULL(@searchText, '''') + ''''
  2091. END
  2092. ELSE IF @param1 = 'dob'
  2093. BEGIN
  2094. SET @SQL += 'AND CONVERT(VARCHAR(10), DOB, 121) = ''' + ISNULL(@searchText, '''') + ''''
  2095. END
  2096. ELSE IF @param1 = 'membershipId'
  2097. BEGIN
  2098. SET @SQL += 'AND membershipId = ''' + ISNULL(@searchText, '''') + ''''
  2099. END
  2100. ELSE IF @param1 = 'idNumber'
  2101. BEGIN
  2102. SET @SQL += 'AND idNumber LIKE ''%' + ISNULL(@searchText, '''') + '%'''
  2103. END
  2104. EXEC (@SQL)
  2105. END
  2106. ELSE IF @category = 'CustomerForLawson'
  2107. BEGIN
  2108. IF LEN(@searchText) < 3
  2109. BEGIN
  2110. SELECT TOP 30 customerId
  2111. ,[detail] = fullName + '[' + isnull(idNumber, '') + '] | ' + ISNULL(email, '') + ISNULL(lawsonCardNo, '')
  2112. FROM customerMaster WITH (NOLOCK)
  2113. WHERE 1 = 2
  2114. AND LawsonCardNo is not null
  2115. RETURN
  2116. END
  2117. SELECT TOP 30 customerId
  2118. ,[detail] = fullName + '[' + isnull(idNumber, '') + '] | ' + ISNULL(email, '') + ISNULL(lawsonCardNo, '')
  2119. FROM customerMaster WITH (NOLOCK)
  2120. WHERE LawsonCardNo is not null
  2121. AND (fullName LIKE @searchText + '%' OR lawsonCardNo LIKE @searchText + '%' )
  2122. RETURN
  2123. END
  2124. ELSE IF @category = 'getAgentForFreeSC'
  2125. BEGIN
  2126. IF LEN(@searchText) < 3
  2127. BEGIN
  2128. SELECT top 30 au.userId,
  2129. [detail] = au.username + ' | ' + AU.firstName + ISNULL(AU.middleName,'') + AU.lastName + '[' + AM.agentName + ']'
  2130. FROM applicationUsers(NOLOCK) AU
  2131. INNER JOIN agentMaster (NOLOCK) AM ON AM.AGENTID = AU.AGENTID
  2132. WHERE 1 = 2
  2133. AND AM.actAsBranch = 'Y' AND AU.isActive = 'Y'
  2134. RETURN
  2135. END
  2136. SELECT top 30 au.userId,
  2137. [detail] = au.username + ' | ' + AU.firstName + ' ' + + ISNULL(AU.middleName,'') + AU.lastName + '[' + AM.agentName + ']'
  2138. FROM applicationUsers(NOLOCK) AU
  2139. INNER JOIN agentMaster (NOLOCK) AM ON AM.AGENTID = AU.AGENTID
  2140. WHERE AM.actAsBranch = 'Y' AND AU.isActive = 'Y'
  2141. AND (firstName LIKE @searchText + '%')
  2142. RETURN
  2143. END
  2144. IF @category = 'searchCustomer-delete-mobile'
  2145. BEGIN
  2146. IF LEN(@searchText) < 3
  2147. BEGIN
  2148. SELECT CUSTOMERID
  2149. ,FULLNAME
  2150. FROM customerMaster(NOLOCK)
  2151. WHERE 1 = 2
  2152. RETURN
  2153. END
  2154. SET @SQL = 'SELECT TOP 20 * FROM
  2155. ( 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, '''') + '']''
  2156. ,fullName,membershipId,mobile,idNumber,email,LawsonCardNo FROM customerMaster (NOLOCK) cm
  2157. INNER JOIN mobile_userRegistration(NOLOCK) mr ON mr.customerId = cm.customerId
  2158. and cm.createdFrom =''M''
  2159. WHERE 1=1 AND 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;