Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROCEDURE [dbo].[fm_tst-generate-coupon_saveItem]
- @username nvarchar(256),
- @itemID int,
- @parameters ExtendedDictionaryParameter READONLY
- -- либо перечислить все поля в форме (@fieldcode и т.д.)
- AS
- BEGIN
- -- сохраняем форму (добавление/обновление некой сущности)
- declare @langID int
- select @langID = try_cast(Value as int) from @parameters where [Key] = 'langID'
- declare @pdiscount nvarchar(max)
- select @pdiscount = Value2 from @parameters where [key]='discount'
- declare @ptext nvarchar(max)
- select @ptext = Value2 from @parameters where [key]='text'
- declare @pdays int
- select @pdays = try_cast(Value2 as int) from @parameters where [key]='days'
- declare @url nvarchar(256) = '/uploads/'+convert(nvarchar(128), newid())+'.png',
- @backImg nvarchar(128) = '/uploads/gen-images/coupon.jpg',
- @date nvarchar(128) = convert(nvarchar, dateadd(day, isnull(@pdays, 0), getdate() ), 104)
- -- SELECT 1 (Result, Msg, SuccessUrl, HideFormAfterSubmit, RefreshContainer)
- select 1 Result, '<a href="'+@url+'" target="_blank" >' +iif(@langID=1, 'Coupon link - ', 'Картинка - ') +@url+'</a>' Msg, '' SuccessUrl, 0 HideFormAfterSubmit, '' RefreshContainer
- -- SELECT 2 Вызов внешнего действия
- select 'generateImage' type, '
- {
- "options":{
- "path":"'+@url+'",
- "width":"735",
- "height":"354",
- "backColor":"#fff",
- },
- "render": [
- {
- "type": "image",
- "path":"'+@backImg+'",
- "x":"0",
- "y":"0",
- "width":"735",
- "height":"354",
- "opacity":"1"
- },
- {
- "type": "text",
- "text":"'+iif(@langID=1, 'Discount', 'Скидка')+' '+@pdiscount+'%",
- "x":"30",
- "y":"120",
- "width":"400",
- "height":"120",
- "color":"#fff",
- "backColor":"",
- "fontSize":"38",
- "fontFamily":"Verdana"
- },
- {
- "type": "line",
- "x1":"20",
- "y1":"190",
- "x2":"380",
- "y2":"190",
- "thickness":"1",
- "color":"white"
- },
- {
- "type": "text",
- "text":"'+iif(@langID=1, 'Coupon 124322', 'Купон 1234241')+'",
- "x":"120",
- "y":"200",
- "width":"400",
- "height":"120",
- "color":"#fff",
- "backColor":"",
- "fontSize":"18",
- "fontFamily":"Verdana"
- },
- {
- "type": "text",
- "text":"'+iif(@langID=1, 'Active till ', 'Действует до ')+' '+@date+'",
- "x":"20",
- "y":"10",
- "width":"400",
- "height":"120",
- "color":"#fff",
- "backColor":"",
- "fontSize":"10",
- "fontFamily":"Verdana"
- },
- {
- "type": "text",
- "text":"'+iif(@langID=1, 'John Smith Ltd', 'ИП Иванов И.И. ОГРН 12355152413123')+'",
- "x":"230",
- "y":"10",
- "width":"400",
- "height":"120",
- "color":"#000",
- "backColor":"",
- "fontSize":"10",
- "fontFamily":"Verdana"
- },
- {
- "type": "text",
- "text":"'+@ptext+'",
- "x":"20",
- "y":"300",
- "width":"400",
- "height":"120",
- "color":"#fff",
- "backColor":"",
- "fontSize":"7",
- "fontFamily":"Verdana"
- }
- ]
- }
- ' options
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement