Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue#73 client google group and time sheet member audit #91

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/appsscript.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"timeZone": "Asia/Hong_Kong",
"dependencies": {
"enabledAdvancedServices": [{
"userSymbol": "Drive",
"serviceId": "drive",
"version": "v2"
}, {
"userSymbol": "AdminDirectory",
"serviceId": "admin",
"version": "directory_v1"
}],
"libraries": [{
"userSymbol": "TeamGroupMemberAudit",
"libraryId": "1W_ijzgRXMDNHMVEofeMZ0xoQQf7jLvJXWGjuoJls42tUem7yoe-0WAox",
"version": "4",
"developmentMode": true
}]
},
"exceptionLogging": "STACKDRIVER"
}
1 change: 1 addition & 0 deletions src/timesheetAudit/.clasp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"scriptId":"1W_ijzgRXMDNHMVEofeMZ0xoQQf7jLvJXWGjuoJls42tUem7yoe-0WAox"}
17 changes: 17 additions & 0 deletions src/timesheetAudit/Reports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var rawInfo = onGoingCLients();
function Report(){
rawInfo.map(function(e) {
if (e.clientName === 'Coderbunker'){
timeSheetReport(e);
googleGroupReport(e);
}
}
);
// rawInfo.forEach(function(e){
// if(e.clientName == 'Coderbunker'){
// timeSheetReport(e);
// googleGroupReport(e);
// };
// }
// );
}
53 changes: 53 additions & 0 deletions src/timesheetAudit/allUsersData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
function FreelancersInfo(freelancerInfo) {
var arrayOfMembers = JSON.parse(DriveApp.getFileById('1YgThK0YM8d_RiEc-IBPBBft0vMEeGQGg').getBlob().getDataAsString());
var userObject = arrayOfMembers.filter(
function(currentUserObject){
//Logger.log(currentUserObject)
if(currentUserObject['fullname'].toLowerCase().trim() === freelancerInfo.toString().toLowerCase().trim()){
return currentUserObject;
}
/*else if (currentUserObject['altnames']!== undefined)
{
var altNamesArray = currentUserObject['altnames'].split(',').toLowerCase()
if (altNamesArray.trim().indexOf(freelancerInfo.toString().toLowerCase().trim())!== -1){
return currentUserObject;
}
}*/
else if(currentUserObject['email'] !== undefined && currentUserObject['email'].toString().toLowerCase().trim() === freelancerInfo.toString().toLowerCase().trim()){
return currentUserObject;
}
/*else{
if(currentUserObject['altemails'] !== undefined
//("'"+currentUserObject['altemails']+"'".includes(freelancerInfo.toString().toLowerCase()))
){
if(currentUserObject['altemails'].toString().includes(freelancerInfo.toString().toLowerCase())){
//var altEmailsArray = currentUserObject['altemails'].toString().split(',').toLowerCase()
//if ( altEmailsArray.indexOf(freelancerInfo.toString().toLowerCase()) !== -1){
return currentUserObject;
}
}
}*/
}
)[0];
return userObject;
// for (var object in arrayOfMembers){
// var name = arrayOfMembers[object].fullname.toLowerCase();
// // CHECK IF THERE AN ALTEMAIL OR NOT TO ASSIGN IT TO THE PERSON EMAILS
// var emails = arrayOfMembers[object].email ;
// var altemail = arrayOfMembers[object].altemails;
// if ((name.trim() || emails.trim() || altemail.trim() ) === freelancerInfo.toString().toLowerCase().trim()){
// if (altemail !== undefined){
// return {
// name : name,
// email: emails,
// altemails : altemail
// }
// }else{
// return {
// name : name,
// email: emails,
// };
// }
// }
// }
}
21 changes: 21 additions & 0 deletions src/timesheetAudit/appsscript.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"timeZone": "Asia/Hong_Kong",
"dependencies": {
"enabledAdvancedServices": [{
"userSymbol": "Drive",
"serviceId": "drive",
"version": "v2"
}, {
"userSymbol": "AdminDirectory",
"serviceId": "admin",
"version": "directory_v1"
}],
"libraries": [{
"userSymbol": "TeamGroupMemberAudit",
"libraryId": "1W_ijzgRXMDNHMVEofeMZ0xoQQf7jLvJXWGjuoJls42tUem7yoe-0WAox",
"version": "4",
"developmentMode": true
}]
},
"exceptionLogging": "STACKDRIVER"
}
31 changes: 31 additions & 0 deletions src/timesheetAudit/clientsGroups.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var onGoingClientsIds = onGoingCLients().map(function (group) {
return group.groupId
});
function listAllGroups() {
var pageToken;
var page;
var onGoingGroups=[] ;
do {
page = AdminDirectory.Groups.list({
domain: 'coderbunker.com',
maxResults: 150,
pageToken: pageToken
});
var groups = page.groups;
if (groups) {
for (var i = 0; i < groups.length; i++) {
if (onGoingClientsIds !== undefined && onGoingClientsIds.indexOf(groups[i].id) !== -1) {
onGoingGroups.push(groups[i])
}
;
// Logger.log('%s (%s)', group.name, group.email)
}
}
// else {
// Logger.log('No groups found.')
// }
pageToken = page.nextPageToken;
} while (pageToken)
//Logger.log(onGoingGroups);
return onGoingGroups;
}
48 changes: 48 additions & 0 deletions src/timesheetAudit/onGoingCLients.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
function onGoingCLients() {
var onGoingClientsList=[];
// get the current sheet in the active spreadSheet in this case {coderbunker opportunities account report}
var currentSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var currentSheet = currentSpreadsheet.getSheetByName('Accounts');

//status rows and colums values
var statusFirstRow = 1 ;
var statusLastRow = currentSheet.getLastRow()-1;
var statusFirstColumn = 1;
var statusLastColumn = currentSheet.getLastColumn() -1;

// status Data range
var status = currentSheet.getRange(statusFirstRow, statusFirstColumn, statusLastRow, statusLastColumn);
var statusValues = status.getValues();

// iterrate on the status to pick only the status with: 'ongoing'
for (var row in status.getValues()){
// assign the row of a client to a variable
var clientRow = statusValues[row];
var name = clientRow[statusValues[0].indexOf('Client')];
var email = clientRow[statusValues[0].indexOf('email')];
var status = clientRow[statusValues[0].indexOf('Status')];
var folderRootLink = clientRow[statusValues[0].indexOf('Folder')];
var timesheetLink = clientRow[statusValues[0].indexOf('Timesheet')];
var auditsheetLink = clientRow[statusValues[0].indexOf('Auditsheet')];
var groupsId = clientRow[statusValues[0].indexOf('Group Id')];

// check is the status of the client is 'ongoing'
if (clientRow[statusValues[0].indexOf('Status')] ==='Ongoing'){
//push a client object to onGoingClients with clients informations (clientName, CurrentStatus, timeSheetLink, auditsheetLink)
var clientInfo = {
clientName: name,
currentStatus : status,
folderLink : folderRootLink ,
timeSheetLink : timesheetLink,
email : email,
auditLink : auditsheetLink,
groupId : groupsId
};
//CREATE A CLIENT REPORT SPREADSHEET IN THE CLIENT FOLDER
onGoingClientsList.push(
clientInfo
);
}
}
return onGoingClientsList;
}
Loading