Commit 4049e733 authored by Valentin Skripnikov's avatar Valentin Skripnikov

Merge branch 'a.habibulina-dev' into 'a.habibulina'

A.habibulina dev

See merge request !41
parents 2d4774f4 8717250d
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
background-color: #49b785; background-color: #49b785;
border-color: #49b785; border-color: #49b785;
color: #ffffff; color: #ffffff;
left: 40%;
} }
.container{ .container{
......
...@@ -69,7 +69,9 @@ function ShowMessage(message){ ...@@ -69,7 +69,9 @@ function ShowMessage(message){
}, 3000); }, 3000);
}; };
var user;
var portal = { var portal = {
player : null, player : null,
clearPlayer : function() { clearPlayer : function() {
...@@ -88,6 +90,26 @@ var portal = { ...@@ -88,6 +90,26 @@ var portal = {
}); });
} }
}); });
var formExistance;
////формирование Пн и Вскр для формирования поискового запроса по форме
var cur_date = new Date();
var StrPeriod = timeComputing(cur_date); //строка Пнд+" "+Вскр
var StrMonday = StrPeriod.substring(0, 10);
var StrSunday = StrPeriod.substring(11);
AS.FORMS.ApiUtils.simpleAsyncGet("rest/api/person/auth", function(userData){
AS.FORMS.ApiUtils.simpleAsyncGet("rest/api/asforms/search?modifiedFrom="+StrMonday+"&modifiedTo="+StrSunday+"&formCode=timesheet&field=ts_author&type=partial&recordsCount=1&search="+userData.lastname, function(success){
AS.SERVICES.hideWaitWindow();
portal.player.view.setEditable(true);
portal.player.showFormData("097a00e2-430c-436d-92e5-c2ea8edc5b30", 1, success);
portal.player.view.appendTo($('#form_player_div'));
ShowMessage("Документ успешно открыт!");
var formExistance = true;
}, 'json', function(){formExistance = false;});
if (formExistance)
{
AS.FORMS.ApiUtils.simpleAsyncGet('rest/api/registry/create_doc?registryCode=registry_timesheets', function(result){ AS.FORMS.ApiUtils.simpleAsyncGet('rest/api/registry/create_doc?registryCode=registry_timesheets', function(result){
if(result.errorCode != "0") { if(result.errorCode != "0") {
AS.SERVICES.hideWaitWindow(); AS.SERVICES.hideWaitWindow();
...@@ -95,13 +117,14 @@ var portal = { ...@@ -95,13 +117,14 @@ var portal = {
return; return;
} else { } else {
AS.SERVICES.hideWaitWindow(); AS.SERVICES.hideWaitWindow();
ShowMessage("Документ успешно создан!");
portal.player.view.setEditable(true); portal.player.view.setEditable(true);
portal.player.showFormData(result.documentID, 0, result.dataUUID); portal.player.showFormData(result.documentID, 0, result.dataUUID);
portal.player.view.appendTo($('#form_player_div')); portal.player.view.appendTo($('#form_player_div'));
ShowMessage("Документ успешно создан!");
} }
}, 'json'); }, 'json');
}
});
}, },
saveData : function(){ saveData : function(){
...@@ -125,28 +148,63 @@ var portal = { ...@@ -125,28 +148,63 @@ var portal = {
}, },
main: function (view, model) { main: function (view, model) {
var serverDateTime = portal.player.model.getModelWithId("ts_date_created").value;
var period = timeComputing(serverDateTime);
var StrMonday = period.substring(0, 10);
var StrSunday = period.substring(11);
portal.player.model.getModelWithId("ts_period_date_from").setValue(StrMonday);
portal.player.model.getModelWithId("ts_period_date_to").setValue(StrSunday);
portal.player.model.on("valueChange", function(){
countingScore();
});
}
};
function countingScore(){
////Расчет итогового количества часов происходит при нажатии кнопки сохранения
var tsTable = portal.player.model.playerModel.getModelWithId('ts_timesheet_table');
var thModel = portal.player.model.playerModel.getModelWithId('ts_total_hours');
var days = {'monday': 0, 'tuesday': 0, 'wednesday': 0, 'thursday': 0, 'friday': 0, 'saturday': 0, 'sunday': 0};;
for(var i in days) {
tsTable.modelBlocks.forEach(function(modelBlock) {
modelBlock.forEach(function (m) {
if (m.asfProperty.id === i) {
var n = parseFloat(m.getValue());
if(_.isNaN(n)){
n = 0;
}
days[i] = days[i] + n;
}
});
});
}
var totalHours = 0;
for(var n in days) {
totalHours += days[n];
jQuery('#ts_timesheet_table_total_'+n).text(days[n]);
}
thModel.setValue(totalHours.toString());
};
function timeComputing(serverDateTime){
function zeroCheck(num){ function zeroCheck(num){
if (num < 10) {num = "0"+ num;} if (num <= 9) {num = "0"+ num;}
return num; return num;
}; };
var serverDateTime = portal.player.model.getModelWithId("ts_date_created").value;
var WeekDay = new Date(serverDateTime); var WeekDay = new Date(serverDateTime);
WeekDay = WeekDay.getDay(); WeekDay = WeekDay.getDay();
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);
var monday = new Date(serverDateTime); var monday = new Date(serverDateTime);
monday.setDate(sunday.getDate() - 6); monday.setDate(sunday.getDate() - 6);
var StrSunday = sunday.getFullYear() + "-" + zeroCheck(sunday.getMonth()+1) + "-" + zeroCheck(sunday.getDate()); var StrSunday = sunday.getFullYear() + "-" + zeroCheck(sunday.getMonth()+1) + "-" + zeroCheck(sunday.getDate());
portal.player.model.getModelWithId("ts_period_date_to").setValue(StrSunday);
var StrMonday = monday.getFullYear() + "-" + zeroCheck(monday.getMonth()+1) + "-" + zeroCheck(monday.getDate()); var StrMonday = monday.getFullYear() + "-" + zeroCheck(monday.getMonth()+1) + "-" + zeroCheck(monday.getDate());
portal.player.model.getModelWithId("ts_period_date_from").setValue(StrMonday); return StrMonday+" "+StrSunday;
}
}; };
//переменные для WaitCircles(); //переменные для WaitCircles();
...@@ -229,4 +287,3 @@ $(document).ready(function(){ ...@@ -229,4 +287,3 @@ $(document).ready(function(){
portal.saveData(); portal.saveData();
}); });
}); });
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