<div class="footer"></div>
<?= $viewDatas['session']->getFlashdata('return_message') ? alert_CommonHelper($viewDatas['session']->getFlashdata('return_message')) : "" ?>
<script type="text/javascript">
  $(document).ready(function() {
    //class가 calender인 inputbox용,날짜field용
    $(".calender").datepicker({
      changeYear: true,
      changeMonth: true,
      yearRange: "-10:+0",
      dateFormat: "yy-mm-dd"
    });
    //id가 batchjobuids_checkbox인 버튼을 클릭시 class가 batchjobuids_checkboxs인 checkbox용
    $('#batchjobuids_checkbox').click(function(event) {
      if (this.checked) {
        $('.batchjobuids_checkboxs').each(function() { //loop checkbox
          $(this).prop('checked', true); //check
        });
      } else {
        $('.batchjobuids_checkboxs').each(function() { //loop checkbox
          $(this).prop('checked', false); //uncheck
        });
      }
    });
    //class가 select-field인 SelectBox용
    $(".select-field").select2({
      theme: "classic",
      width: 'style'
    });
    // text editor 초기화
    //참고: https://phppot.com/menu/php/learn-php/
    // class가 editor인 textarea용
    tinymce.init({
      selector: 'textarea.editor',
      plugins: ['code', 'image', 'preview', 'table', 'emoticons', 'autoresize'],
      height: 600,
      // content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:16px }'
      automatic_uploads: false,
      images_upload_url: '/tinymce_upload.php',
      // images_upload_base_path: '/upload_images',
      images_upload_handler: function(blobInfo, success, failure) {
        var xhr, formData;
        xhr = new XMLHttpRequest();
        xhr.withCredentials = false;
        xhr.open('POST', '/tinymce_upload.php');
        xhr.onload = function() {
          var json;
          if (xhr.status != 200) {
            failure('HTTP Error: ' + xhr.status);
            return;
          }
          json = JSON.parse(xhr.responseText);
          if (!json || typeof json.file_path != 'string') {
            failure('Invalid JSON: ' + xhr.responseText);
            return;
          }
          success(json.file_path);
        };
        formData = new FormData();
        formData.append('file', blobInfo.blob(), blobInfo.filename());
        xhr.send(formData);
      },
    });
  });
</script>