//
//
//Suzi
if (ReqBasePath == "") {
ReqBasePath = 'https://shop4.wizsoft.com/VSHOP/WSHOP.wzx';
}
if (typeof String.prototype.trim !== 'function') {
String.prototype.trim = function () {
return this.replace(/^\s+|\s+$/g, '');
}
}
function WizShop(ShopName, PurchCallBack) {
if (!PurchCallBack) {
PurchCallBack=function(){return;}
}
var InnerPurchCallBack = PurchCallBack;
var ShopID = ShopName;
this.WizShopInit = function () { //init call back function for Update Customer Data and Purchasing in Iframe.
if (window.addEventListener) { // all browsers except IE before version 9
window.addEventListener("message", this.OnMessage, false);
}
else {
if (window.attachEvent) { // IE before version 9
window.attachEvent("onmessage", this.OnMessage); // Internet Explorer from version 8
}
}
}
this.OnMessage = function (Data) {
try {
if (!Data || !Data.data)
return;
Data = eval("(" + Data.data + ")")
if (Data.Action == 'UpdateCustDetails' || Data.Action == 'ConfirmPurch') {
document.getElementById("WizShopPurch").style.display = "none"
InnerPurchCallBack(Data);
}
} catch (e) {
}
}
this.SetShop = function (ShopID) {
document.cookie = "CurShop=" + ShopID + ";path=/";
}
this.GetShop = function () {
return (this.GetCookies()["CurShop"]);
}
this.GetProgPath = function () {
return this.ProgPath;
}
this.GetImagePath = function () {
return this.vShopImagePath;
}
this.GetLanguage = function () {
return this.vShopLanguage;
}
this.IsHebrew = function () {
return this.vShopLanguage=="HE";
}
// Get current customer
this.GetCust = function (CurShop) {
var Cook = this.GetCookies();
if (Cook['Cust_' + CurShop])
return Cook['Cust_' + CurShop]
var Key;
for (Key in Cook)
if (Key.substr(0, 11) == 'WizCustomer')
return Cook[Key];
}
this.GetAgent = function (CurShop) {
var Cook = this.GetCookies();
if (Cook['Agnt_' + CurShop])
return Cook['Agnt_' + CurShop]
return null;
}
// Is B2B customer
this.IsB2B = function () {
var CurShop = this.GetShop();
if (!CurShop) {
alert("Use SetShop before using the WizShop API")
throw 'No shop defined by SetShop';
}
var WizCust = this.GetCust(CurShop);
if (WizCust == null || WizCust == '')
return false;
return WizCust.substr(0, 1) != "0";
}
this.IsDispCategory = function (vDisplayType)
{
// vDisplayType as returned from JSON (action 14)
if (vDisplayType == '0')
return true;
else if (vDisplayType == '4')
return false;
else if (this.IsB2B())
return (vDisplayType != '1');
else
return (vDisplayType != '2');
}
// Build base URL
this.GetBaseUrl = function (Oper, WithCust) {
var CurShop = this.GetShop();
if (!CurShop) {
alert("Use SetShop before using the WizShop API")
throw 'No shop defined by SetShop';
}
var Url = "Lang=" + this.GetLanguage() + "&API=Yes&HTTPREQ=" + Oper + "&UC=" + CurShop;
// In fact, WithCust is never null (true or false) and it's OK because WizCustomer has to be sent in every action
if (WithCust != null) {
var WizCust = this.GetCust(CurShop);
if (WizCust != null) {
Url += "&WizCustomer=" + WizCust + "xxxx";
if (WizCust.substr(0, 1) != "0") {
var vAgent = this.GetAgent(CurShop);
if (vAgent != null)
Url += "&VSAgentNo" + CurShop + "=" + vAgent;
}
}
}
return Url;
}
this.GetDomainFromURL = function (vUrl) {
if (!vUrl || vUrl.length < 7)
return "";
var vDomain;
//find & remove protocol (http, ftp, etc.) and get domain
if (vUrl.indexOf("://") > -1)
vDomain = vUrl.split('/')[2];
else
vDomain = vUrl.split('/')[0];
//find & remove port number
vDomain = vDomain.split(':')[0];
return vDomain;
}
this.CheckOrigin = function (vEventOrigin) {
if (!vEventOrigin)
return false;
return (this.GetDomainFromURL("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx") == this.GetDomainFromURL(vEventOrigin));
}
// -------------------------------------------------------------------------
// Action 8 - retreive items for category or for search text. This function builds the url for both options.
this.GetBasicUrlAction8 = function (vGetQntInCart, vMaxItemsNumber, vFromIndex, vGetItemsCount, vSortBy, vSortOrder, vGetMatrixDef, vGetSetInfo, vGetImgEx, vGetNotes, vFilter) {
var Url = this.GetBaseUrl(8, true);
if (vGetQntInCart != null)
Url += "&VSQntInCart=Yes";
if (vMaxItemsNumber != null)
Url += "&VSMaxItms=" + vMaxItemsNumber;
if (vFromIndex != null)
Url += "&ItemsRangeFrom=" + vFromIndex;
if ((vGetItemsCount != null) && (vGetItemsCount == 1))
Url += "&VSGetCount=Yes"
if ((vSortBy != null) && (vSortBy != ''))
Url += "&VSItmSortBy=" + vSortBy;
if ((vSortOrder != null) && (vSortOrder != ''))
Url += "&VSItmSortOrder=" + vSortOrder;
if ((vGetMatrixDef != null) && (vGetMatrixDef == 1))
Url += "&VSGetMatDef=Yes";
if ((vGetSetInfo != null) && (vGetSetInfo == 1))
Url += "&VSGetSetInfo=Yes";
if ((vGetImgEx != null) && (vGetImgEx == 1))
Url += "&VSGetImgEx=Yes";
if ((vGetNotes != null) && (vGetNotes == 1))
Url += "&VSGetNotes=Yes";
if (vFilter != null && (vFilter != ''))
Url += "&Filter=" + vFilter;
return Url;
}
// Get items included in a certain category "Cat"
this.GetItemsForCat = function (Cat, CallBack, vGetQntInCart, vMaxItemsNumber, vFromIndex, vGetItemsCount, vSortBy, vSortOrder, vGetMatrixDef, vGetSetInfo, vGetImgEx, vGetNotes, vFilter) {
var Url = this.GetBasicUrlAction8(vGetQntInCart, vMaxItemsNumber, vFromIndex, vGetItemsCount, vSortBy, vSortOrder, vGetMatrixDef, vGetSetInfo, vGetImgEx, vGetNotes, vFilter);
Url += "&ItmCategory=" + Cat;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// Search items by name
this.SearchItems = function (vSearchText, CallBack, vGetQntInCart, vMaxItemsNumber, vFromIndex, vGetItemsCount, vSortBy, vSortOrder, vGetMatrixDef, vGetSetInfo, vGetImgEx, vGetNotes, vFilter) {
var Url = this.GetBasicUrlAction8(vGetQntInCart, ((vMaxItemsNumber != null) && (vMaxItemsNumber != "ALL")) ? vMaxItemsNumber : null, vFromIndex, vGetItemsCount, vSortBy, vSortOrder, vGetMatrixDef, vGetSetInfo, vGetImgEx, vGetNotes, vFilter);
Url += "&SRCH=" + vSearchText;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// -------------------------------------------------------------------------
// Search items by name while typing
// Min length of vSearchText = 2 characters
this.FastSearchItems = function (vSearchText, CallBack) {
var Url = this.GetBaseUrl(25, true);
Url += "&VSSrch=" + vSearchText;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// -------------------------------------------------------------------------
this.CountItemsInBasket = function (CallBack) {
var Url = this.GetBaseUrl(27, true);
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// Insert an item to the shopping cart
this.ItemToBasket = function (ItemKey, Quant, CallBack, vForFutureUse, vItemRemark, vMatCodeLine, vMatCodeCol) {
var Url = this.GetBaseUrl(1, true);
Url += "&AddItemToBasket=" + ItemKey + "&Quant=" + Quant;
//if ((CheckCorrectQuantity != null) && (CheckCorrectQuantity == 1))
// Url += "&VSChk=Yes";
if ((vItemRemark != null) && (vItemRemark != ''))
Url += "&VSItmRem=" + this.PrepareRemark4Url(vItemRemark);
if ((vMatCodeLine != null) && (vMatCodeLine != '')) {
Url += "&MatCDL=" + vMatCodeLine;
if (vMatCodeCol != null)
Url += "&MatCDC=" + vMatCodeCol;
}
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// Remove an item from shopping cart (by ID or ItemKey)
this.RemoveItemFromBasket = function (ID, ItemKey, CallBack) {
var Url = this.GetBaseUrl(18, true)
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url + "&APIRemoveItemIdFromBasket=" + ID + "&APIRemoveItemKeyFromBasket=" + ItemKey, CallBack);
}
// Update shopping cart quantities and remarks
// ItemsToUpdateArr: ID, ItemKey, Quantity, Item Remark
this.UpdateBasket = function (ItemsToUpdateArr, vForFutureUse, CallBack, vUpdateRemarks) {
var Url = this.GetBaseUrl(20, true);
var i = 0;
var vLoop = 2;
if ((vUpdateRemarks != null) && (vUpdateRemarks == 1))
vLoop = 3;
while (i + vLoop < ItemsToUpdateArr.length) {
Url += "&quantity.";
Url += ItemsToUpdateArr[i]; // ID
Url += "=" + ItemsToUpdateArr[i + 2]; // Quant
Url += "_" + ItemsToUpdateArr[i + 1]; // ItemKey
if (vLoop == 3) {
Url += "&ItemRemark.";
Url += ItemsToUpdateArr[i]; // ID
Url += "=" + this.PrepareRemark4Url(ItemsToUpdateArr[i + 3]); // Remarks
}
i += vLoop + 1;
}
//if (CheckCorrectQuantity == 1)
// Url += "&VSChk=Yes";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// Get current basket. CallBack function can be used to display the basket.
this.ShowBasket = function (CallBack, vShipCountry, vShipType, vGetAllShipCost, vGetPaymenetDetails, vSortDesc, vNoDiscLines, vCpNum) {
var Url = this.GetBaseUrl(9, true)
if ((vShipCountry != null) && (vShipCountry != ''))
Url += "&VSShipCountry=" + vShipCountry;
if ((vShipType != null) && (vShipType != ''))
Url += "&VSShipType=" + vShipType;
if ((vGetAllShipCost != null) && (vGetAllShipCost == 1))
Url += "&VSShipCostAll=Yes";
if ((vGetPaymenetDetails == null) || (vGetPaymenetDetails == 1))
Url += "&VSPAY=Yes";
if ((vSortDesc != null) && (vSortDesc == 1))
Url += "&VSCrtSrtTyp=DESC";
if ((vNoDiscLines != null) && (vNoDiscLines == 1))
Url += "&VSNoDiscLines=1";
if (vCpNum != null)
Url += "&VSCpNum=" + vCpNum;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// Check if item can be purchased.
this.ItemCanBePurchased = function (vItemKey, vQuantity, CallBack) {
var Url = this.GetBaseUrl(19, true);
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url + "&ItemKey=" + vItemKey + "&Quant=" + vQuantity, CallBack);
}
// Check if item is in shopping cart by its Item Key
this.IsItemInBasket = function (vItemKey, CallBack) {
var Url = this.GetBaseUrl(21, true);
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url + "&ItemKey=" + vItemKey, CallBack);
}
// Check if item is in shopping cart by its Item Key
this.GetItemQuantityInBasket = function (vItemKey, CallBack, vMatCodeLine, vMatCodeCol) {
var Url = this.GetBaseUrl(21, true);
Url += "&VSExInfo=1&ItemKey=" + vItemKey;
if (vMatCodeLine != null) {
Url += "&MatCDL=" + vMatCodeLine;
if (vMatCodeCol != null)
Url += "&MatCDC=" + vMatCodeCol;
}
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// Check if matrix item is in shopping cart (at lease one of the sones is in cart)
this.IsMatrixItemInBasket = function (vMatrixKey, CallBack) {
var Url = this.GetBaseUrl(21, true);
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url + "&VSExInfo=2&ItemKey=" + vMatrixKey, CallBack);
}
// Get item information
this.GetSingleItemData = function (vItemKey, CallBack, vGetAllCategories, vGetRelTabs, vGetSetsEx) {
var Url = this.GetBaseUrl(15, true);
if ((vGetAllCategories != null) && (vGetAllCategories == 1))
Url += "&VSGetItmCats=Yes";
if ((vGetRelTabs != null) && (vGetRelTabs == 1))
Url += "&VSGetRelTabs=Yes";
if ((vGetSetsEx != null) && (vGetSetsEx == 1))
Url += "&VSSetsEx=Yes";
Url += "&VSForceChkMig=Yes";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url + "&SingleItem=" + vItemKey, CallBack);
}
// Get matrix son information - to be deleted
this.GetMatrixSonData = function (vMatItemKey, vMatCodeLine, vMatCodeCol, CallBack) {
var Url = this.GetBaseUrl(15, true);
Url += "&VSItemKey=" + vMatItemKey;
Url += "&MatCDL=" + vMatCodeLine;
if (vMatCodeCol != null)
Url += "&MatCDC=" + vMatCodeCol;
Url += "&VSForceChkMig=Yes";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// Get matrix son information
this.GetMatrixSonDataEx = function (vMatItemKey, vMatCodeLine, vMatCodeCol, CallBack) {
var Url = this.GetBaseUrl(15, true);
Url += "&VSMode=MSON&VSItemKey=" + vMatItemKey;
Url += "&MatCDL=" + vMatCodeLine;
if (vMatCodeCol != null)
Url += "&MatCDC=" + vMatCodeCol;
Url += "&VSForceChkMig=Yes";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// Get item last price
this.GetItemLastPrice = function (vItemKey, CallBack, vExInfo) {
var Url = this.GetBaseUrl(15, true);
Url += "&VSMode=PRC";
if ((vExInfo != null) && (vExInfo == 1))
Url += "&VSFULL=1";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url + "&SingleItem=" + vItemKey, CallBack);
}
// Logout customer
this.Logout = function (CallBack) {
var Url = this.GetBaseUrl(16, true);
var that = this;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url,
function (Result) {
var Res;
eval("Res = Result");
//alert(JSON.stringify(Res));
if (Res.Status == "OK") {
var CurShop = that.GetCookies()["CurShop"];
document.cookie = "Cust_" + CurShop + "=" + Res.CustCookieVal + ";path=/";
document.cookie = "Agnt_" + CurShop + "=0;path=/";
document.cookie = "CReg_" + CurShop + "=0;path=/";
document.cookie = "CDet_" + CurShop + "=3;path=/";
CallBack(Result);
}
else {
CallBack(Result);
}
} // function(Result)
); // CDSAsyncCallReq
}
// Check if any customer is currently registered.
// Note: Yes = Exists in database
// If not registered, the system creates new ID for the session.
this.IsRegisterCustDeFacto = function (CallBack) {
var Url = this.GetBaseUrl(10, true)
Url += "&ExInfo=1";
var that = this;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url,
function (Result) {
var Res;
eval("Res = Result");
if (Res.CustCookieVal != '') {
var CurShop = that.GetCookies()["CurShop"];
document.cookie = "Cust_" + CurShop + "=" + Res.CustCookieVal + ";path=/";
var vCustSymbol = "0";
if (Res.Status == "Yes")
vCustSymbol = (Res.CustCookieVal.substr(0, 1) != "0") ? "1" : "2";
document.cookie = "CReg_" + CurShop + "=" + vCustSymbol + ";path=/";
document.cookie = "CDet_" + CurShop + "=" + Res.B2BSwCustDet + ";path=/";
}
CallBack(Result);
} // function(Result)
); // CDSAsyncCallReq
}
this.IsRegisterCust = function (CallBack) {
var vCurShop = this.GetShop();
var vCustReg = this.GetCookies()["CReg_" + vCurShop];
if (vCustReg) {
var vObjRes = { Status: '', CustID: '' };
vObjRes.Status = (vCustReg == '0') ? 'No' : 'Yes';
vObjRes.CustID = this.GetCookies()["Cust_" + vCurShop];
CallBack(vObjRes);
}
else
this.IsRegisterCustDeFacto(CallBack);
}
// Register B2B customer
this.B2BRegisterCust = function (WizKey, Pass, CallBack, vOTP) {
var Url = this.GetBaseUrl(11, true); // Send WizCustomer parameter in order to move the temporary shopping cart if necessary
Url += "&ExInfo=1";
var that = this;
Url += "&Name=" + WizKey;
Url += (vOTP && (vOTP == 1)) ? "&OTP=" : "&Pass=";
Url += Pass;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url,
function (Result) {
var Res;
eval("Res = Result");
if (Res.Status == "OK") {
var CurShop = that.GetCookies()["CurShop"];
document.cookie = "Cust_" + CurShop + "=" + Res.CustCookieVal + ";path=/";
document.cookie = "Agnt_" + CurShop + "=" + Res.AgentCookieVal + ";path=/";
document.cookie = "CReg_" + CurShop + "=1;path=/";
document.cookie = "CDet_" + CurShop + "=" + Res.B2BSwCustDet + ";path=/";
CallBack(Result);
}
else {
CallBack(Result);
}
} // function(Result)
); // CDSAsyncCallReq
}
// Send password to B2B customer
this.B2BSendPassword = function (WizKey, Email, CallBack) {
var Url = this.GetBaseUrl(11, true);
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url + "&SendPassMode=1&Name=" + WizKey + "&EMailNo=" + Email, CallBack);
}
// Send OTP to B2B customer
this.B2BSendOTP = function (WizKey, vSms, Email, vPhone, CallBack) {
var Url = this.GetBaseUrl(55, true);
Url += "&WZK=" + WizKey;
if (vSms && (vSms==1))
Url += "&SMS=1";
if (Email)
Url += "&EML=" + Email;
if (vPhone)
Url += "&PHN=" + vPhone;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// Register B2C customer
this.B2CRegisterCust = function (Email, Pass, CallBack, vDonation) {
var Url = this.GetBaseUrl(11, true); // Send WizCustomer parameter in order to move the temporary shopping cart if necessary
if (vDonation && vDonation == 1) {
if (window.console)
console.log("== WizShop.B2CRegisterCust: vDonation is ignored, this function does not register donors anymore");
//Url += "&VSTruma=Yes";
}
var that = this;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url + "&umail=" + Email + "&Pass=" + Pass,
function (Result) {
var Res;
eval("Res = Result");
if (Res.Status == "OK") {
var CurShop = that.GetCookies()["CurShop"]
document.cookie = "Cust_" + CurShop + "=" + Res.CustCookieVal + ";path=/";
document.cookie = "Agnt_" + CurShop + "=0;path=/";
document.cookie = "CReg_" + CurShop + "=2;path=/";
document.cookie = "CDet_" + CurShop + "=3;path=/";
CallBack(Result);
}
else {
CallBack(Result);
}
} // function(Result)
); // CDSAsyncCallReq
}
// Send password to B2C customer
this.B2CSendPassword = function (Email, CallBack) {
var Url = this.GetBaseUrl(11, true)
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url + "&SendPassMode=1&umail=" + Email, CallBack);
}
// Get customer details
this.GetCustDet = function (CallBack) {
var Url = this.GetBaseUrl(12, true);
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, function (custDet) {
var TmpRes = custDet;
//eval("TmpRes = custDet")
CallBack(TmpRes);
});
}
// Get default details for new customer
this.GetDefaultNewCustDet = function (CallBack) {
var Url = this.GetBaseUrl(12, true);
Url += "&NewCustDflt=Yes";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, function (custDet) {
var TmpRes = custDet;
//eval("TmpRes = custDet")
CallBack(TmpRes);
});
}
// Purchase the basket and create an order
// SuppDt format must be "mm/dd/yyyy" if MDY=Yes, otherwise "dd/mm/yyyy"
this.HttpDoPurch = function (CallBack, vConfEmail, vCreditCardMethod, vOrderRemark, vShipMethod, vPaymentsNo, vSupplyDate, vMDY, vOrdExData) {
if (vPaymentsNo && vPaymentsNo != "1") {
if (window.console)
console.log("== WizShop.HttpDoPurch: vPaymentsNo is ignored in this action and considered 1");
}
var Url = this.GetBaseUrl(13, true);
Url += this.PrepareUrlForOrder(vConfEmail, vOrderRemark, vShipMethod, null, vSupplyDate, vMDY, vCreditCardMethod, vOrdExData);
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// PrepareUrlForOrder called from action 13 and action 45
this.PrepareUrlForOrder = function (vConfEmail, vOrderRemark, vShipMethod, vPaymentsNo, vSupplyDate, vMDY, vCreditCardMethod, vOrdExData) {
var Url = '';
if ((vConfEmail != null) && (vConfEmail != ''))
Url += "&CustEmail=" + vConfEmail;
if ((vCreditCardMethod != null) && (vCreditCardMethod != ''))
Url += "&VSCrdt=" + vCreditCardMethod;
if (vOrderRemark != null) // Empty value is valid 7.6.17
Url += "&VSOrdRemark=" + this.PrepareRemark4Url(vOrderRemark);
if ((vShipMethod != null) && (vShipMethod != ''))
Url += "&VSShipType=" + vShipMethod;
if ((vPaymentsNo != null) && (vPaymentsNo != ''))
Url += "&PaymentsNo=" + vPaymentsNo;
if ((vSupplyDate != null) && (vSupplyDate != "")) {
Url += "&SuppDt=" + vSupplyDate;
if (vMDY && (vMDY == 1))
Url += "&MDY=Yes";
}
if (vOrdExData != null) // 1005
Url += "&VSOrdExData=" + this.PrepareRemark4Url(vOrdExData);
return Url;
}
// Default callback function
this.Nothing = function (MyReq) {
alert("RES:" + MyReq)
return;
}
this.GetIframeDoc = function (oIframe) {
var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
if (oDoc.document) oDoc = oDoc.document;
}
// Get cookies
this.GetCookies = function () {
var Arr = document.cookie.split(";");
for (var i = 0; i < Arr.length; i++) {
if (Arr[i] != null)
Arr[i] = Arr[i].split("=");
}
var Cook = {};
for (var i = 0; i < Arr.length; i++) {
if (Arr[i] != null && Arr[i][0] != null && Arr[i][1] != null)
Cook[Arr[i][0].trim()] = Arr[i][1].trim();
}
return Cook;
}
/*this.SetCookie = function (vCookName, vCookVal) {
var vCookie = this.GetCookies()[vCookName];
if (!vCookie)
vCookie = [];
document.cookie = vCookName + "=" + vCookVal;
}
this.DelCookie = function (vCookName) {
var vCookie = this.GetCookies()[vCookName];
if (!vCookie)
vCookie = [];
document.cookie = vCookName + '=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}*/
this.GetCategoryInfo = function (vCat, CallBack) {
var Url = this.GetBaseUrl(14, true);
Url += "&VSCT=" + vCat;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
this.GetCategories = function(vParentCat, vOnlyValid, CallBack, vSortType, vCatalogMode){
var Url = this.GetBaseUrl(14, true);
Url += "&category=" + vParentCat;
if ((vOnlyValid != null) && (vOnlyValid == 0))
Url += "&VSOnlyValid=No";
if ((vCatalogMode != null) && (vCatalogMode != 0))
Url += "&VSCatalogMode=" + vCatalogMode.toString();
// vSortType:
// By default, the categories are sorted by the order defined in back-office
// Send 1 to sort by ParentId (relevant when vParentCat is empty and the whole tree is retreived).
if (vSortType != null)
Url += "&VSSortType=" + vSortType.toString();
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
this.GetCategoriesTree = function (CallBack, vOnlyValid, vCheckMigvan, vCatalogMode) {
var Url = this.GetBaseUrl(14, true);
Url += "&VSTree=Yes";
if ((vOnlyValid != null) && (vOnlyValid == 0))
Url += "&VSOnlyValid=No";
if ((vCatalogMode != null) && (vCatalogMode != 0))
Url += "&VSCatalogMode=" + vCatalogMode.toString();
if ((vCheckMigvan != null) && (vCheckMigvan == 0))
Url += "&VSChkMigvan=No";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// Get shop definitions
this.GetShopDefinitions = function (CallBack, vGetType) {
var Url = this.GetBaseUrl(30, true);
if ((vGetType == null) || (vGetType != 0))
Url += "&VSDefFull=Yes";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// vListType: WL=Wish_List, FX=Default Order (Fix), PI=Purchased Items
// vSortDesc is relevant for WL and FX
// vSortByLocation is relevant for FX
this.GetItemsInList = function (vListType, CallBack, vSortDesc, vSortByLocation) {
var Url = this.GetBaseUrl(9, true);
Url += "&VSListType=" + vListType;
if ((vSortDesc != null) && (vSortDesc == 1))
Url += "&VSCrtSrtTyp=DESC";
if ((vListType=="FX") && (vSortByLocation != null) && (vSortByLocation == 1))
Url += "&VSCrtSrtLocation=Yes";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// vListType: WL=Wish_List, FX=Default Order (Fix), PI=Purchased Items
// vActionType: 1=Move item from cart to wish-list,
// 2=Insert item to list (dont move from cart),
// 2M=Insert item to list (move from cart),
// 3=Remove item from list
this.ActionOnList = function (ItemKey, vListType, vActionType, CallBack, vInsert2FixOnlyPI, vMatCodeLine, vMatCodeCol, vFxQuantity, vFxLocation) {
var Url = this.GetBaseUrl(28, true);
Url += "&ItemKey=" + ItemKey;
if (vMatCodeLine != null) {
Url += "&MatCDL=" + vMatCodeLine;
if (vMatCodeCol != null)
Url += "&MatCDC=" + vMatCodeCol;
}
Url += "&VSListType=" + vListType;
Url += "&VSActionType=" + vActionType;
if ((vInsert2FixOnlyPI != null) && (vInsert2FixOnlyPI == 1))
Url += "&VSFXOnlyPI=1";
if (vFxLocation != null && vFxLocation != '')
Url += "&VSLocation=" + vFxLocation;
if (vFxQuantity != null && vFxQuantity != '')
Url += "&VSQnt=" + vFxQuantity;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// Insert all default order to shopping cart
this.InsertDefaultOrderToBasket = function (CallBack) {
var Url = this.GetBaseUrl(28, true);
Url += "&VSActionType=100";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// Insert all purchased items to shopping cart
this.InsertPurchasedItemsToBasket = function (CallBack) {
var Url = this.GetBaseUrl(28, true);
Url += "&VSActionType=200";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// =========================
this.UpdateDefaultOrderLocations = function (vLines2UpdArr, CallBack) {
var Url = this.GetBaseUrl(28, true);
Url += "&VSListType=FX";
Url += "&VSActionType=400";
if (vLines2UpdArr != null && vLines2UpdArr.length > 0) {
var i = 0;
for (i = 0; i < vLines2UpdArr.length; ++i) {
var vLineArr = new Array();
vLineArr = vLines2UpdArr[i].split("|");
if (vLineArr.length == 2) {
if (vLineArr[1] != '') // ID
Url += "&LCTN." + vLineArr[0] + "=" + vLineArr[1];
}
}
}
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// =========================
this.SendTempCartToBackOffice = function (vName, vPhone, vEmail, vRemark, vAddress, CallBack) {
var Url = this.GetBaseUrl(29, true);
if (vName != null)
Url += "&VSName=" + vName;
if (vPhone != null)
Url += "&VSPhone=" + vPhone;
if (vEmail != null)
Url += "&VSMail=" + vEmail;
if (vRemark != null)
Url += "&VSRemark=" + vRemark;
if (vAddress != null)
Url += "&VSAddress=" + vAddress;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
this.GetCountriesAndShippingTypes = function (CallBack, vOnlyCustCountry) {
var Url = this.GetBaseUrl(22, true);
if ((vOnlyCustCountry != null) && (vOnlyCustCountry == 1)) {
Url += "&VSCustShipCountry=Yes";
}
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
this.ChangePassword = function (vCurrentPass, vNewPass, CallBack) {
var Url = this.GetBaseUrl(39, true);
Url += "&VSCurP=" + vCurrentPass;
Url += "&VSNewP=" + vNewPass;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
this.GetPromotedItems = function (vGroupType, vCategory, CallBack, vSortType, vMaxItems) {
var Url = this.GetBaseUrl(36, true);
Url += "&VSGrpTyp=" + vGroupType.toString();
if ((vGroupType != 2) && vCategory)
Url += "&category=" + vCategory;
if (vSortType && (vSortType != ''))
Url += "&VSSort=" + vSortType;
if (vMaxItems)
Url += "&VSMax=" + vMaxItems.toString();
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
this.RegisterNewsletters = function (vEmail, vSendMeAdvByMail, CallBack, vSendMeCpn, vName, vPhone) {
var Url = this.GetBaseUrl(23, true);
Url += "&VSRegNewsletter=1";
Url += "&EMail=" + vEmail;
Url += "&VSAdvByMailPrm=";
Url += (vSendMeAdvByMail == 1) ? "1" : "0";
if (vSendMeCpn) {
Url += "&VSSndCpnPrm=";
Url += vSendMeCpn==1 ? "1" : "0";
}
if (vName)
Url += "&VSNwNamePrm=" + vName;
if (vPhone)
Url += "&VSNwPhonePrm=" + vPhone;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// ==================================================================================
// PCI - Phase 1 - opening the Pci Iframe to get the card details from user
this.PciOrderUpdateCreditDetails = function (vPciFrame, vTKN, CallBack, vPaymentsNo, vShipMethod, vConfEmail, vOrderRemark, vSupplyDate, vMDY, vOrdExData) {
this.SubmitPciOrder(vPciFrame, vTKN, CallBack, vPaymentsNo, vShipMethod, vConfEmail, vOrderRemark, vSupplyDate, vMDY, vOrdExData);
}
// ==================================================================================
// PCI Guest - Phase 1 - opening the Pci Iframe to get the card details from user
this.PciOrderUpdateCreditDetailsGuest = function (vPciFrame, vTKN, CallBack, vPaymentsNo, vShipMethod, vConfEmail, vOrderRemark, vSupplyDate, vMDY, vOrdExData,
vEMail, vFullName, vAddress, vCity, vCountry, vZip, vRegion, vPhone,
vBFullName, vBAddress, vBCity, vBCountry, vBZip, vBRegion, vBPhone, vSendMeDigInv, vSendMeAdvByMail,
vSameAddress, vCDTp, vSendMeCpn) {
this.SubmitPciOrder(vPciFrame, vTKN, CallBack, vPaymentsNo, vShipMethod, vConfEmail, vOrderRemark, vSupplyDate, vMDY, vOrdExData,
1, vEMail, vFullName, vAddress, vCity, vCountry, vZip, vRegion, vPhone,
vBFullName, vBAddress, vBCity, vBCountry, vBZip, vBRegion, vBPhone, vSendMeDigInv, vSendMeAdvByMail,
vSameAddress, vCDTp, vSendMeCpn);
}
// ==================================================================================
// PCI - Phase 1 - opening the Pci Iframe to get the card details from user
this.SubmitPciOrder = function (vPciFrame, vTKN, CallBack, vPaymentsNo, vShipMethod, vConfEmail, vOrderRemark, vSupplyDate, vMDY, vOrdExData,
vGuest,
vEMail, vFullName, vAddress, vCity, vCountry, vZip, vRegion, vPhone,
vBFullName, vBAddress, vBCity, vBCountry, vBZip, vBRegion, vBPhone, vSendMeDigInv, vSendMeAdvByMail,
vSameAddress, vCDTp, vSendMeCpn) {
if (!vPciFrame) {
alert("Credit card iframe is not defined");
return;
}
//vPciFrame.setAttribute('data-cardok', '0');
var Url = this.GetBaseUrl(45, true);
if (vTKN && (vTKN != ""))
Url += "&VSTN=" + vTKN;
Url += this.PrepareUrlForOrder(vConfEmail, vOrderRemark, vShipMethod, vPaymentsNo, vSupplyDate, vMDY, null, vOrdExData);
if (vGuest && vGuest == 1) {
Url += "&VSGST=Yes";
Url += this.PrepareUrlForAction23(vEMail, vFullName, vAddress, vCity, vCountry, vZip, vRegion, vPhone,
vBFullName, vBAddress, vBCity, vBCountry, vBZip, vBRegion, vBPhone, null, vSendMeDigInv, vSendMeAdvByMail,
vSameAddress, vCDTp, null, null, vSendMeCpn);
}
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url,
function (Result) {
var Res;
eval("Res = Result");
if ((Res.Status == "OK") && (Res.HostedPageUrl != "")) {
vPciFrame.style.display = "";
vPciFrame.src = Res.HostedPageUrl;
CallBack(Result);
}
else {
vPciFrame.src = "about:blank";
CallBack(Result);
}
} // function(Result)
); // CDSAsyncCallReq
}
//***************** Donation **********************
// ==================================================================================
// PCI - Phase 1 - opening the Pci Iframe to get the card details from user
this.PciDonationUpdateCreditDetails = function (vPciFrame, CallBack, vPaymentsNo, vDonationSum, vDonationCurrency, vDonationEmail, vDonationRemarks, vBFullName, vBAddress, vBCity, vBCountry, vBZip, vBRegion, vBPhone, vSendMeDigInv, vOrdExData) {
if (!vPciFrame) {
alert("Credit card iframe is not defined");
return;
}
var Url = this.GetBaseUrl(45, true);
Url += "&VSTruma=Yes";
Url += "&CTTL=" + vDonationSum;
Url += "&CCOIN=" + vDonationCurrency;
//Url += "&VSEmail=" + vDonationEmail;
Url += "&EMail=" + vDonationEmail;
if ((vPaymentsNo != null) && (vPaymentsNo != ''))
Url += "&PaymentsNo=" + vPaymentsNo;
if (vBFullName == null) {
if (window.console)
console.log("== WizShop.PciDonationUpdateCreditDetails (vBFullName=null): you must send donor data in this function instead of using UpdateDonorDetails");
}
else {
//Url += "&EMail=" + vDonationEmail;
Url += "&BName=" + vBFullName;
Url += "&BAddress=" + vBAddress;
Url += "&BCity=" + vBCity;
if (vBRegion != null)
Url += "&BRegion=" + vBRegion;
if (vBZip != null)
Url += "&BZip=" + vBZip;
Url += "&BCountry=" + vBCountry;
Url += "&BPhone=" + vBPhone;
}
if (vSendMeDigInv != null) {
Url += "&VSDigInvPrm=";
Url += (vSendMeDigInv == 1) ? "1" : "0";
}
if (vDonationRemarks)
Url += "&VSOrdRemark=" + this.PrepareRemark4Url(vDonationRemarks);
if (vOrdExData != null) // 6.4.21
Url += "&VSOrdExData=" + this.PrepareRemark4Url(vOrdExData);
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url,
function (Result) {
var Res;
eval("Res = Result");
if ((Res.Status == "OK") && (Res.HostedPageUrl != "")) {
vPciFrame.style.display = "";
vPciFrame.src = Res.HostedPageUrl;
CallBack(Result);
}
else {
vPciFrame.src = "about:blank";
CallBack(Result);
}
} // function(Result)
); // CDSAsyncCallReq
}
// ==================================================================================
// Donation is not completed yet!
this.PciGetDonationDefinitions = function (vGetCountries, CallBack) {
var Url = this.GetBaseUrl(44, true);
if (vGetCountries == 0)
Url += "&VSGetCountries=0";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// ==================================================================================
// Get payments tab for the donation amount
this.PciGetDonationPaymentsForAmount = function (vDonationSum, vDonationCurrency, CallBack) {
var Url = this.GetBaseUrl(47, true);
Url += "&CTTL=" + vDonationSum.toString();
Url += "&CCOIN=" + vDonationCurrency;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// ==================================================================================
// Get currency for a specific country
this.PciGetDonationCurrency = function (vCountry) {
if ((vCountry == "Israel") || (vCountry == "ישראל"))
return "NIS";
else
return "$";
}
// ==================================================================================
this.CalculateDonationPaymentsForAmount = function (vDonationSum, vMaxPayments, vMinPay, vRate) {
if ((vDonationSum <= 0) || (vMaxPayments <= 0))
return 1;
var vPays = vMaxPayments;
if (vMinPay > 0) {
if (vRate && (vRate != 1))
vMinPay = parseFloat((vMinPay / vRate).toString());
vPays = (vDonationSum <= vMinPay) ? 1 : parseInt(vDonationSum / vMinPay);
if (vPays > vMaxPayments)
vPays = vMaxPayments;
}
return vPays;
}
// ==================================================================================
// 2020: Not suppoted. Data is send in action 45
this.UpdateDonorDetails = function (vNewCust, vEMail, vEMail2Upd, vPass, vBFullName, vBAddress, vBCity, vBCountry, vBZip, vBRegion, vBPhone, CallBack) {
if (window.console)
console.log("== WizShop.UpdateDonorDetails: this function is not supported. Please send donor data in function PciDonationUpdateCreditDetails");
var Url = this.GetBaseUrl(23, true);
Url += "&VSTruma=Yes";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// ==================================================================================
// 2020: Get registered customer details (vEmail is ignored)
this.GetDonorData = function (vEmail, CallBack) {
if (vEmail != null) {
if (window.console)
console.log("== WizShop.GetDonorData: vEmail is ignored, this function returns data only for the current registered customer");
}
var Url = this.GetBaseUrl(12, true)
Url += "&VSTruma=Yes"; //&VSEmail=" + vEmail;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, function (custDet) {
var TmpRes = custDet;
//eval("TmpRes = custDet")
CallBack(TmpRes);
});
}
// ==================================================================================
this.UpdateClientDetailsEx = function (vNewCust, vEMail, vPass, vFullName, vAddress, vCity, vCountry, vZip, vRegion, vPhone, CallBack,
vBFullName, vBAddress, vBCity, vBCountry, vBZip, vBRegion, vBPhone, vShippingType, vSendMeDigInv, vSendMeAdvByMail, vRegisterNewCust,
vSameAddress, vCDTp, vRemark, vOrdExData, vSendMeCpn) {
var Url = this.GetBaseUrl(23, true);
var vRegNewCust = false;
if (vNewCust == 1) {
vRegNewCust = (vRegisterNewCust == null) || (vRegisterNewCust == 1);
Url += "&NC=1";
Url += "&Pass=" + vPass;
}
Url += this.PrepareUrlForAction23(vEMail, vFullName, vAddress, vCity, vCountry, vZip, vRegion, vPhone,
vBFullName, vBAddress, vBCity, vBCountry, vBZip, vBRegion, vBPhone, vShippingType, vSendMeDigInv, vSendMeAdvByMail,
vSameAddress, vCDTp, vRemark, vOrdExData, vSendMeCpn);
var that = this;
if ((vNewCust != 1) || !vRegNewCust)
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
else {
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, function (Result) {
var Res;
eval("Res = Result");
if (Res.Status == "OK" && Res.VSRegAllowed == "1") {
var CurShop = that.GetCookies()["CurShop"];
document.cookie = "Cust_" + CurShop + "=" + Res.CustCookieVal + ";path=/";
document.cookie = "Agnt_" + CurShop + "=0;path=/";
document.cookie = "CReg_" + CurShop + "=2;path=/";
document.cookie = "CDet_" + CurShop + "=3;path=/";
}
CallBack(Result);
} // function(Result)
); // CDSAsyncCallReq
}
}
// ==================================================================================
this.PrepareUrlForAction23 = function (vEMail, vFullName, vAddress, vCity, vCountry, vZip, vRegion, vPhone,
vBFullName, vBAddress, vBCity, vBCountry, vBZip, vBRegion, vBPhone, vShippingType, vSendMeDigInv, vSendMeAdvByMail,
vSameAddress, vCDTp, vRemark, vOrdExData, vSendMeCpn) {
var Url = '';
if (vSameAddress != null && vSameAddress == "1")
Url += "&VSSameAddPrm=1";
Url += "&EMail=" + vEMail;
Url += "&Name=" + vFullName;
Url += "&Address=" + vAddress;
Url += "&City=" + vCity;
Url += "&Country=" + vCountry;
if (vZip != null)
Url += "&Zip=" + vZip;
if (vRegion != null)
Url += "&Region=" + vRegion;
Url += "&Phone=" + vPhone;
if (vBFullName != null)
Url += "&BName=" + vBFullName;
if (vBAddress != null)
Url += "&BAddress=" + vBAddress;
if (vBCity != null)
Url += "&BCity=" + vBCity;
if (vBCountry != null)
Url += "&BCountry=" + vBCountry;
if (vBZip != null)
Url += "&BZip=" + vBZip;
if (vBRegion != null)
Url += "&BRegion=" + vBRegion;
if (vBPhone != null)
Url += "&BPhone=" + vBPhone;
if (vShippingType != null)
Url += "&Delivery=" + vShippingType;
if (vSendMeDigInv != null) {
Url += "&VSDigInvPrm=";
Url += (vSendMeDigInv == 1) ? "1" : "0";
}
if (vSendMeAdvByMail != null) {
Url += "&VSAdvByMailPrm=";
Url += (vSendMeAdvByMail == 1) ? "1" : "0";
}
if (vCDTp != null)
Url += "&VSCDTp=" + vCDTp;
if (vRemark != null)
Url += "&VSOrdRemark=" + this.PrepareRemark4Url(vRemark);
if (vOrdExData != null) // 1005
Url += "&VSOrdExData=" + this.PrepareRemark4Url(vOrdExData);
if (vSendMeCpn != null) {
Url += "&VSSndCpnPrm=";
Url += (vSendMeCpn == 1) ? "1" : "0";
}
return Url;
}
// ==================================================================================
// Agents
// ==================================================================================
this.VSAgentSearchCustomers = function (vEmail, vPass, vSrchName, vSrchCity, vSrchMail, CallBack) {
var Url = this.GetBaseUrl(41, true)
Url += "&VSEmail=" + vEmail;
Url += "&VSPass=" + vPass;
Url += "&VSNameSrch=" + vSrchName;
if (vSrchCity != '')
Url += "&VSCitySrch=" + vSrchCity;
if (vSrchMail != '')
Url += "&VSMailSrch=" + vSrchMail;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// ==================================================================================
this.VSAgentSendPassword = function (vEmail, CallBack) {
var Url = this.GetBaseUrl(42, true)
Url += "&VSEmail=" + vEmail;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// ==================================================================================
this.VSAgentGetInfo = function (vEmail, vPass, CallBack) {
var Url = this.GetBaseUrl(40, true)
Url += "&VSEmail=" + vEmail;
Url += "&VSPass=" + vPass;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// ==================================================================================
// B2B reports
// ==================================================================================
this.B2BRepGetBasicFilter = function (vSort, vMDY, vDateF, vDateT, vDueDateF, vDueDateT, vRefF, vRefT, vRef2F, vRef2T, vAmountF, vAmountT) {
var Url = "";
if (vSort && (vSort > 0))
Url += "&RD=" + vSort.toString();
if (vMDY && (vMDY == 1))
Url += "&MDY=Yes";
if (vDateF && (vDateF != ""))
Url += "&DF=" + vDateF;
if (vDateT && (vDateT != ""))
Url += "&DT=" + vDateT;
if (vDueDateF && (vDueDateF != ""))
Url += "&VDF=" + vDueDateF;
if (vDueDateT && (vDueDateT != ""))
Url += "&VDT=" + vDueDateT;
if (vRefF && (vRefF != ""))
Url += "&RF" + vRefF;
if (vRefT && (vRefT != ""))
Url += "&RT" + vRefT;
if (vRef2F)
Url += "&R2F" + vRef2F;
if (vRef2T)
Url += "&R2T" + vRef2T;
if (vAmountF && (vAmountF != ""))
Url += "&SF=" + vAmountF;
if (vAmountT && (vAmountT != ""))
Url += "&ST=" + vAmountT;
return Url;
}
// ==================================================================================
// B2B Accounting Ledger
this.B2BRepHsDesign = function (CallBack, vGetCurrBal, vFullInfo) {
var Url = this.GetBaseUrl(50, true)
Url += "&VSRepType=1&VSMode=1";
if (vGetCurrBal && (vGetCurrBal == 1))
Url += "&VSGetCurrBal=Yes";
if (vFullInfo && (vFullInfo == 1))
Url += "&VSEX=1";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
this.B2BRepHsCurrBalance = function (CallBack) {
var Url = this.GetBaseUrl(50, true)
Url += "&VSRepType=1&VSMode=3";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
this.B2BRepHsIssue = function (CallBack, vOpenBalanceOnly, vSort, vMDY, vDateF, vDateT, vDueDateF, vDueDateT, vRefF, vRefT, vRef2F, vRef2T, vAmountF, vAmountT) {
var Url = this.GetBaseUrl(50, true)
Url += "&VSRepType=1";
if (vOpenBalanceOnly && (vOpenBalanceOnly == 1))
Url += "&OPTR=ON";
Url += this.B2BRepGetBasicFilter(vSort, vMDY, vDateF, vDateT, vDueDateF, vDueDateT, vRefF, vRefT, vRef2F, vRef2T, vAmountF, vAmountT);
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// ==================================================================================
// B2B Item transaction
this.B2BRepItmDesign = function (CallBack, vFullInfo) {
var Url = this.GetBaseUrl(50, true)
Url += "&VSRepType=2&VSMode=1";
if (vFullInfo && (vFullInfo == 1))
Url += "&VSEX=1";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
this.B2BRepItmIssue = function (vItemKey, CallBack, vSort, vMDY, vDateF, vDateT, vDueDateF, vDueDateT, vRefF, vRefT, vRef2F, vRef2T, vAmountF, vAmountT,
vQntF, vQntT, vPriceF, vPriceT, vItmDiscF, vItmDiscT, vGenDiscF, vGenDiscT, vNetPriceF, vNetPriceT) {
var Url = this.GetBaseUrl(50, true)
Url += "&VSRepType=2";
Url += "&SrchKey=" + vItemKey;
Url += this.B2BRepGetBasicFilter(vSort, vMDY, vDateF, vDateT, vDueDateF, vDueDateT, vRefF, vRefT, vRef2F, vRef2T, vAmountF, vAmountT);
if (vQntF && (vQntF != ""))
Url += "&QF=" + vQntF;
if (vQntT && (vQntT != ""))
Url += "&QT=" + vQntT;
if (vPriceF && (vPriceF != ""))
Url += "&PF=" + vPriceF;
if (vPriceT && (vPriceT != ""))
Url += "&PT=" + vPriceT;
if (vItmDiscF && (vItmDiscF != ""))
Url += "&DSF=" + vItmDiscF;
if (vItmDiscT && (vItmDiscT != ""))
Url += "&DST=" + vItmDiscT;
// Version 2016
if (vGenDiscF && (vGenDiscF != ""))
Url += "&GDSF=" + vGenDiscF;
if (vGenDiscT && (vGenDiscT != ""))
Url += "&GDST=" + vGenDiscT;
// Version 2016
if (vNetPriceF && (vNetPriceF != ""))
Url += "&NPF=" + vNetPriceF;
if (vNetPriceT && (vNetPriceT != ""))
Url += "&NPT=" + vNetPriceT;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// ==================================================================================
// Items Properties/Notes
// ==================================================================================
this.VSNotesGet4Search = function (vCategory, CallBack) {
var Url = this.GetBaseUrl(31, true);
Url += "&VSNtType=1";
Url += "&VSCategory=" + vCategory;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// vNumericArr: [ID|ValFrom|ValTo] or [ID||ValTo] or [ID|ValFrom|]
// vStringArr: [ID|Val]
this.VSNotesSubmitSearch = function (vCategoryPath, CallBack, vPriceF, vPriceT, vNumericArr, vStringArr) {
var Url = this.GetBaseUrl(33, true);
Url += "&CategoryPath=" + vCategoryPath;
if (vPriceF && (vPriceF != ''))
Url += "&FPIDF=" + vPriceF;
if (vPriceT && (vPriceT != ''))
Url += "&FPIDT=" + vPriceT;
if (vNumericArr != null && vNumericArr.length > 0) {
var i = 0;
for (i = 0; i < vNumericArr.length; ++i) {
var vNoteArr = new Array();
vNoteArr = vNumericArr[i].split("|");
if (vNoteArr.length == 3) {
if (vNoteArr[1] != '') // From
Url += "&NIDF" + vNoteArr[0] + "=" + vNoteArr[1];
if (vNoteArr[2] != '')
Url += "&NIDT" + vNoteArr[0] + "=" + vNoteArr[2];
}
}
}
if (vStringArr != null && vStringArr.length > 0) {
var i = 0;
for (i = 0; i < vStringArr.length; ++i) {
var vNoteArr = new Array();
vNoteArr = vStringArr[i].split("|");
if (vNoteArr.length == 2) {
if (vNoteArr[1] != '') // Val
Url += "&CID" + vNoteArr[0] + "=" + vNoteArr[1];
}
}
}
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
this.VSNotesGetNames4Refine = function (vCategory, CallBack) {
var Url = this.GetBaseUrl(31, true);
Url += "&VSNtType=2";
Url += "&VSCategory=" + vCategory;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
this.VSNotesGetValues4Refine = function (vCategory, vNoteId, vFilter, vSearchText, CallBack, vNumFromTo) {
var Url = this.GetBaseUrl(32, true);
Url += "&MainNoteID=" + vNoteId;
if (vNumFromTo != null && vNumFromTo != "")
Url += "&VSNumFromTo=" + vNumFromTo;
if (vFilter != null)
Url += "&Filter=" + vFilter;
if (vSearchText != null && vSearchText != '')
Url += "&SRCH=" + vSearchText;
Url += "&ItmCategory=" + vCategory;
//alert(Url);
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
this.VSNotesGetNames4Sort = function (vCategory, vSearchText, CallBack) {
var Url = this.GetBaseUrl(31, true);
Url += "&VSNtType=3";
Url += "&VSCategory=" + vCategory;
if (vSearchText != null && vSearchText != '')
Url += "&SRCH=" + vSearchText;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// ==================================================================================
// Related items by properties
// ==================================================================================
this.VSRelItemsGetTabs = function (vItemKey, CallBack) {
var Url = this.GetBaseUrl(37, true);
Url += "&ItemKey=" + vItemKey;
Url += "&TabID=0";
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// ==================================================================================
// Related items by properties
// ==================================================================================
this.VSRelItemsGetData = function (vItemKey, vTabId, CallBack) {
var Url = this.GetBaseUrl(37, true);
Url += "&ItemKey=" + vItemKey;
Url += "&TabID=" + vTabId;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// ==================================================================================
// Reviews
// ==================================================================================
this.VSReviewAddNew = function (vItemKey, vTitle, vName, vText, vRank, CallBack) {
var Url = this.GetBaseUrl(26, true);
Url += "&VSActionType=1";
Url += "&VSItemKey=" + vItemKey;
Url += "&VSTitle=" + vTitle;
Url += "&VSName=" + vName;
Url += "&VSText=" + PrepareRemark4Url(vText);
if (vRank != null && vRank != '')
Url += "&VSRank=" + vRank;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
this.VSReviewGetCount = function (vItemKey, CallBack) {
var Url = this.GetBaseUrl(26, true);
Url += "&VSActionType=2";
Url += "&VSItemKey=" + vItemKey;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
this.VSReviewGetData = function (vItemKey, vDateFormat, CallBack) {
var Url = this.GetBaseUrl(26, true);
Url += "&VSActionType=3";
Url += "&VSItemKey=" + vItemKey;
if (vDateFormat != null && vDateFormat != '')
Url += "&VSDtFt=" + vDateFormat;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// ==================================================================================
// Guests
// ==================================================================================
this.B2CToGuest = function (vEmail, vCurrentPass, CallBack) {
var Url = this.GetBaseUrl(38, true);
Url += "&VSMode=2";
Url += "&VSEmail=" + vEmail;
Url += "&VSCurP=" + vCurrentPass;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
this.GuestToB2C = function (vEmail, CallBack) {
var Url = this.GetBaseUrl(38, true);
Url += "&VSMode=1";
Url += "&VSEmail=" + vEmail;
CDSAsyncCallReq("https://shop4.wizsoft.com/VSHOP/WSHOP.wzx", Url, CallBack);
}
// ******************************************************************
this.FormatNumber4Show = function (vNumberStr, vFix2, vNoZero) {
if (vNumberStr == '')
return '';
var vNumStr = '';
var vChar;
for (i = 0; i < vNumberStr.length; i++) {
vChar = vNumberStr.charAt(i);
if ((vChar == '.') || ((vChar >= "0") && (vChar <= '9')))
vNumStr += vNumberStr.substr(i, 1);
}
if (vFix2 && (vFix2 == 1)) {
var vPrice = parseFloat(vNumStr);
vPrice = vPrice.toFixed(2);
vNumStr = vPrice.toString();
}
if (vNoZero && vNoZero == 1)
vNumStr = parseFloat(vNumStr).toString();
var vParts = vNumStr.split(".");
return vParts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (vParts[1] ? "." + vParts[1] : "");
}
//==============================================================
this.FormatPrice4Show = function (vPriceStr, vCurrency, vFix2) {
var vFormattedPrice = this.FormatNumber4Show(vPriceStr, vFix2);
if (this.IsHebrew())
return vFormattedPrice + ' ' + vCurrency;
else
return vCurrency + ' ' + vFormattedPrice;
}
//==============================================================
this.FormatPrice4ShowNoZero = function (vFormattedPriceStr) {
// Important! vFormattedPriceStr = 15,582.00
return vFormattedPriceStr.replace(".00", "");
}
//==============================================================
this.IsHeshTree = function (vItemFlags) {
return (vItemFlags & (1 << 11)) != 0 ? 1 : 0;
}
this.HasMashlim = function (vItemFlags) {
return (vItemFlags & (1 << 10)) != 0 ? 1 : 0;
}
//==============================================================
// vType = 1: Main page, vType = 2: Before purch
this.B2BDisplayCustDetails = function (vB2BSwCustDet, vType) {
if (vB2BSwCustDet=="3")
return true;
if (vType == 1)
return vB2BSwCustDet=="1";
else if (vType == 2)
return vB2BSwCustDet=="2";
return false;
}
//==============================================================
this.GetCustPayOptions = function (vCrAllowed, vCrAllowedPayLater) {
if (this.IsB2B())
return (vCrAllowed == 1) ? 1 : 2;
else {
var vOptions = 0;
if (vCrAllowed == 1)
vOptions += 1;
if (vCrAllowedPayLater != 'NONE')
vOptions += 2;
return vOptions;
}
}
//==============================================================
this.PrepareRemark4Url = function (vRemark) {
if ((vRemark == null) || (vRemark == ''))
return "";
var vTempRem = vRemark;
vTempRem = vTempRem.replace(/\r\n/gi, "%0A");
vTempRem = vTempRem.replace(/\n/gi, "%0A");
return vTempRem;
}
//==============================================================
this.IsPaymentsAllowed = function (vCrAllowed, vPaymentsTab, vCustSelectedPayOption) {
return (vCrAllowed == "1") && (vCustSelectedPayOption != "3") && vPaymentsTab && (vPaymentsTab.length > 0);
}
//==============================================================
this.IsCouponAllowed = function (vCpAvailable, vCustSelectedPayOption) {
return (vCpAvailable == "1") && (vCustSelectedPayOption != "3");
}
// ******************************************************************
// Suzi, Sep 2014: vShopImagePath is the shop images path according to the language
this.ImagPath = 'https://shop4.wizsoft.com/vshop/images/btouchimg/heb'; // 20.10.14: Will be deleted soon...
this.vShopImagePath = 'https://shop4.wizsoft.com/vshop/images/btouchimg/heb';
this.vShopLanguage = 'HE';
this.ProgPath='https://shop4.wizsoft.com/VSHOP/WSHOP.wzx';
this.ExePath='https://shop4.wizsoft.com/VSHOP';
this.IncPath='https://shop4.wizsoft.com/vshop/udiver/css';
this.shopID=ShopID;
this.SetShop(ShopName);
this.WizShopInit();
}