In the htmlTemplateDirectPurchase i want to add a anchor link to execute a procedure in the webapp, lets call it DoOneClickPurchase
If I do add it to day, one of the problem is that the OnClick event gets fired, then it navigates to the details page of the product.
I want to execute the DoOneClickPurchase method if the <a> link is clicked
Code:
Procedure RenderArticles String groupCode String supplierID String groupSubCode String groupSubDetailCode String SearchString
String custNo
Get psLoginName of oSessionManager to custNo
stArticles[] articles
Handle hQry
Integer fetchOK aPos cPos
String htmlData htmlTemplate htmlTemplateDirectPurchase
String toNumber currentImmage
Boolean isFavourites
WebGet pbIsFavourites of Self to isFavourites
Move '<div class="ArticleItem" data-ServerOnClick="%1" data-OnClickParam="%2"><p class="pArticleNo">%5</p><div class="ImgContainer" style="background-image: url(%3)" ></div><div class="ArticleLabel"><p>%4</p></div></div>' to htmlTemplate
Move '<div class="ArticleItem" data-ServerOnClick="%1" data-OnClickParam="%2"><p class="pArticleNo">%5</p><div class="ImgContainer" style="background-image: url(%3)" ></div><div class="ArticleLabel"><p>%4</p></div></div>' to htmlTemplateDirectPurchase
Get SQLFileConnect of oSQLManager WebAppUser.File_Number to hdbc
Get SQLOpen of hdbc to hQry
If (groupCode = "" and SearchString <> "") Begin
Send SQLSetProcedureName of hQry "SearchAllAvailibleArticles" "dbo"
Send SQLSetParameter of hQry 1 SearchString
End
Else If (isFavourites) Begin
Send SQLSetProcedureName of hQry "GetCustomerFavouriteArticles" "dbo"
Send SQLSetParameter of hQry 1 custNo
End
Else If (supplierID <> "0") Begin
Send SQLSetProcedureName of hQry "ArticleBySubGroupSubDetailGroupSupplierID" "dbo"
Send SQLSetParameter of hQry 1 groupCode
Send SQLSetParameter of hQry 2 groupSubCode
Send SQLSetParameter of hQry 3 groupSubDetailCode
// ToDo: Är obsolote, tas bort, även i sql-fråga
Send SQLSetParameter of hQry 4 supplierID
If (SearchString <> "") ;
Send SQLSetParameter of hQry 5 SearchString
End
Else Begin
Send SQLSetProcedureName of hQry "ArticlesBySubGroupSubDetailsGroupAllNoBrand" "dbo"
Send SQLSetParameter of hQry 1 groupCode
Send SQLSetParameter of hQry 2 groupSubCode
Send SQLSetParameter of hQry 3 groupSubDetailCode
// ToDo: Är obsolote, tas bort, även i sql-fråga
If (SearchString <> "") ;
Send SQLSetParameter of hQry 4 SearchString
End
Send SQLCall of hQry
Repeat
Get SQLFetch of hQry to fetchOK
If (fetchOK <> 0) Begin
Move (SizeOfArray(articles)) to aPos
Move (Trim(SQLColumnValue(hQry, 1))) to articles[aPos].articleID
Move (Trim(SQLColumnValue(hQry, 2))) to articles[aPos].descript1
Move (Trim(SQLColumnValue(hQry, 3))) to articles[aPos].Descript2
Move (Trim(SQLColumnValue(hQry, 4))) to articles[aPos].image
Move (Trim(SQLColumnValue(hQry, 5))) to articles[aPos].isBatch
Move (SQLColumnValue(hQry, 6)) to toNumber
Move (Replaces('.', toNumber, ',')) to toNumber
Move (Number(toNumber)) to articles[aPos].lagerSaldo
End
Until (fetchOK = 0)
Send SQLClose of hQry
Send SQLDisconnect of hdbc
Move (SizeOfArray(articles)) to aPos
Boolean hasImage
For cPos from 0 to (aPos-1)
Get BuildImagePath ttwArtikelThumb articles[cPos].image (&hasImage) to currentImmage
// Append htmlData (SFormat(htmlTemplate, articles[cPos].articleID, ('isBatch='+ (String(articles[cPos].isBatch))), currentImmage, (ToOEM(articles[cPos].articleID)) ))
// Lägger in beskrivning för kunden istället
Append htmlData (SFormat(htmlTemplate, articles[cPos].articleID, ('isBatch='+ (String(articles[cPos].isBatch))), currentImmage, (ToOEM(articles[cPos].descript1)), (ToOEM(articles[cPos].articleID)) ))
// Move (htmlData + '<div class="VarorItem" data-ServerOnClick="' + articles[cPos].articleID + '" data-OnClickParam="isBatch=' + (String(articles[cPos].isBatch)) + '"><div class="product_label">' + (ToOEM(articles[cPos].articleID)) + " - " + (ToOEM(articles[cPos].descript1)) + '</div><img src="' + currentImmage + '" class="product_image"></div>') to htmlData
Loop
Send UpdateHtml htmlData
End_Procedure
Procedure OnClick String sId String sParam
String articleID
Boolean isBatch
Move sId to articleID
Move (Pos("isBatch=1", sParam)) to isBatch
WebSet psArticleID of Self to sId
WebSet pbIsBatch of Self to isBatch
Send NavigateForward to oAddArticleToOrder Self
End_Procedure