Commit 2d4774f4 authored by Valentin Skripnikov's avatar Valentin Skripnikov

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

+ time period

See merge request !39
parents fa2d3497 a06f1446
......@@ -81,6 +81,13 @@ var portal = {
createPlayer : function(){
portal.clearPlayer();
portal.player = AS.FORMS.createPlayer();
AS.FORMS.bus.on(AS.FORMS.EVENT_TYPE.formShow, function (event, model, view) {
if (model.formCode === "timesheet") {
model.on(AS.FORMS.EVENT_TYPE.dataLoad, function() {
portal.main(portal.player.view.getViewWithId("main_script"), portal.player.model.getModelWithId("main_script"));
});
}
});
AS.FORMS.ApiUtils.simpleAsyncGet('rest/api/registry/create_doc?registryCode=registry_timesheets', function(result){
if(result.errorCode != "0") {
AS.SERVICES.hideWaitWindow();
......@@ -92,7 +99,9 @@ var portal = {
portal.player.view.setEditable(true);
portal.player.showFormData(result.documentID, 0, result.dataUUID);
portal.player.view.appendTo($('#form_player_div'));
}}, 'json');
}
}, 'json');
},
saveData : function(){
......@@ -113,6 +122,30 @@ var portal = {
ShowMessage("Данные сохранены");
}
});
},
main: function (view, model) {
function zeroCheck(num){
if (num < 10) {num = "0"+ num;}
return num;
};
var serverDateTime = portal.player.model.getModelWithId("ts_date_created").value;
var WeekDay = new Date(serverDateTime);
WeekDay = WeekDay.getDay();
var shift = 7 - WeekDay;
var sunday = new Date(serverDateTime);
sunday.setDate(sunday.getDate() + shift);
var monday = new Date(serverDateTime);
monday.setDate(sunday.getDate() - 6);
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());
portal.player.model.getModelWithId("ts_period_date_from").setValue(StrMonday);
}
};
......
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