ZigBox
Please select a Project and at least one file
Code.gs
function doGet() {
var template = HtmlService.createTemplateFromFile('index');
return template.evaluate().setTitle("Bakerson ZigBox").setSandboxMode(HtmlService.SandboxMode.IFRAME);
}
function saveFile(data,name,folderId, desc) {
var contentType = data.substring(5,data.indexOf(';')); Logger.log("contentType" + contentType)
var file = Utilities.newBlob(Utilities.base64Decode(data.substr(data.indexOf('base64,')+7)), contentType, name); Logger.log("file" + file)
var getFolder = DriveApp.getFolderById(folderId);
var createFile = getFolder.createFile(file);
var fileId = createFile.getId();
var getFile = DriveApp.getFileById(fileId);
var folderName = getFolder.getName();
var folderUrl = getFolder.getUrl();
var activeUser = Session.getActiveUser();
getFile.setDescription("Comments: " + desc + ". Uploaded by " + activeUser);
// Send confirmation Email to admin,submitter and social@bakerson.com
// This will show up as the sender's name
var sendername = "Bakerson ZigBox";
var to = "admin@bakerson.com"; // + ",social@bakerson.com";
//var cc = "social@bakerson.com" + "," + activeUser;
var cc = activeUser;
// Get the sunvek logo image
var thumbnail = "http://zigmands.com/mockups/bakerson/bakerson_logo.png";
var thumbnailBlob = UrlFetchApp.fetch(thumbnail).getBlob().setName("thumbnailBlob");
// Create the body of the report
var message = "
"
+ "3030 E Cactus Rd #105, Phoenix, AZ 85032
"
+ "www.Bakerson.com
"
+ "Phone: (602) 845-9620
"
+ "
Bakerson ZigBox
"
+ "
Click to access images.";
// Subject of Email
var subject = "New Image/s added to Bakerson Project " + folderName;
MailApp.sendEmail({
name: sendername,
to: to,
cc: cc,
subject: subject,
htmlBody: message,
//,attachments:[proposalPdf],
inlineImages:
{
propertyThumbnail: thumbnailBlob
}
});
}
//these two functions could be cleaned up
function getMenuListFromSheet() {
var p = SpreadsheetApp.openById("1Bx0_SzA55RHx1Ls0R_Avg5I8oto3SjBZ4JUCFJ8PzyU").getLastRow();
var q = p-2;
return SpreadsheetApp.openById("1Bx0_SzA55RHx1Ls0R_Avg5I8oto3SjBZ4JUCFJ8PzyU")
.getSheets()[0].getRange(3,10,q,1).getValues();
}
function getIdsFromSheet() {
var p = SpreadsheetApp.openById("1Bx0_SzA55RHx1Ls0R_Avg5I8oto3SjBZ4JUCFJ8PzyU").getLastRow();
var q = p-2;
return SpreadsheetApp.openById("1Bx0_SzA55RHx1Ls0R_Avg5I8oto3SjBZ4JUCFJ8PzyU")
.getSheets()[0].getRange(3,4,q,1).getValues();
}
index.html
Please select a Project and at least one file