Commit a3425dc2 authored by Alina Habibulina's avatar Alina Habibulina

+ week score

parent aa9953c1
...@@ -133,6 +133,8 @@ var portal = { ...@@ -133,6 +133,8 @@ var portal = {
return; return;
} }
countingScore();
var data = portal.player.model.asfDataId; var data = portal.player.model.asfDataId;
portal.player.saveFormData(function(data){ portal.player.saveFormData(function(data){
if(_.isUndefined(data)){ if(_.isUndefined(data)){
...@@ -152,8 +154,38 @@ var portal = { ...@@ -152,8 +154,38 @@ var portal = {
var StrSunday = period.substring(11); var StrSunday = period.substring(11);
portal.player.model.getModelWithId("ts_period_date_from").setValue(StrMonday); portal.player.model.getModelWithId("ts_period_date_from").setValue(StrMonday);
portal.player.model.getModelWithId("ts_period_date_to").setValue(StrSunday); portal.player.model.getModelWithId("ts_period_date_to").setValue(StrSunday);
} }
};
function countingScore(){
////Расчет итогового количества часов
////in the "table" variable - array with the all data
//// 10 columns in row, 1st row - table headers
//// if we have only 1 full row - we have 20 values in array, every extra row - +10 value in array
/////first 3 columns - project and ect;
///// last 7 colums is what we need - the value of hours in day
var table = portal.player.model.getModelWithId("ts_timesheet_table").getAsfData().findElement().data;
var score = 0, monday = 0, tuesday = 0, wednesday = 0, thursday = 0, friday = 0, saturday = 0, sunday = 0;
for (var i = 10; i < table.length; i++){
var row = Number.parseInt(i/10);
if(table[i].id == ("project-b"+row) || table[i].id == ("task-b"+row) || table[i].id == ("result-b"+row))
{
continue;
} else if(table[i].id == ("monday-b"+row)) { monday = table[i].value; score = Number.parseFloat(score) + Number.parseFloat(monday);}
else if (table[i].id == ("tuesday-b"+row)) { tuesday = table[i].value; score = Number.parseFloat(score) + Number.parseFloat(tuesday);}
else if (table[i].id == ("wednesday-b"+row)) { wednesday = table[i].value; score = Number.parseFloat(score) + Number.parseFloat(wednesday);}
else if (table[i].id == ("thursday-b"+row)) { thursday = table[i].value; score = Number.parseFloat(score) + Number.parseFloat(thursday);}
else if (table[i].id == ("friday-b"+row)) { friday = table[i].value; score = Number.parseFloat(score) + Number.parseFloat(friday);}
else if (table[i].id == ("saturday-b"+row)) { saturday = table[i].value; score = Number.parseFloat(score) + Number.parseFloat(saturday);}
else if (table[i].id == ("sunday-b"+row)) { sunday = table[i].value; score = Number.parseFloat(score) + Number.parseFloat(sunday);}
}
portal.player.model.getModelWithId("ts_total_hours").setValue(score.toString());
ShowMessage(score);
}; };
function timeComputing(serverDateTime){ function timeComputing(serverDateTime){
function zeroCheck(num){ function zeroCheck(num){
...@@ -161,7 +193,7 @@ function timeComputing(serverDateTime){ ...@@ -161,7 +193,7 @@ function timeComputing(serverDateTime){
return num; return num;
}; };
var WeekDay = new Date(serverDateTime); var WeekDay = new Date(serverDateTime);
WeekDay = WeekDay.getDay(); WeekDay = WeekDay.getDay() + 1;
var shift = 7 - WeekDay; var shift = 7 - WeekDay;
var sunday = new Date(serverDateTime); var sunday = new Date(serverDateTime);
sunday.setDate(sunday.getDate() + shift); sunday.setDate(sunday.getDate() + shift);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment