Commit aa9953c1 authored by Alina Habibulina's avatar Alina Habibulina

+ open existance form

parent a06f1446
...@@ -70,6 +70,7 @@ function ShowMessage(message){ ...@@ -70,6 +70,7 @@ function ShowMessage(message){
}; };
var portal = { var portal = {
player : null, player : null,
clearPlayer : function() { clearPlayer : function() {
...@@ -88,6 +89,26 @@ var portal = { ...@@ -88,6 +89,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/asforms/search", function(success){
AS.SERVICES.hideWaitWindow();
portal.player.view.setEditable(true);
portal.player.showFormData("6af6bf3d-a093-4a33-990c-2ec98c15423a",1, success);
portal.player.view.appendTo($('#form_player_div'));
ShowMessage("Документ успешно открыт!");
var formExistance = true;
}, 'json', {'modifiedFrom': StrMonday, 'modifiedTo': StrSunday,'formCode':'timesheet','recordsCount':1,'sortDir':'desc'}, function(){formExistance = false;});
if (formExistance == false)
{
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();
...@@ -101,7 +122,7 @@ var portal = { ...@@ -101,7 +122,7 @@ var portal = {
portal.player.view.appendTo($('#form_player_div')); portal.player.view.appendTo($('#form_player_div'));
} }
}, 'json'); }, 'json');
}
}, },
saveData : function(){ saveData : function(){
...@@ -125,28 +146,30 @@ var portal = { ...@@ -125,28 +146,30 @@ 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);
}
};
function timeComputing(serverDateTime){
function zeroCheck(num){ function zeroCheck(num){
if (num < 10) {num = "0"+ num;} if (num < 10) {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();
......
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