dojo.provide("parus.designerReportPeriodDateDialog");

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

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

dojo.require("parus.editDictionaryDialog");

dojo.declare("parus.designerReportPeriodDateDialog", [parus.editDictionaryDialog], {

  onLoadParams: function(store, item, editMode) {
    this.inherited(arguments);

    if (store && item) {
      this.dateEdit.attr("value", parus.formats.stringToDate(store.getValue(item, "BDATE")));
    }
  },

  executeInsert: function(duplicate) {
    var response = parus.database.execute("insertDesignerReportPeriodDate", {
      PRN: this.prn,
      BDATE: parus.formats.dateToString(this.dateEdit.attr("value"))
    });

    if (response) return parus.parus8.nodeField(parus.parus8.rowNodes(response)[0], "NRN");
  },

  executeUpdate: function() {
    var response = parus.database.execute("updateDesignerReportPeriodDate", {
      RN: this.rn,
      BDATE: parus.formats.dateToString(this.dateEdit.attr("value"))
    });

    return !!response;
  },

  executeDelete: function(store, item) {
    var response = parus.database.execute("deleteDesignerReportPeriodDate", {
      RN: store.getValue(item, "RN")
    });

    return !!response;
  }

});