function doGet() {
return HtmlService.createTemplateFromFile('index')
.evaluate()
.addMetaTag('viewport', 'width=device-width, initial-scale=1')
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}
function submitData(obj) {
var ss = SpreadsheetApp.openById("1zt9JdsV0PX-xc-L-VzWgxCZQoyeDlAZrfSwIfnGXZnE");
var sheet = ss.getSheetByName("data");
var flag = 1;
var lr = sheet.getLastRow();
for (var i = 1; i <= lr; i++) {
var version = sheet.getRange(i, 1).getValue(); // Assuming "Tên phiên bản" is in column 1
if (version == obj) {
flag = 0;
var price = sheet.getRange(i, 2).getValue(); // Assuming "Giá niêm yết" is in column 2
var discount = sheet.getRange(i, 3).getValue(); // Assuming "Khuyến mãi" is in column 3
var afterDiscount = sheet.getRange(i, 4).getValue(); // Assuming "Giá sau KM" is in column 4
var freeGift = sheet.getRange(i, 5).getValue(); // Assuming "Tặng kèm" is in column 5
var totalCost = sheet.getRange(i, 6).getValue(); // Assuming "Tổng phí" is in column 6
var onroadPrice = sheet.getRange(i, 7).getValue(); // Assuming "Giá lăn bánh" is in column 7
var data = buildTable(version, price, discount, afterDiscount, freeGift, totalCost, onroadPrice);
return data;
}
}
if (flag == 1) {
var data = "
Bạn chưa điền Tên phiên bản hoặc chưa chính xác!
";
return data;
}
}
// This function builds the HTML table with 7 columns
function buildTable(version, price, discount, afterDiscount, freeGift, totalCost, onroadPrice) {
var tableHtml = "
";
tableHtml += " nhập tên phiên bản đầy đủ nhé |
";
tableHtml += "";
tableHtml += "| Tên phiên bản | ";
tableHtml += "Giá niêm yết | ";
tableHtml += "Khuyến mãi | ";
tableHtml += "Giá sau KM | ";
tableHtml += "Tặng kèm | ";
tableHtml += "Tổng phí | ";
tableHtml += "Giá lăn bánh | ";
tableHtml += "
";
tableHtml += "";
tableHtml += "| " + version + " | ";
tableHtml += "" + price.toLocaleString('vi-VN') + " | "; // Use toLocaleString for VND format
tableHtml += "" + discount.toLocaleString('vi-VN') + " | "; // Use toLocaleString for VND format
tableHtml += "" + afterDiscount.toLocaleString('vi-VN') + " | "; // Use toLocaleString for VND format
tableHtml += "" + freeGift + " | ";
tableHtml += "" + totalCost.toLocaleString('vi-VN') + " | "; // Use toLocaleString for VND format
tableHtml += "" + onroadPrice.toLocaleString('vi-VN') + " | "; // Use toLocaleString for VND format
tableHtml += "
";
tableHtml += "
";
return tableHtml;
}
0 Nhận xét