dojo.provide("parus.balanceCheckAbsentReportsDialog");

dojo.require("dijit.Dialog");
dojo.require("dijit.form.Button");

dojo.require("parus.parus8");
dojo.require("parus.dialog");

dojo.declare("parus.balanceCheckAbsentReportsDialog", [parus.Dialog], {

  _lastValues: null,

  onShow: function() {
    this.restoreFormLastValues();
    if (!this.reportDate.attr("value")) this.reportDate.attr("value", new Date());
    var v = parus.parus8.nodeField(parus.parus8.rowNodes(parus.database.execute("GetDefaultAgentGroup", {}))[0], "VALUE");
    if (v) this.agentsGroupEdit.attr("value", v);
  },


  onClose: function() {
    this.saveFormLastValues();
  },


  saveFormLastValues: function() {

    this._lastValues["agentsGroupEdit"] = this.agentsGroupEdit.value;

    this._lastValues["reportDate"] = dojo.date.locale.format(this.reportDate.value, {
      selector: "date",
      datePattern: "dd.MM.yyyy"
    });
    this._lastValues["userSize"] = this.userSize;
    parus.userdata.set(this.declaredClass, this._lastValues);
  },

  restoreFormLastValues: function() {
    this._lastValues = parus.userdata.get(this.declaredClass) || {};

    this.reportDate.attr("value", this._lastValues["reportDate"] ? dojo.date.locale.parse(this._lastValues["reportDate"], {
      datePattern: "dd.MM.yyyy",
      selector: "date"
    }) : null);
    this.agentsGroupEdit.attr("value", this._lastValues["agentsGroupEdit"]);
    this.userSize = this._lastValues["userSize"] || null;
  }


});