דמי הרשמה
@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@100;200;300;400;500;600;700;800;900&display=swap');
html,
body {
height: 100%;
}
body {
direction: rtl;
padding: 25px;
font-family: 'Heebo', sans-serif;
}
iframe {
height: 100%;
width: 100%;
}
thead {
background-color: #cccccc;
}
tbody {
background-color: #eee9e9;
}
th,
td {
padding: 10px;
}
h2 {
text-align: center;
}
.dyncontent {
height: 1000px;
}
.orderdetails {
display: none;
}
@media (max-width:480px) {
.orderdetails {
display:block;
}
}
let crmordernumber;
let sum;
let productname;
let maxNumOfPayments;
let items;
init();
async function init() {
const queryString = window.parent.location.search;
const urlParams = new URLSearchParams(queryString);
const id = urlParams.get('id'); //|| 'b024acf2-d20e-4c5e-9c40-662139152346';
const type = urlParams.get('type'); //|| 1;
if (!id || !type) {
alert("שגיאה, נא ליצור קשר");
return;
}
// דמי הרשמה
const res123 = await axios.post('https://pbd-s.herokuapp.com/sendPlQuery', {
token: '0c59560e-015b-4fcb-a8a5-cd908d8bdebb', criteria: {
"objecttype": "17",
"sort_type": "desc",
"query": `crmorderitemid = ${id}`,
"fields": "crmorderidname, productname, pcfsystemfield123, itemtotalprice, pcfsystemfield103, crmorderid, itemquantity, itemprice"
}
}).then(res => res.data).then(res => res.data).then(data => data.Data[0]);
crmordernumber = res123.crmorderidname;
sum = res123.itemtotalprice;
productname = res123.productname;
maxNumOfPayments = res123.pcfsystemfield123 || 1;
//קורס
if (res123.pcfsystemfield103 == 'קורסים') {
items = await axios.post('https://pbd-s.herokuapp.com/sendPlQuery', {
token: '0c59560e-015b-4fcb-a8a5-cd908d8bdebb', criteria: {
"objecttype": "17",
"sort_type": "desc",
"query": `(crmorderid = ${res123.crmorderid}) AND ((pcfsystemfield103 = 3) OR (pcfsystemfield103 = 2))`,
"fields": "crmorderidname, productname, pcfsystemfield123, itemtotalprice, itemquantity, itemprice"
}
}).then(res => res.data).then(res => res.data).then(data => data.Data);
}
if (!sum) {
alert('לא הוגדר סכום')
return;
}
//קורס
if (res123.pcfsystemfield103 == 'קורסים') {
let strHTML = `
פרטי הזמנה:
שם המוצר |
כמות |
מחיר |
`
for (let i = 0; i < items.length; i++) {
strHTML += `
${items[i].productname} |
${parseInt(items[i].itemquantity)} |
${parseInt(items[i].itemprice)} |
`
}
const sumWithInitial = items.reduce(
(accumulator, currentValue) => accumulator + currentValue.itemtotalprice,
0,);
strHTML += `סה"כ | ${sumWithInitial} |
`
strHTML += `
`;
document.querySelector('.orderdetails').innerHTML = strHTML;
}
//דמי הרשמה
if (res123.pcfsystemfield103 == 'דמי הרשמה') {
let strHTML = `
פרטי הזמנה:
שם המוצר |
כמות |
מחיר |
`
strHTML += `
${res123.productname} |
${parseInt(res123.itemquantity)} |
${parseInt(res123.itemprice)} |
`
strHTML += `סה"כ | ${res123.itemtotalprice} |
`
strHTML += `
`;
document.querySelector('.orderdetails').innerHTML = strHTML;
}
const url = await axios.post('https://hook.eu1.make.com/9wgtoq2gn44krjxuclvdqsxyfo5iklys', {
maxNumOfPayments,
productname,
crmordernumber,
id,
sumtobill: sum,
type
}).then(res => res.data.url);
var iframe = document.createElement('iframe');
iframe.src = url
//document.body.appendChild(iframe);
document.querySelector('.dyncontent').appendChild(iframe);
}