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.

129 lines
3.7 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_addCommentAPI] Script Date: 7/4/2019 11:35:48 AM ******/
  4. DROP PROCEDURE [dbo].[proc_addCommentAPI]
  5. GO
  6. /****** Object: StoredProcedure [dbo].[proc_addCommentAPI] Script Date: 7/4/2019 11:35:48 AM ******/
  7. SET ANSI_NULLS ON
  8. GO
  9. SET QUOTED_IDENTIFIER ON
  10. GO
  11. ALTER proc [dbo].[proc_addCommentAPI] (
  12. @flag VARCHAR(50)
  13. ,@controlNo VARCHAR(20) = NULL
  14. ,@user VARCHAR(30) = NULL
  15. ,@agentRefId VARCHAR(50) = NULL
  16. ,@tranId INT = NULL
  17. ,@message VARCHAR(200) = NULL
  18. ,@sendSmsEmail VARCHAR(10) = NULL
  19. )
  20. AS
  21. DECLARE
  22. @sAgent INT
  23. ,@tAmt MONEY
  24. ,@cAmt MONEY
  25. ,@pAmt MONEY
  26. SET NOCOUNT ON
  27. SET XACT_ABORT ON
  28. DECLARE
  29. @code VARCHAR(50)
  30. ,@userName VARCHAR(50)
  31. ,@password VARCHAR(50)
  32. EXEC proc_GetAPI @user OUTPUT,@code OUTPUT, @userName OUTPUT, @password OUTPUT
  33. DECLARE @controlNoEncrypted VARCHAR(20)
  34. SELECT @controlNoEncrypted = dbo.FNAEncryptString(@controlNo)
  35. DECLARE
  36. @msg VARCHAR(MAX)
  37. ,@mobileNo VARCHAR(100)
  38. ,@country VARCHAR(100)
  39. ,@branchId VARCHAR(100)
  40. ,@agentId VARCHAR(100)
  41. ,@email VARCHAR(100)
  42. ,@subject VARCHAR(100)
  43. ,@agentName VARCHAR(100)
  44. ,@branchName VARCHAR(100)
  45. --IF @message IS NOT NULL
  46. --BEGIN
  47. -- SET @msg= 'Dear Customer, '+@message+' '+'Please confirm the detail and visit sending agent,if modification required.'
  48. -- --Check Mobile No and Email
  49. -- SELECT
  50. -- @mobileNo=ts.mobile,@country=ts.country
  51. -- FROM RemitTran rt (NOLOCK)
  52. -- INNER JOIN tranSenders ts (NOLOCK) on rt.id = ts.tranId
  53. -- WHERE rt.controlNo=dbo.FNAEncryptString(@controlNo) AND ts.mobile IS NOT NULL
  54. -- SET @subject='Trouble Ticket'
  55. -- SELECT
  56. -- @agentId=rt.sAgent
  57. -- ,@agentName=am.agentName
  58. -- ,@branchId=rt.sBranch
  59. -- FROM remitTran rt
  60. -- INNER JOIn tranSenders ts (NOLOCK) on ts.tranId=rt.id
  61. -- INNER JOIn agentMaster am (NOLOCK) on am.agentId=rt.sAgent
  62. -- WHERE rt.id=@tranId
  63. -- SELECT
  64. -- @branchName= am.agentName
  65. -- FROM remitTran rt (NOLOCK)
  66. -- INNER JOIn tranSenders ts (NOLOCK) on ts.tranId=rt.id
  67. -- INNER JOIN agentMaster am (NOLOCK) on am.agentId=rt.sBranch
  68. -- WHERE rt.id=@tranId AND agentType = '2904'
  69. -- SET @email=
  70. -- (
  71. -- SELECT am.agentEmail1
  72. -- FROM remitTran rt (NOLOCK)
  73. -- INNER JOIN agentMaster am (NOLOCK) ON rt.sAgent=am.agentId
  74. -- WHERE rt.id=@tranId and am.agentEmail1 IS NOT NULL
  75. -- )
  76. -- DECLARE @emailContent VARCHAR(MAX)
  77. -- SET @emailContent='Dear<strong>' +' ' + @agentName +' - ' + @branchName +'</strong>, <br/><br/>Following message has been raised from IME.<br/>" '+@message +'"<br/><br/>' +'ICN:'+' '+@controlNo+'
  78. -- <br/>Please email to <a href="javascript:void(0);"> support@imeremit.com.np </a> for any queries.<br/><br/>Thank you, <br/>IME Support Team <br/><br/><br/><br/>'
  79. --END
  80. --Add Comment API----------------------------------------------------------------------------------------------------
  81. IF @flag = 'i'
  82. BEGIN
  83. EXEC proc_errorHandler 0, 'SUCCESS.', @password
  84. IF (@sendSmsEmail='sms')
  85. BEGIN
  86. SELECT @mobileNo = mobile FROM tranSenders(nolock) WHERE TRANID = @tranId
  87. SELECT @message = LEFT(@message,90),@mobileNo = ISNULL(@mobileNo,'')
  88. EXEC sp_InsertIntoSMSQueue 'sms' ,@user ,@message,@country,NULL,@agentId ,@branchId ,@mobileNo ,@controlNo,NULL,@tranId
  89. EXEC proc_errorHandler 0,' ',@email
  90. EXEC FastMoneyPro_Remit.dbo.proc_CallToSendSMS @FLAG = 'I',@SMSBody = @message,@MobileNo = @mobileNo
  91. RETURN
  92. END
  93. IF (@sendSmsEmail='email' OR @sendSmsEmail='both') AND @email IS NOT NULL
  94. BEGIN
  95. EXEC sp_InsertIntoSMSQueue 'email' ,@user,@message, @country,@email,@agentId ,@branchId ,NULL,@controlNo , @subject,@tranId
  96. EXEC proc_errorHandler 0,' ',@email
  97. RETURN
  98. END
  99. RETURN
  100. END