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.

593 lines
44 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_customerDetail] Script Date: 9/27/2019 1:30:14 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER OFF
  7. GO
  8. CREATE proc [dbo].[proc_customerDetail]
  9. @flag VARCHAR(50) = NULL
  10. ,@user VARCHAR(50) = NULL
  11. ,@membershipId VARCHAR(50) = NULL
  12. ,@id INT = NULL
  13. ,@sortBy VARCHAR(50) = NULL
  14. ,@sortOrder VARCHAR(5) = NULL
  15. ,@pageSize INT = NULL
  16. ,@pageNumber INT = NULL
  17. ,@name VARCHAR(200) = NULL
  18. ,@fileName VARCHAR(50) = NULL
  19. ,@fileDescription VARCHAR(100) = NULL
  20. ,@fileType VARCHAR(10) = NULL
  21. ,@hasChanged CHAR(1) = NULL
  22. ,@sMembershipId VARCHAR(50) = NULL
  23. ,@sFirstName VARCHAR(200) = NULL
  24. ,@sMiddleName VARCHAR(200) = NULL
  25. ,@sLastName VARCHAR(200) = NULL
  26. ,@sContactNo VARCHAR(50) = NULL
  27. ,@rMembershipId VARCHAR(50) = NULL
  28. ,@rFullName VARCHAR(100) = NULL
  29. ,@rMobile VARCHAR(50) = NULL
  30. ,@rReceiverId INT = NULL
  31. ,@isApproved CHAR(1) = NULL
  32. ,@searchBy VARCHAR(50) = NULL
  33. ,@searchValue VARCHAR(200) = NULL
  34. ,@customerId VARCHAR(50) = NULL
  35. ,@sAmount MONEY = NULL
  36. ,@sAmountThreshold MONEY = NULL
  37. AS
  38. SET NOCOUNT ON
  39. SET XACT_ABORT ON
  40. BEGIN TRY
  41. CREATE TABLE #msg(errorCode INT, msg VARCHAR(100), id INT)
  42. DECLARE
  43. @sql VARCHAR(MAX)
  44. ,@oldValue VARCHAR(MAX)
  45. ,@newValue VARCHAR(MAX)
  46. ,@module VARCHAR(10)
  47. ,@tableAlias VARCHAR(100)
  48. ,@logIdentifier VARCHAR(50)
  49. ,@logParamMod VARCHAR(100)
  50. ,@logParamMain VARCHAR(100)
  51. ,@table VARCHAR(MAX)
  52. ,@select_field_list VARCHAR(MAX)
  53. ,@extra_field_list VARCHAR(MAX)
  54. ,@sql_filter VARCHAR(MAX)
  55. ,@modType VARCHAR(6)
  56. ,@errorMsg VARCHAR(MAX)
  57. SELECT
  58. @logIdentifier = 'id'
  59. ,@logParamMain = 'Customer Master'
  60. ,@module = '20'
  61. ,@tableAlias = 'customerMaster'
  62. DECLARE @TranId INT,
  63. @ReceiverID AS VARCHAR(100)
  64. -- ## sender information for normal send
  65. IF @flag = 'CS'
  66. BEGIN
  67. IF NOT EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK)
  68. WHERE membershipId = @membershipId AND ISNULL(isDeleted, 'N') <> 'Y')
  69. BEGIN
  70. EXEC proc_errorHandler 1, 'Customer with this Membership Id not found', NULL
  71. END
  72. ELSE IF EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK) WHERE membershipId = @membershipId AND ISNULL(isDeleted, 'N') <> 'Y' AND rejectedDate IS NULL AND expiryDate<=Convert(date,GETDATE(),101))
  73. BEGIN
  74. SELECT 1 errorCode, 'This IME membership ID has expired on '+Cast(expiryDate as varchar)+', please inform to renew Membership card!' msg, NULL from customerMaster WITH(NOLOCK)
  75. WHERE membershipId = @membershipId
  76. END
  77. ELSE IF EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK)
  78. WHERE membershipId = @membershipId
  79. AND ISNULL(isDeleted, 'N') <> 'Y'
  80. AND ISNULL(isBlackListed, 'N') = 'Y')
  81. BEGIN
  82. EXEC proc_errorHandler 1, 'This customer is blacklisted. Cannot proceed for transaction.', NULL
  83. END
  84. ELSE IF EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK)
  85. WHERE membershipId = @membershipId
  86. AND ISNULL(isDeleted, 'N') <> 'Y'
  87. AND approvedDate IS NULL)
  88. BEGIN
  89. EXEC proc_errorHandler 1, 'Customer with this membership ID has not been approved yet. Please contact head office.', NULL
  90. END
  91. ELSE
  92. BEGIN
  93. EXEC proc_errorHandler 0, 'Customer Found', NULL
  94. END
  95. SELECT
  96. cm.customerId customerId
  97. ,isnull(cm.firstName,'') firstName
  98. ,isnull(cm.middleName,'') middleName
  99. ,isnull(cm.lastName,'') lastName1
  100. ,'' lastName2
  101. ,isnull(cm.pMunicipality,'')+' '+isnull(cm.pdistrict,'')+' '+isnull(cm.pzone,'')+' '+isnull(cm.pcountry,'') [address]
  102. ,isnull(cm.mobile,'') mobile
  103. --,'1301' idType
  104. ,sdv.valueId idType
  105. ,cm.citizenshipNo idNumber
  106. ,isnull(cm.email,'') email
  107. FROM customerMaster cm WITH(NOLOCK)
  108. LEFT JOIN staticDataValue sdv with(nolock) on sdv.detailTitle=cm.idType
  109. WHERE cm.membershipId = @membershipId
  110. AND ISNULL(cm.isDeleted, 'N') <> 'Y'
  111. AND ISNULL(cm.isActive, 'Y') = 'Y'
  112. RETURN
  113. END
  114. -- ## sender & receiver information for normal send
  115. IF @flag = 'CS1'
  116. BEGIN
  117. -->>select * from customerMaster
  118. IF NOT EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK)
  119. WHERE membershipId = @membershipId AND ISNULL(isDeleted, 'N') <> 'Y')
  120. BEGIN
  121. EXEC proc_errorHandler 1, 'Customer with this CUSTOMER CARD NUMBER not found!', NULL
  122. RETURN;
  123. END
  124. IF EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK)
  125. WHERE membershipId = @membershipId AND ISNULL(isDeleted, 'N') <> 'Y' AND expiryDate<=Convert(date,GETDATE(),101))
  126. BEGIN
  127. SELECT 1 errorCode, 'This IME membership ID has expired on '+Cast(expiryDate as varchar)+', please inform to renew Membership card!' msg, NULL from customerMaster WITH(NOLOCK)
  128. WHERE membershipId = @membershipId
  129. RETURN;
  130. END
  131. IF EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK)
  132. WHERE membershipId = @membershipId
  133. AND ISNULL(isDeleted, 'N') <> 'Y'
  134. AND ISNULL(isBlackListed, 'N') = 'Y')
  135. BEGIN
  136. EXEC proc_errorHandler 1, 'This customer is blacklisted. Cannot proceed for transaction.', NULL
  137. RETURN;
  138. END
  139. IF EXISTS(
  140. SELECT 'X' FROM customerMaster WITH(NOLOCK)
  141. WHERE membershipId = @membershipId
  142. AND ISNULL(isDeleted, 'N') <> 'Y'
  143. AND ISNULL(isActive, 'Y') <> 'Y'
  144. )
  145. --AND approvedDate IS NULL)
  146. BEGIN
  147. --EXEC proc_errorHandler 1, 'Customer with this membership ID has not been approved yet. Please contact head office.', NULL
  148. EXEC proc_errorHandler 1, 'Customer with this membership ID is not active. Please contact head office.', NULL
  149. RETURN;
  150. END
  151. IF EXISTS(
  152. SELECT 'X' FROM customerMaster WITH(NOLOCK)
  153. WHERE membershipId = @membershipId
  154. AND ISNULL(isDeleted, 'N') <> 'Y'
  155. AND approvedDate IS NULL
  156. )
  157. BEGIN
  158. IF ISNULL(@sAmountThreshold,0) <> 0 AND ISNULL(@sAmount,0)<>0
  159. BEGIN
  160. IF @sAmount >= @sAmountThreshold
  161. BEGIN
  162. EXEC proc_errorHandler 1, 'Customer with this membership ID is not approved yet. Unapproved customer cannot send money greater than or equals to threshold amount using customer card. Please contact head office.', NULL
  163. RETURN;
  164. END
  165. END
  166. END
  167. SELECT
  168. TOP 1 @TranId = C.tranId
  169. FROM tranSenders C WITH(NOLOCK)
  170. WHERE C.membershipId = @membershipId
  171. order by id desc
  172. SELECT errCode = ISNULL(errCode,'') ,
  173. sCustomerId = ISNULL(sCustomerId,''),
  174. sCustomerCardNo = ISNULL(sCustomerCardNo,''),
  175. sFirstName = ISNULL(sFirstName,''),
  176. sMiddleName = ISNULL(sMiddleName,''),
  177. sLastName1 = ISNULL(sLastName1,''),
  178. sLastName2 = ISNULL(sLastName2,''),
  179. sAddress = ISNULL(sAddress,''),
  180. sMobile = ISNULL(sMobile,''),
  181. sIdType = ISNULL(cast(sIdType as varchar),''),
  182. sIdType1 = ISNULL(sIdType1,''),
  183. sIdNumber = ISNULL(sIdNumber,''),
  184. sEmail = ISNULL(sEmail,''),
  185. tranId = ISNULL(sen.tranId,''),
  186. rCustomerId = ISNULL(rCustomerId,''),
  187. rCustomerCardNo = ISNULL(rCustomerCardNo,''),
  188. rFirstName = ISNULL(rFirstName,''),
  189. rMiddleName = ISNULL(rMiddleName,''),
  190. rLastName1 = ISNULL(rLastName1,''),
  191. rLastName2 = ISNULL(rLastName2,''),
  192. rAddress = ISNULL(rAddress,''),
  193. rMobile = ISNULL(rMobile,''),
  194. rIdType = ISNULL(cast(rIdType as varchar),''),
  195. rIdNumber = ISNULL(rIdNumber,''),
  196. rEmail = ISNULL(rEmail,''),
  197. sIdIssuedDate=ISNULL(issueDate,''),
  198. sIdIssuedDateBs=ISNULL(issueDateNp,''),
  199. sDOB=ISNULL(dobEng,''),
  200. sDOBBs=ISNULL(dobNep,''),
  201. sIdExpiryDate=ISNULL(expiryDate,''),
  202. sIdExpiryDateBs=ISNULL(expiryDateNp,''),
  203. sOccupation=ISNULL(occupation,''),
  204. sGender=ISNULL(gender,''),
  205. sFatherMotherName=ISNULL(fatherMotherName,''),
  206. sPlaceOfIssue=ISNULL(placeOfIssue,'')
  207. FROM
  208. (
  209. SELECT TOP 1
  210. errCode = '0'
  211. ,sCustomerId = cust.customerId
  212. ,sCustomerCardNo = cust.membershipId
  213. ,sFirstName = ISNULL(cust.firstName,'')
  214. ,sMiddleName = ISNULL(cust.middleName,'')
  215. ,sLastName1 = ISNULL( cust.lastName,'')
  216. ,sLastName2 = ''
  217. ,sAddress = ISNULL(' '+cust.pMunicipality,'')+isnull(' '+cust.pdistrict,'')+isnull(' '+cust.pzone,'')+isnull(' '+cust.pcountry,'') +ISNULL(' '+cust.pTole,'')
  218. ,sMobile = ISNULL(cust.mobile,'')
  219. ,sIdType = ISNULL(cust.idType,'') --'1301'
  220. ,sIdType1 = dbo.FNAGetIDType(cust.idType,'151')+ '|' + ISNULL(cit.expiryType, 'E') --CAST(cust.idType AS VARCHAR)
  221. ,sIdNumber = cust.citizenshipNo
  222. ,sEmail = ISNULL(cust.email,'')
  223. ,tranId = @TranId
  224. ,issueDate=convert(varchar,issueDate,101)
  225. ,issueDateNp
  226. ,dobEng,dobNep
  227. ,expiryDate=convert(varchar,expiryDate,101)
  228. ,expiryDateNp
  229. ,occupation
  230. ,gender
  231. ,fatherMotherName= ISNULL(fatherName,motherName)
  232. ,placeOfIssue
  233. FROM customerMaster cust WITH(NOLOCK)
  234. --LEFT JOIN countryIdType cit WITH(NOLOCK) ON cust.idType = CAST(cit.IdTypeId AS VARCHAR) AND countryId='151'
  235. LEFT JOIN countryIdType cit WITH(NOLOCK) ON dbo.FNAGetIDType(cust.idType,'151') = CAST(cit.IdTypeId AS VARCHAR) AND countryId='151'
  236. WHERE cust.membershipId = @membershipId
  237. AND ISNULL(cust.isDeleted, 'N') <> 'Y'
  238. AND ISNULL(cust.isActive, 'Y') = 'Y'
  239. )sen left join
  240. (
  241. SELECT
  242. rCustomerId = ISNULL(cust.customerId,rec.customerId)
  243. ,rCustomerCardNo = ISNULL(cust.membershipId,rec.membershipId)
  244. ,rFirstName = ISNULL(cust.firstName,rec.firstName)
  245. ,rMiddleName = ISNULL(cust.middleName,rec.middleName)
  246. ,rLastName1 = ISNULL(cust.lastName,rec.lastName1)
  247. ,rLastName2 = ISNULL(rec.lastName2,'')
  248. ,rAddress = case when cust.customerId is not null then
  249. isnull(cust.pMunicipality,'')+' '+isnull(cust.pdistrict,'')+' '+isnull(cust.pzone,'')+' '+isnull(cust.pcountry,'')
  250. else
  251. rec.address
  252. end
  253. ,rMobile = ISNULL(cust.mobile,rec.mobile)
  254. ,rIdType = '1301'
  255. ,rIdNumber = cust.citizenshipNo
  256. ,rEmail = isnull(cust.email,rec.email)
  257. ,tranId = @TranId
  258. FROM tranReceivers rec with(nolock)
  259. LEFT JOIN customerMaster cust WITH(NOLOCK) on rec.membershipId=cust.membershipId
  260. LEFT JOIN staticDataValue sdv with(nolock) on sdv.detailTitle=rec.idType
  261. AND ISNULL(cust.isDeleted, 'N') <> 'Y'
  262. AND ISNULL(cust.isActive, 'Y') = 'Y'
  263. WHERE rec.tranId=@TranId
  264. ) rec on sen.tranId=rec.tranId
  265. return
  266. END
  267. IF @flag='p'
  268. BEGIN
  269. IF @membershipId IS NULL
  270. SELECT @membershipId=membershipId FROM customerMaster with(nolock) WHERE customerId=@id
  271. SELECT fileName [fileName],
  272. CASE
  273. WHEN fileDescription='Enrollform'
  274. THEN 'Enrollment Form'
  275. WHEN fileDescription='IdCard'
  276. THEN 'Primary Id Card'
  277. ELSE fileDescription
  278. END fileDescription
  279. FROM customerDocument a WITH(NOLOCK)
  280. INNER JOIN customerMaster b WITH(NOLOCK) ON a.customerId=b.customerId
  281. WHERE b.membershipId=@membershipId ORDER BY isProfilePic DESC
  282. END
  283. -- ## receiver information for third party payment
  284. IF @flag = 'CS2'
  285. BEGIN
  286. IF NOT EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK)
  287. WHERE membershipId = @membershipId AND ISNULL(isDeleted, 'N') <> 'Y' AND rejectedDate IS NULL)
  288. BEGIN
  289. EXEC proc_errorHandler 1, 'Customer with this Membership Id not found', NULL
  290. END
  291. ELSE IF EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK)
  292. WHERE membershipId = @membershipId
  293. AND ISNULL(isDeleted, 'N') <> 'Y'
  294. AND ISNULL(isBlackListed, 'N') = 'Y')
  295. BEGIN
  296. EXEC proc_errorHandler 1, 'This customer is blacklisted. Cannot proceed for transaction.', NULL
  297. END
  298. ELSE IF EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK)
  299. WHERE membershipId = @membershipId
  300. AND ISNULL(isDeleted, 'N') <> 'Y'
  301. AND approvedDate IS NULL)
  302. BEGIN
  303. EXEC proc_errorHandler 1, 'Customer with this membership ID has not been approved yet. Please contact head office.', NULL
  304. END
  305. ELSE
  306. BEGIN
  307. EXEC proc_errorHandler 0, 'Customer Found', NULL
  308. END
  309. SELECT
  310. customerId customerId
  311. ,'1301' idType
  312. ,ISNULL(citizenshipNo,'') idNumber
  313. ,ISNULL(pDistrict,'') district
  314. ,ISNULL(mobile,'') mobile
  315. ,REPLACE(ISNULL(firstName, '') + ISNULL(' ' + middleName, '') + ISNULL(' ' + lastName, ''), ' ', ' ') fullName
  316. ,'2101' relationType
  317. ,isnull(fatherName,'') relativeName
  318. FROM customerMaster cust WITH(NOLOCK)
  319. WHERE cust.membershipId = @membershipId
  320. AND ISNULL(cust.isDeleted, 'N') <> 'Y'
  321. AND ISNULL(cust.isActive, 'Y') = 'Y'
  322. RETURN
  323. END
  324. -- ## receiver information for money gram
  325. IF @flag = 'rPayMg'
  326. BEGIN
  327. IF NOT EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK)
  328. WHERE membershipId = @membershipId AND ISNULL(isDeleted, 'N') <> 'Y' AND rejectedDate IS NULL)
  329. BEGIN
  330. EXEC proc_errorHandler 1, 'Customer with this Membership Id not found', NULL
  331. END
  332. ELSE IF EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK)
  333. WHERE membershipId = @membershipId
  334. AND ISNULL(isDeleted, 'N') <> 'Y'
  335. AND ISNULL(isBlackListed, 'N') = 'Y')
  336. BEGIN
  337. EXEC proc_errorHandler 1, 'This customer is blacklisted. Cannot proceed for transaction.', NULL
  338. END
  339. ELSE
  340. BEGIN
  341. EXEC proc_errorHandler 0, 'Customer Found', NULL
  342. END
  343. SELECT
  344. customerId customerId
  345. ,'1301' idType
  346. ,ISNULL(citizenshipNo,'') idNumber
  347. ,ISNULL(pDistrict,'') district
  348. ,ISNULL(mobile,'') mobile
  349. ,REPLACE(ISNULL(firstName, '') + ISNULL(' ' + middleName, '') + ISNULL(' ' + lastName, ''), ' ', ' ') fullName
  350. ,'2101' relationType
  351. ,isnull(fatherName,'') relativeName
  352. FROM customerMaster cust WITH(NOLOCK)
  353. WHERE cust.membershipId = @membershipId
  354. AND ISNULL(cust.isDeleted, 'N') <> 'Y'
  355. AND ISNULL(cust.isActive, 'Y') = 'Y'
  356. RETURN
  357. END
  358. -- ## Select Receiver History By Sender Information
  359. IF @flag = 'viewHistory'
  360. BEGIN
  361. IF @sortBy IS NULL
  362. SET @sortBy = 'id'
  363. IF @sortOrder IS NULL
  364. SET @sortOrder = 'ASC'
  365. SET @table = '(
  366. SELECT
  367. Id = rec.id,
  368. rCustomerId = rec.customerId,
  369. rMembershipId = rec.membershipId,
  370. rFullName = ISNULL(rec.firstName, '''') + ISNULL('' '' + rec.middleName, '''')+ ISNULL('' '' + rec.lastName1, '''')+ ISNULL('' '' + rec.lastName2, '''') ,
  371. rMobile = rec.mobile,
  372. rIdType = rec.idType,
  373. rIdNumber = rec.idNumber,
  374. rAddress = rec.address
  375. FROM tranReceivers rec WITH(NOLOCK)
  376. INNER JOIN tranSenders sen WITH(NOLOCK) ON rec.tranId=sen.tranId
  377. WHERE 1=1
  378. '
  379. IF @sMembershipId IS NOT NULL
  380. SET @table = @table + ' AND sen.membershipId = ''' + CAST(@sMembershipId AS VARCHAR) + ''''
  381. ELSE
  382. BEGIN
  383. SET @table = @table + ' AND isnull(sen.firstName,'''') = ''' + CAST(ISNULL(@sFirstName,'') AS VARCHAR) + ''''
  384. SET @table = @table + ' AND isnull(sen.middleName,'''')= ''' + CAST(ISNULL(@sMiddleName,'') AS VARCHAR) + ''''
  385. SET @table = @table + ' AND isnull(sen.lastName1,'''') = ''' + CAST(ISNULL(@sLastName,'') AS VARCHAR) + ''''
  386. SET @table = @table + ' AND isnull(sen.mobile,'''')= ''' + CAST(ISNULL(@sContactNo,'') AS VARCHAR) + ''''
  387. END
  388. SET @table = @table + ')x'
  389. SET @sql_filter = ''
  390. IF @rMembershipId IS NOT NULL
  391. SET @sql_filter = @sql_filter + ' AND ISNULL(rMembershipId,'''') = ''' + @rMembershipId + ''''
  392. IF @rFullName IS NOT NULL
  393. SET @sql_filter = @sql_filter + ' AND ISNULL(rFullName,'''') LIKE ''%' + @rFullName + '%'''
  394. IF @rMobile IS NOT NULL
  395. SET @sql_filter = @sql_filter + ' AND ISNULL(rMobile,'''') = ''' + @rMobile + ''''
  396. SET @select_field_list ='
  397. id
  398. ,rCustomerId
  399. ,rMembershipId
  400. ,rFullName
  401. ,rMobile
  402. ,rIdType
  403. ,rIdNumber
  404. ,rAddress'
  405. EXEC dbo.proc_paging
  406. @table
  407. ,@sql_filter
  408. ,@select_field_list
  409. ,@extra_field_list
  410. ,@sortBy
  411. ,@sortOrder
  412. ,@pageSize
  413. ,@pageNumber
  414. END
  415. IF @flag='getReceiverById'
  416. BEGIN
  417. EXEC proc_errorHandler 0, 'Customer Found', NULL
  418. SELECT
  419. id,
  420. membershipId,
  421. customerId,
  422. ISNULL(firstName,'') firstName,
  423. ISNULL(middleName,'') middleName,
  424. ISNULL(lastName1,'') lastName1,
  425. ISNULL(mobile,'') mobile,
  426. ISNULL(val.valueId,'') idType,
  427. ISNULL(idNumber,'') idNumber,
  428. ISNULL(address,'') address
  429. FROM tranReceivers rec WITH(NOLOCK)
  430. LEFT JOIN staticDataValue val WITH(NOLOCK) ON rec.idType=val.detailTitle
  431. WHERE rec.id=@rReceiverId
  432. END
  433. IF @flag = 'LoadImages'
  434. BEGIN
  435. DECLARE @enrollForm VARCHAR(200),@idCard VARCHAR(200)
  436. select @enrollForm = [fileName] from customerDocument with(nolock) where customerId = @customerId and fileDescription ='Enrollform'
  437. select @idCard = [fileName] from customerDocument with(nolock) where customerId = @customerId and fileDescription ='IdCard'
  438. select
  439. imgForm =
  440. case when @enrollForm is not null
  441. then 'Enrollment Form : <img alt = "Enrollment Form" onclick = "ShowSenderCustomer();" style="height:50px;width:50px;" src="../../../../../doc/'+@enrollForm+'"/>'
  442. else 'Enrollment Form : <img alt = "Enrollment Form" onclick = "ShowSenderCustomer();" style="height:50px;width:50px;" src="../../../../../Images/na.gif" />'
  443. end
  444. ,imgID =
  445. case when @idCard is not null
  446. then 'ID Card : <img alt = "ID Card" onclick = "ShowSenderCustomer();" style="height:50px;width:50px;" src="../../../../../doc/'+@idCard+'"/>'
  447. else 'ID Card : <img alt = "ID Card" onclick = "ShowSenderCustomer();" style="height:50px;width:50px;" src="../../../../../Images/na.gif" />'
  448. end
  449. END
  450. IF @flag = 'LoadImagesAgent'
  451. BEGIN
  452. DECLARE @enrollForm1 VARCHAR(200),@idCard1 VARCHAR(200)
  453. select @enrollForm1 = [fileName] from customerDocument with(nolock) where customerId = @customerId and fileDescription ='Enrollform'
  454. select @idCard1 = [fileName] from customerDocument with(nolock) where customerId = @customerId and fileDescription ='IdCard'
  455. select
  456. imgForm =
  457. case when @enrollForm1 is not null
  458. then 'Enrollment Form : <img alt = "Enrollment Form" onclick = "ShowSenderCustomer();" style="height:50px;width:50px;" src="../../../../../doc/'+@enrollForm1+'"/>'
  459. else 'Enrollment Form : <img alt = "Enrollment Form" onclick = "ShowSenderCustomer();" style="height:50px;width:50px;" src="../../../../../Images/na.gif" />'
  460. end
  461. ,imgID =
  462. case when @idCard1 is not null
  463. then 'ID Card : <img alt = "ID Card" onclick = "ShowSenderCustomer();" style="height:50px;width:50px;" src="../../../../../doc/'+@idCard1+'"/>'
  464. else 'ID Card : <img alt = "ID Card" onclick = "ShowSenderCustomer();" style="height:50px;width:50px;" src="../../../../../Images/na.gif" />'
  465. end
  466. END
  467. -- ## SELECT CUSTOMER ACCRODING TO CUSTOMER CARD NUMBER FROM PAY PAGE To SHOW ON THIRD PARY PAY PAGE
  468. IF @flag = 'searchRecForThp'
  469. BEGIN
  470. IF NOT EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK)
  471. WHERE membershipId = @membershipId AND ISNULL(isDeleted, 'N') <> 'Y' AND rejectedDate IS NULL)
  472. BEGIN
  473. select errorCode ='1',errorMsg= 'Customer with this Membership Id not found'
  474. return
  475. END
  476. IF EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK) WHERE membershipId = @membershipId AND ISNULL(isDeleted, 'N') <> 'Y' AND rejectedDate IS NULL AND expiryDate<=Convert(date,GETDATE(),101))
  477. BEGIN
  478. SELECT 1 errorCode, 'This IME membership ID has expired on '+Cast(expiryDate as varchar)+', please inform to renew Membership card!' errorMsg, NULL from customerMaster WITH(NOLOCK)
  479. WHERE membershipId = @membershipId
  480. RETURN
  481. END
  482. ELSE IF EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK)
  483. WHERE membershipId = @membershipId
  484. AND ISNULL(isDeleted, 'N') <> 'Y'
  485. AND ISNULL(isBlackListed, 'N') = 'Y')
  486. BEGIN
  487. select errorCode ='1',errorMsg= 'This customer is blacklisted. Cannot proceed for transaction.'
  488. return
  489. END
  490. ELSE IF EXISTS(SELECT 'X' FROM customerMaster WITH(NOLOCK)
  491. WHERE membershipId = @membershipId
  492. AND ISNULL(isDeleted, 'N') <> 'Y'
  493. AND approvedDate is null)
  494. BEGIN
  495. select errorCode ='1',errorMsg= 'Customer has not been approved yet.'
  496. return
  497. END
  498. SELECT
  499. customerId
  500. --,idType = '1301'
  501. ,idType = sdv.valueId
  502. ,IdType1 = dbo.FNAGetIDType(cust.idType,'151')+ '|' + ISNULL(cit.expiryType, 'E') --CAST(cust.idType AS VARCHAR)
  503. ,idNumber = ISNULL(citizenshipNo,'')
  504. ,district = ISNULL(pDistrict,'')
  505. ,mobile = ISNULL(mobile,'')
  506. ,fullName = REPLACE(ISNULL(firstName, '') + ISNULL(' ' + middleName, '') + ISNULL(' ' + lastName, ''), ' ', ' ')
  507. ,relationType = '2101'
  508. ,relativeName = ISNULL(fatherName,'')
  509. ,country = isnull(pCountry,'')
  510. ,dob = isnull(dobNep,'')
  511. ,recOccupation = isnull(occupation,'')
  512. ,membershipId = @membershipId
  513. ,errorCode = '0'
  514. ,errorMsg = 'Customer Found'
  515. ,issueDate = convert(varchar,issueDate,101)
  516. ,issueDateNp
  517. ,dobEng = convert(varchar,dobEng,101)
  518. ,dobNep
  519. ,expiryDate = convert(varchar,expiryDate,101)
  520. ,expiryDateNp
  521. ,occupation
  522. ,gender
  523. ,placeOfIssue
  524. FROM customerMaster cust WITH(NOLOCK)
  525. LEFT JOIN staticDataValue sdv with(nolock) on sdv.detailTitle=cust.idType
  526. LEFT JOIN countryIdType cit WITH(NOLOCK) ON dbo.FNAGetIDType(cust.idType,'151') = CAST(cit.IdTypeId AS VARCHAR) AND countryId='151'
  527. WHERE cust.membershipId = @membershipId
  528. AND ISNULL(cust.isDeleted, 'N') <> 'Y'
  529. AND ISNULL(cust.isActive, 'Y') = 'Y'
  530. RETURN
  531. END
  532. END TRY
  533. BEGIN CATCH
  534. IF @@TRANCOUNT > 0
  535. ROLLBACK TRANSACTION
  536. DECLARE @errorMessage VARCHAR(MAX)
  537. SET @errorMessage = ERROR_MESSAGE()
  538. EXEC proc_errorHandler 1, @errorMessage, @id
  539. END CATCH
  540. GO