<script>


		var ndat = new Date();
//    console.log(ndat);
    console.log(ndat.getMonth());
		ndat.setMonth(ndat.getMonth()+6);
    console.log(ndat);
		sDat = ndat.getFullYear().toString().substr(2,2) + ('00' + (parseInt(ndat.getMonth()) + 1)).substr(-2) + ('00' + ndat.getDate()).substr(-2);
    console.log(sDat);

    console.log("test");


/*    console.log(ndat.getMonth());
    console.log((parseInt(ndat.getMonth())));
    console.log((parseInt(ndat.getMonth()) + 1));
    console.log(('00' + (parseInt(ndat.getMonth()) + 1)));
*/

  function doPdf() {
/*
alert(common.getPdfUrl());
  window.open( common.getPdfUrl() + "603383526dd30", "入庫リスト" );
return false;
*/
    let fileName = "外注先マスタ.pdf";
    let irep = "ITEST";
    $.ajax({
      type: "GET",
      url: "../../api/getWseq.php",
      data: { "method": "GetWseqMjan" },
      dataType: "json",
      scriptCharset: 'utf-8',
      success: function(data, status, xhr) {
        let d = {
          PRGID: "AF999I",
          TABLE: irep,
          WSEQ: data.data,
          KTKTCD:"{$_SYSTEM_NAME_EN_LGKTKTCD}",
          VEND:"",
          CHGCD:"{$_SYSTEM_NAME_EN_CHGCD}",
          INI:"1",
          DBNO:"{$_SYSTEM_NO}",
          PARAMS:{
            JOKEN1:$("#at904eCocd").val(),
            JOKEN2:$("#at904eEcd").val(),
            JOKEN3:$("#at904eSgccd").val(),
            JOKEN4:$("#at904eEgccd").val(),
          },
          fileName:fileName,
        };
        print.downloadPdf(d);
      }
    });
  }
  $(document).ready(function(){
    /* 明細 高さ 自動設定
    //===================================================================*/
    /* イベント
    //===================================================================*/
    //　F1
    $(document).on("click", ".Func1:not('.noevent')", function(e) {
      
    });
    //　F2
    $(document).on("click", ".Func2:not('.noevent')", function(e) {
    });
    //　F3
    $(document).on("click", ".Func3:not('.noevent')", function(e) {
    });
    //　F4
    $(document).on("click", ".Func4:not('.noevent')", function(e) {
    });
    //　F5
    $(document).on("click", ".Func5:not('.noevent')", function(e) {
   });
    //　F6
    $(document).on("click", ".Func6:not('.noevent')", function(e) {
    });
    //　F7
    $(document).on("click", ".Func7:not('.noevent')", function(e) {
    });
    //　F8
    $(document).on("click", ".Func8:not('.noevent')", function(e) {
      //doPdf();
      doPdf();
    });
    //　F9
    $(document).on("click", ".Func9:not('.noevent')", function(e) {
    });
    //　F10
    $(document).on("click", ".Func10:not('.noevent')", function(e) {
      $(".popup-af90m").trigger("click");
    });
    //　F11
    $(document).on("click", ".Func11:not('.noevent')", function(e) {
    });
    //　F12 メニュー/戻る
    $(document).on("click", ".Func12:not('.noevent')", function(e) {
      {if $mode eq "9"}
      open('about:blank', '_self').close();
      {else}
      $('.btn-close').trigger('click')
      {/if}
    });

    //操作可/不可ボタン
    if($("#detailTop").hasClass("noevent")){  //初期
      //$(".Func2").addClass("noevent");
      $(".Func3").addClass("noevent");
      $(".Func8").addClass("noevent");
    } else {  //表示後
      //$(".Func1").addClass("noevent");
//      $(".Func5").addClass("noevent");
    }

    //=== header ===
    $(document).on("drowHieght", function(e){
      {if $isNoData eq true}
        alert("該当データがありません。");
      {/if}
      {if $hasError eq true}
        alert("{$errorMsg}")
      {/if}
      $(document).off("drowHieght");
    });

    //MENUボタン===============================
    $(document).on("regSuccess", ".btn-reg", function(e){

      alert("登録しました");
      {if $mode eq "9"}
      open('about:blank', '_self').close();
      {else}
      location.replace("./");
      {/if}

    });

    $(document).on("click","#seikyusyo", function(e) {

      if(window.confirm("請求書サンプルを出力します")) {
        let param2 = { "method": "GetWseqMjan" };
        let irep = "AP2170I";
        //let irep = "AF2020E";
        $.ajax({
          type: "GET",
          url: "../../api/getWseq.php",
          data: param2,
          dataType: "json",
          scriptCharset: 'utf-8',
          success: function(data, status, xhr) {
            var wurl = "{$_REPORT_URL}" + "AF999I?WSEQ=" + JSON.parse(data.data)
                    + "&IREP=" + irep
                    + "&CHGCD=" + "{$_SYSTEM_NAME_EN_CHGCD}"
                    + "&KTKTCD=" + "{$_SYSTEM_NAME_EN_LGKTKTCD}"
                    + "&VEND=" + "{$_SYSTEM_NAME_EN_VEND}"
                    + "&ACCD=" + "{$_SYSTEM_NAME_EN_ACCD}"
                    + "&DBNO=" + "{$_SYSTEM_NO}"
                    + "&PDF=" +  "1"
                    + "&JOKEN2=" + "ALL";
            window.open(wurl, irep+JSON.parse(data.data));
          }
        });
      }
    });

    //=== header ===
    $dialog = $("#dialogSample2");
    $dialog.dialog({
      modal: false,
      resizable: false,
      autoOpen: false,
      open: function(event, ui) {
        $('.ui-dialog-titlebar').hide();
        $(".ui-dialog-titlebar-close", $(this).closest(".ui-dialog")).hide();
      }
    });

    $(document).on("click", "#showDialog", function(e) {
      $("#dialogSample").show();
      //$dialog.dialog('open');
      $("#dialogSample").find(".btn-yes").focus();
    });
    $(document).on("click", "#closeDialog", function(e) {
      $("#dialogSample").hide();
      //$dialog.dialog('close');
    });
    $(document).on("click", "#dialogSample .btn-yes", function(e) {
      alert("yes");
    });
    $(document).on("click", "#dialogSample .btn-no", function(e) {
      alert("no");
    });

    $(document).on("click", "#showDialog2", function(e) {
    });


    //=== body ===
		$(document).on("change", ".txt_text, .txt_number", function(e) {
			let w_item = "";
			w_item = common.getValue($(this));
			alert(w_item);
		});
    //=== footer ===

    // 初回フォーカス
    var form = $(".header").find(".area").closest("form");

    if(!(form.hasClass("noevent"))){
      $(".header").find(".area").focus();
    }else{
      var anm = $("#detail").find(".anm");
      anm.focus();
    }

  });

</script>
