<info-config>
  <link rel="stylesheet" href="css/S06.css">
  <link rel="stylesheet" href="css/common.css" type="text/css" />
  <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
  <script src="https://rawgit.com/jquery/jquery-ui/master/ui/i18n/datepicker-ja.js"></script>
  <div class="main">
    <div class="content">
      <div class="tab-content">
        <div class="tab-child {!show_tab_2 ? 'active' : ''}" data-panel="panel_first" id="first_tab">お知らせ設定</div>
        <div if={memberType != 0} class="tab-child {show_tab_2 ? 'active' : ''}" data-panel="panel_second" id="second_tab">お知らせ</div>
      </div>
      <div class="wrap_content {!show_tab_2 ? 'active' : ''}" id="panel_first">
        <div class="page-title">
          <h2>お知らせ設定</h2>
        </div>
        <div class="form-wrapper" id="s06_search">
          <table>
            <tr>
              <td>
                <label>検索</label>
              </td>
              <td>
                <label>表示期間</label>
              </td>
              <td class="checkTd">
                <label>
                  <input type="checkbox" class="period-cls" checked="checked"> お知らせ表示中のみを表示 <br>
                  <!-- <input type="checkbox" class="inputActive" name="inputActive"> -->
                  <div class="date-div-cls" hidden="hidden">
                    <input class=" datepicker dateInput notice_start_date" type="text">
                    <span>～</span>
                    <input class=" datepicker1 dateInput notice_end_date" type="text">
                  </div>
                </label>
              </td>
              <!-- <td class="btnTd">
                <button type="reset" class="reset-btn"><i class="fa fa-refresh"></i>条件クリア</button>
                <button type="button" class="submit" id="searchNoticeInfo">検索</button>
              </td> -->
            </tr>
  
            <tr>
              <td>
                <label></label>
              </td>
              <td>
                <label>カスタマ</label>
              </td>
              <td class="checkTd">
                <label>
                  <input type="checkbox" class="cus-cls"> 全カスタマ対象 <br>
                  <div class="customer-cls div-wraper-autocompleter cust-inp-cls"><input type="text" class="customer_co_name_notice"></div>
                </label>
              </td>
            </tr>
  
            <tr>
              <td>
                <label></label>
              </td>
              <td>
                <label>販売元メーカー</label>
              </td>
              <td class="checkTd">
                <label>
                  <input type="checkbox" class="man-cls"> 全販売元メーカー対象 <br>
                  <div class="manu-class div-wraper-autocompleter manu-inp-cls"><input type="text" class="supp_co_name_notice"></div>
                </label>
              </td>
            </tr>
  
            <tr if={memberType == 0}>
              <td>
                <label></label>
              </td>
              <td>
                <label>販売店</label>
              </td>
              <td class="checkTd">
                <label>
                   <input type="checkbox" class="dealer-cls"> 全販売店対象 <br> 
                  <div class="dealer-class div-wraper-autocompleter dealer-inp-cls"><input type="text" class="to_dealer_co_name_notice"></div>
                </label>
              </td>
            </tr>
            
            <tr if={memberType == 0}>
              <td>
                <label></label>
              </td>
              <td>
                <label>発信元</label>
              </td>
              <td class="checkTd">
                <label>
                  <!-- <input type="checkbox" class="dealer-cls" checked="checked"> サグブレインのみ <br> -->
                  <div class="dealer-class-old div-wraper-autocompleter dealer-inp-cls"><input type="text" class="dealer_co_name_notice"></div>
                </label>
              </td>
            </tr>
  
            <tr>
              <td></td>
              <td></td>
              <td></td>
              <td class="btnTd">
                <button type="button" class="submit" id="searchNoticeInfo">検索</button>
                <button type="reset" class="reset-btn"><i class="fa fa-refresh"></i>条件クリア</button>
              </td>
            </tr>
  
          </table>
        </div>
        <div class="table-wrapper">
          <div class="table-head">
            <div class="sort">
              <label>並べ替え：</label>
              <select class="sorting">
                <option value="DESC">登録日の新しい順</option>
                <option value="ASC">登録日の古い順</option>
              </select>
            </div>
            <div class="btn-wrapper">
              <button id="S06-add-Open">お知らせを追加</button>
            </div>
          </div>
          <table class="blue-table">
            <thead>
              <tr>
                <th style="width:85px">登録日</th>
                <th>件名</th>
                <th>
                  <div>
                    表示開始日
                  </div>
                  <div>
                    表示終了日
                  </div>
                </th>
                <th>
                  <div>
                    説明
                  </div>
                  <div>
                    URL
                  </div>
                </th>
                <th>販売元メーカー</th>
                <th>カスタマ名</th>
                <th>
                  非通知<br>
                  カスタマ
                </th>
                <th if={memberType == 0} >販売店名</th>
                <th if={memberType == 0} >
                  非通知<br>
                  販売店
                </th>
                <th if={memberType == 0} >発信元</th>
                <th>公開<br/>ステータス</th>
                <th width="60px"></th>
              </tr>
            </thead>
            <tbody>
              <tr each="{item,index in notice_list}">
                <td>{item.createdate}</td>
                <td>{item.name}</td>
                <td class="no-break-line">
                  <div>
                    {item.notice_start_date}
                  </div>
                  <div>
                    {item.notice_end_date}
                  </div>
                </td>
                <td>
                  <div>
                    <description id="description_{index}"></description>
                  </div>
                  <div>
                    <a if={item.url} href="{item.url}" target="_blank">詳細はこちら</a>
                  </div>
                </td>
                <td>{item.supp_co_cd ? item.supp_co_name : (item.notice_type != 3 ? '全販売元メーカー開示' : '') }</td>
                <td>{item.customer_co_cd ? item.customer_co_name : (item.notice_type != 3 ? '全カスタマ開示' : '') }</td>
                <td class="center">
                  <button onclick="{openPopupListHiddenName}" if={item.hidden_customer_co_cd.length > 0} hidden_type="customer">詳細</button>
                  <span if={!item.hidden_customer_co_cd}>なし</span>
                </td>
                <td if={memberType == 0} > { item.to_dealer_co_cd == 'all' ? '全販売店開示' : item.to_dealer_comp_name } </td>
                <td class="center" if={memberType == 0} >
                  <button onclick="{openPopupListHiddenName}" if={item.hidden_dealer_co_cd.length > 0} hidden_type="dealer">詳細</button>
                  <span if={!item.hidden_dealer_co_cd}>なし</span>
                </td>
                <td if={memberType == 0} >{ item.comp_name}</td>
                <td class="center">
                  {item.is_hidden == 0 ? '公開' : ''}
                  {item.is_hidden == 1 ? '非公開' : ''}
                  {item.is_hidden == 2 ? '重点公開' : ''}
                </td>
                <td>
                  <div>
                    <button class="S06-edit-Open" onclick="{s06EditModal}">編集</button>
                  </div>
                  <div>
                    <button class="S06-delete" onclick="s06DeleteModal( {item.seq} )">削除</button>
                  </div>
                </td>
              </tr>            
            </tbody>
          </table>
          <div id="paging" class="text-center">
            <ul class="pagination" id="pagination_notice_info"></ul>
          </div>
        </div>
      </div>
      <div class="wrap_content {show_tab_2 ? 'active' : ''}" id="panel_second" if={memberType != 0}>
        <div class="page-title">
          <h2>お知らせ</h2>
        </div>
        
        <div class="sort_reference">
          <label>並べ替え：</label>
          <select id="sortCreateDate">
            <option each="{sortType in sortTypes}" value="{sortType.value}" selected="{(sortType.value == sort_value) ? 'selected' : ''}">{sortType.label}</option>
          </select>
        </div>
        
        <div class="result-wrapper">
                <div class="info-item" each={item,index in list_info}>
                  <div class="info-top">
                    <p class="imp-cls" style="color: red;" if={item.is_hidden == 2} >重要</p>
                    <h1 class="info-title">
                      <a href="{item.url}" target="_blank" style="display:{(!item.url == '' ) ? 'block' : 'none'}">{item.name}</a>
                      <span style="display:{(item.url == '' ) ? 'block' : 'none'}">{item.name}</span>
                    </h1>
                  </div>
                  <p>{item.createdate}</p>
                  <div class="info-main">
                    <p class="info-detail"></p>
                    <description id="description_{index}"></description>
                  </div>
                  <p><img src="{item.image_url}" class="image_url" style="max-width: 500px; max-height: 300px;" if={item.image_url}></p>
                </div>
              </div>
              <div id="paging_tab2" class="text-center">
                <ul class="pagination" id="pagination_notice_info_reference"></ul>
              </div>
      </div>
    </div>
  </div>
  <div class="modal-wrapper">
    <div class="o_modal" id="S06-add">
      <div class="o_modal_box">
        <div class="o_modal_head">
          <a id="S06-add-Close"><i class="fa fa-times"></i></a>
        </div>
        <div class="o_modal_body">
          <div class="o_modal_main">
            <h3 class="modal-title">お知らせ登録</h3>
            <div class="modal-form-box">
              <table>
                <tr>
                  <th>件名</th>
                  <td><input type="text" class="notice_name"></td>
                </tr>
                <tr>
                  <th>表示開始日</th>
                  <td><input type="text" class="notice_start_date datepicker"></td>
                </tr>
                <tr>
                  <th>表示終了日</th>
                  <td><input type="text" class="notice_end_date datepicker1"></td>
                </tr>
                <tr>
                  <th>説明</th>
                  <td><textarea class="notice_description"></textarea></td>
                </tr>
                <tr>
                  <th>URL</th>
                  <td><input type="text" class="url_notice"></td>
                </tr>
                <tr>
                  <th>画像</th>
                  <td>
                    <input type="file" class="image_url" id="noticeImage" accept=".png,.jpg,.jpeg,.gif">
                    <div  style="font-size: 11px;">
                      <p>3MBまでファイルをアップロード可能です</p>
                      <p>ファイルタイプ：.jpg、.jpeg、.png、.gif</p>
                    </div>
                    <img class="show-image-detail" src="" style="max-width: 500px; max-height: 300px;")>
                  </td>
                </tr>
                <tr if={ memberType == 0 }>
                  <th>お知らせ対象</th>
                  <td>
                    <select class="notice_type" name="notice_type_add">
                      <option value="1">カスタマー・販売店両方</option>
                      <option value="2">カスタマーのみ</option>
                      <option value="3">販売店のみ</option>
                    </select>
                  </td>
                </tr>
                <tr if={show_customer}>
                  <th>カスタマ名</th>
                  <td>
                    <input type="checkbox" id="custName" name="custName" checked="checked">
                    <label for="custName"> 全カスタマ対象</label><br>
                    <div class="div-wraper-autocompleter cust-inp-cls" hidden="hidden"><input type="text" class="customer_co_name_notice_add"></div>
                  </td>
                </tr>
                <tr if={show_customer}>
                  <th class="no-break-line">非通知カスタマ名</th>
                  <td>
                    <label for="hidden_customer_co_cd_checkbox">あり</label> <input type="checkbox" name="hidden_customer_co_cd_checkbox" class="hidden_customer_co_cd_checkbox" id="hidden_customer_co_cd_checkbox_add" onchange="{hiddenCustomerCoCdCheckbox}" />
                    <div class="list_hidden_customer_co_cd" if={list_hidden_customer_co_cd_select.length > 0}>
                      <select id="hidden_customer_co_cd_select" onchange="{pickHiddenCustomerCoCd}">
                        <option value="">--選択してください--</option>
                        <option each="{item,index in list_hidden_customer_co_cd_select}" value="{item.comp_code}">{item.label}</option>
                      </select>
                    </div>
                    <div class="list_hidden_customer_co_cd_selected" if={list_hidden_customer_co_cd_selected.length > 0}>
                      <ul class="item">
                        <li each={item,index in list_hidden_customer_co_cd_selected}>{item.label} <span class="item_remove" hidden_type="customer" comp_code={item.comp_code} onclick="{removeHiddenCoCd}">☓削除</span></li>
                      </ul>
                    </div>
                  </td>
                </tr>
                <tr if={show_customer}>
                  <th>販売元メーカー名</th>
                  <td>
                    <input type="checkbox" id="manuName" name="manuName" checked="checked">
                    <label for="manuName"> 全販売元メーカー対象</label><br>
                    <div class="div-wraper-autocompleter manu-inp-cls" hidden="hidden"><input type="text" class="supp_co_name_notice_add"></div>
                  </td>
                </tr>
                <tr if={memberType == 0 && show_dealer}>
                  <th>販売店名</th>
                  <td>
                    <input type="checkbox" id="toDealerName" name="dealerName" checked="checked">
                    <label for="toDealerName"> 全販売店対象</label><br>
                    <div class="div-wraper-autocompleter dealer-inp-cls" hidden="hidden"><input type="text" class="to_dealer_co_name_notice_add"></div>
                  </td>
                </tr>
                <tr if={memberType == 0 && show_dealer}>
                  <th class="no-break-line">非通知販売店名</th>
                  <td>
                    <label for="hidden_dealer_co_cd_checkbox">あり</label> <input type="checkbox" name="hidden_dealer_co_cd_checkbox" class="hidden_dealer_co_cd_checkbox" id="hidden_dealer_co_cd_checkbox_add" onchange="{hiddenDealerCoCdCheckbox}" />
                    <div class="list_hidden_dealer_co_cd" if={list_hidden_dealer_co_cd_select.length > 0}>
                      <select id="hidden_dealer_co_cd_select" onchange="{pickHiddenDealerCoCd}">
                        <option value="">--選択してください--</option>
                        <option each="{item,index in list_hidden_dealer_co_cd_select}" value="{item.comp_code}">{item.label}</option>
                      </select>
                    </div>
                    <div class="list_hidden_dealer_co_cd_selected" if={list_hidden_dealer_co_cd_selected.length > 0}>
                      <ul class="item">
                        <li each={item,index in list_hidden_dealer_co_cd_selected}>{item.label} <span class="item_remove" hidden_type="dealer" comp_code={item.comp_code} onclick="{removeHiddenCoCd}">☓削除</span></li>
                      </ul>
                    </div>
                  </td>
                </tr>
                <tr>
                  <th>ステータス</th>
                  <td>
                    <select class="is_hidden">
                      <option value="0">公開</option>
                      <option value="1">非公開</option>
                      <option value="2">重点公開</option>
                    </select>
                  </td>
                </tr>
              </table>
              <div class="btn-wrapper">
                <button type="reset" class="reset-btn"><i class="fa fa-refresh"></i>条件クリア</button>
                <button type="button" class="submit" onclick="{addNotice}">登録</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="o_modal" id="S06-edit">
      <div class="o_modal_box">
        <div class="o_modal_head">
          <a id="S06-edit-Close"><i class="fa fa-times"></i></a>
        </div>
        <div class="o_modal_body">
          <div class="o_modal_main">
            <h3 class="modal-title">お知らせ更新</h3>
            <div class="modal-form-box">
              <table>
                <input type="hidden" class="notice_seq" value="{editItem.seq}">
                <input type="hidden" class="notice_customer_co_cd" value="{editItem.customer_co_cd}">
                <input type="hidden" class="notice_supp_co_cd" value="{editItem.supp_co_cd}">
                <tr>
                  <th>件名</th>
                  <td><input type="text" class="notice_name" id="name_notice_edit" value="{editItem.name}"></td>
                </tr>
                <tr>
                  <th>開始日</th>
                  <td><input type="text" class="notice_start_date datepicker" value="{editItem.notice_start_date}"></td>
                </tr>
                <tr>
                  <th>終了日</th>
                  <td><input type="text" class="notice_end_date datepicker1" value="{editItem.notice_end_date}"></td>
                </tr>
                <tr>
                  <th>説明</th>
                  <td><textarea class="notice_description" id="description_notice_edit">{editItem.description}</textarea></td>
                </tr>
                <tr>
                  <th>URL</th>
                  <td><input type="text" class="url_notice" id="url_notice_edit" value="{editItem.url}"></td>
                </tr>
                <tr>
                  <th>画像</th>
                  <td>
                    <input type="file" class="image_url" id="noticeImageEdit" name="noticeImageEdit" accept=".png,.jpg,.jpeg,.gif">
                    <div  style="font-size: 11px;">
                      <p>3MBまでファイルをアップロード可能です</p>
                      <p>ファイルタイプ：.jpg、.jpeg、.png、.gif</p>
                    </div>
                    <img class="show-image-detail" src={editItem.image_url ? editItem.image_url : "" } style="max-width: 500px; max-height: 300px;")>
                  </td>
                </tr>
                <tr if={ memberType == 0 }>
                  <th>お知らせ対象</th>
                  <td>
                    <select name="notice_type_edit" class="notice_type" disabled>
                      <option value="1" if={editItem.notice_type == 1}>カスタマー・販売店両方</option>
                      <option value="2" if={editItem.notice_type == 2}>カスタマーのみ</option>
                      <option value="3" if={editItem.notice_type == 3}>販売店のみ</option>
                    </select>
                  </td>
                </tr>
                <tr if={show_customer_edit}>
                  <th>カスタマ名</th>
                  <td>
                    <input type="checkbox" id="editCustName" name="editCustName" checked="{ editItem.customer_co_name ? '' : 'checked' }" >
                    <label for="editCustName"> 全カスタマ対象</label><br>
                    <div class="div-wraper-autocompleter edit-cust-inp-cls" show={editItem.customer_co_name} ><input type="text" class="customer_co_name_notice customer_co_name_notice_edit" id="customer_co_name_notice_edit" value="{editItem.customer_co_name}"></div>
                  </td>
                </tr>
                <tr if={show_customer_edit}>
                  <th class="no-break-line">非通知カスタマ名</th>
                  <td>
                    <label for="hidden_customer_co_cd_checkbox">あり</label> <input type="checkbox" name="hidden_customer_co_cd_checkbox" class="hidden_customer_co_cd_checkbox" id="hidden_customer_co_cd_checkbox_edit" onchange="{hiddenCustomerCoCdCheckbox}" />
                    <div class="list_hidden_customer_co_cd" if={list_hidden_customer_co_cd_select.length > 0}>
                      <select id="hidden_customer_co_cd_select_edit" onchange="{pickHiddenCustomerCoCd}">
                        <option value="">--選択してください--</option>
                        <option each="{item,index in list_hidden_customer_co_cd_select}" value="{item.comp_code}">{item.label}</option>
                      </select>
                    </div>
                    <div class="list_hidden_customer_co_cd_selected" if={list_hidden_customer_co_cd_selected.length > 0}>
                      <ul class="item">
                        <li each={item,index in list_hidden_customer_co_cd_selected}>{item.label} <span class="item_remove" comp_code={item.comp_code} hidden_type="customer" onclick="{removeHiddenCoCd}">☓削除</span></li>
                      </ul>
                    </div>
                  </td>
                </tr>
                <tr if={show_customer_edit}>
                  <th>販売元メーカー名</th>
                  <td>
                    <input type="checkbox" id="editManuName" name="editManuName" checked="{ editItem.supp_co_name ? '' : 'checked' }">
                    <label for="editManuName"> 全販売元メーカー対象</label><br>
                    <div class="div-wraper-autocompleter edit-manu-inp-cls" show={editItem.supp_co_name}><input type="text" class="supp_co_name_notice_edit" value="{editItem.supp_co_name}"></div>
                  </td>
                </tr>
                <tr if={memberType == 0 && show_dealer_edit}>
                  <th>販売店名</th>
                  <td>
                    <input type="checkbox" id="toDealerNameEdit" name="dealerNameEdit" checked="checked">
                    <label for="toDealerNameEdit"> 全販売店対象</label><br>
                    <div class="div-wraper-autocompleter dealer-inp-cls"><input type="text" class="to_dealer_co_name_notice_edit"></div>
                  </td>
                </tr>
                <tr if={memberType == 0 && show_dealer_edit}>
                  <th class="no-break-line">非通知販売店名</th>
                  <td>
                    <label for="hidden_dealer_co_cd_checkbox">あり</label> <input type="checkbox" name="hidden_dealer_co_cd_checkbox" class="hidden_dealer_co_cd_checkbox" id="hidden_dealer_co_cd_checkbox_edit" onchange="{hiddenDealerCoCdCheckbox}" />
                    <div class="list_hidden_dealer_co_cd" if={list_hidden_dealer_co_cd_select.length > 0}>
                      <select id="hidden_dealer_co_cd_select_list" onchange="{pickHiddenDealerCoCd}">
                        <option value="">--選択してください--</option>
                        <option each="{item,index in list_hidden_dealer_co_cd_select}" value="{item.comp_code}">{item.label}</option>
                      </select>
                    </div>
                    <div class="list_hidden_dealer_co_cd_selected" if={list_hidden_dealer_co_cd_selected.length > 0}>
                      <ul class="item">
                        <li each={item,index in list_hidden_dealer_co_cd_selected}>{item.label} <span class="item_remove" hidden_type="dealer" comp_code={item.comp_code} onclick="{removeHiddenCoCd}">☓削除</span></li>
                      </ul>
                    </div>
                  </td>
                </tr>
                <tr>
                  <th>ステータス</th>
                  <td>
                    <select class="is_hidden">
                      <option value="0" selected="{(editItem.is_hidden == 0) ? 'selected':''}">公開</option>
                      <option value="1" selected="{(editItem.is_hidden == 1) ? 'selected':''}">非公開</option>
                      <option value="2" selected="{(editItem.is_hidden == 2) ? 'selected':''}">重点公開</option>
                    </select>
                  </td>
                </tr>
              </table>
              <div class="btn-wrapper">
                <button type="reset" class="reset-btn" onclick="{resetS06Edit}"><i class="fa fa-times"></i>キャンセル</button>
                <button type="button" class="submit" onclick="{editNotice}">更新</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="o_modal" id="popup-hidden-list">
          <div class="o_modal_box">
            <div class="o_modal_head">
              <a id="popup-hidden-list-close"><i class="fa fa-times"></i></a>
            </div>
            <div class="o_modal_body">
              <div class="o_modal_main">
                <h3 class="modal-title">
                  非通知{hidden_type == 'customer' ? 'カスタマ名' : '販売店名'}
                </h3>
                <div class="modal-form-box">
                  <table>
                    <thead>
                    <tr>
                      <th class="no-th">No.</th>
                      <th>法人名</th>
                    </tr>
                    </thead>
                    <tbody>
                      <tr each={item,index in list_hidden_co_cd_popup}>
                        <td class="center">{index + 1}</td>
                        <td>{item.comp_name}</td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
          </div>
        </div>
  </div>
  <script>
    /* global $ */
    this.IWAI_SITE = IWAI_SITE;
    this.show_tab_2 = opts.show_tab_2;
    this.notice_list = opts.notice_list;
    this.list_comp_name = opts.list_comp_name;
    this.list_dealer_comp_name = opts.list_dealer_comp_name;
    this.all_dealer_comp_name_list = opts.all_dealer_comp_name_list;
    this.customer_co_cd = '';
    this.supp_co_cd = '';
    this.to_dealer_co_cd = '';
    this.dealer_co_cd = '';
    this.customer_co_cd_add = '';
    this.supp_co_cd_add = '';
    this.to_dealer_co_cd_add = '';
    this.customer_co_cd_edit = '';
    this.supp_co_cd_edit = '';
    this.to_dealer_co_cd_edit = '';
    this.total = opts.total;
    this.noticeInfo = [];
    this.currentPage = 1;
    this.currentPageReference = 1;
    this.editItem = [];
    this.sort_field = 'createdate';
    this.sort_value = 'DESC';
    this.sort_value_reference = 'DESC';
    this.total_page = 0;
    this.hidden_type = '';
    this.list_hidden_co_cd_popup = [];
    this.list_hidden_customer_co_cd_select = [];
    this.list_hidden_customer_co_cd_selected = [];
    this.list_hidden_dealer_co_cd_select = [];
    this.list_hidden_dealer_co_cd_selected = [];
    this.list_hidden_dealer_co_cd_selected = [];
    this.show_dealer = 1;
    this.show_customer = 1;
    this.show_dealer_edit = 1;
    this.show_customer_edit = 1;
    this.sortTypes = [{label:'登録日の新しい順', value: 'DESC'},{label:'登録日の古い順', value: 'ASC'}]
    
    // notice type
    const BOTH_CUSTOMER_DEALER = 1;
    const ONLY_CUSTOMER = 2;
    const ONLY_DEALER = 3;
    thisTag = this;


    const HIDDEN_CUSTOMER = 'customer';
    const HIDDEN_DEALER = 'dealer';
    var user_info = JSON.parse(localStorage.getItem('EcUserInfo'));
    this.memberType = user_info.member_type;
    thisTag.update({ memberType : this.memberType });


    $(function(){
        $('#second_tab').on('click', function () {
          var page = 1;
          window.history.replaceState({},'',  '#s06?tab=2');
          thisTag.getNoticeReference(page);
        });
        $('.tab-child').on('click',function(){
          if(!$(this).hasClass('active')){
            $('.tab-child').removeClass('active');
            $(this).addClass('active');
            var panel = $(this).attr('data-panel');
            $('.wrap_content').removeClass('active');
            $('#' + panel).addClass('active');
          }
        })
        /* tab & panel */
        $('.tab').on('click',function(){
          if(!$(this).hasClass('active')){
            /*tab*/
            $('.tab').removeClass('active');
            $(this).addClass('active');
            /*panel*/
            var panel = $(this).attr('data-panel');
            $('.panel').removeClass('active');
            $('#' + panel).addClass('active');
          }
        });
        $('#popup-hidden-list-close').on('click',function(){
          $('#popup-hidden-list').fadeOut();
          thisTag.list_hidden_co_cd_popup = [];
          thisTag.update(thisTag.list_hidden_co_cd_popup);
        });
      
      $("#noticeImage").change(function () {
          if (this.files && this.files[0]) {
              var reader = new FileReader();
              reader.onload = function (e) {
                $("#noticeImage").nextAll('.show-image-detail:first').attr('src', e.target.result);
              }
              reader.readAsDataURL(this.files[0]);
          } else $("#noticeImage").nextAll('.show-image-detail:first').attr('src', '');
      });
      $("#noticeImageEdit").change(function () {
          if (this.files && this.files[0]) {
              var reader = new FileReader();
              reader.onload = function (e) {
                $("#noticeImageEdit").nextAll('.show-image-detail:first').attr('src', e.target.result);
              }
              reader.readAsDataURL(this.files[0]);
          } else $("#noticeImageEdit").nextAll('.show-image-detail:first').attr('src', '');
      });
      
      $('#S06-add .notice_type').on('change',function(){
        thisTag.show_dealer = $(this).val() == ONLY_CUSTOMER ? '' : 1;
        thisTag.show_customer = $(this).val() == ONLY_DEALER ? '' : 1;
        thisTag.update(thisTag.show_customer);
        thisTag.update(thisTag.show_dealer);
      });
      if (thisTag.show_tab_2) {
          thisTag.list_info = thisTag.notice_list;
          var totalPages = Math.ceil(thisTag.total/LIMIT_ON_PAGE);
          var visiblePages = 1;
          if(totalPages != 0){
              visiblePages =  5;
          } 
          var $pagination = $('#pagination_notice_info_reference');
          $pagination.twbsPagination('destroy');
          $pagination.twbsPagination({
              totalPages: totalPages,
              visiblePages: visiblePages,
              startPage: thisTag.currentPageReference,
              initiateStartPageClick: false,
              onPageClick: function (event, page) {
                thisTag.currentPageReference = page;
                thisTag.getNoticeReference(page);
              }
          });
          thisTag.update(thisTag.list_info);
          $.each(thisTag.list_info,function(i,e){
              riot.tag('description', '', function(opts) {   
                  this.root.innerHTML = opts.r;
              });
              riot.mount('#description_' + i, {
                  r: e.description
              })
              thisTag.update();
          });
          $('#sortCreateDate').change(function(){
              thisTag.sort_value_reference = thisTag.sort_value_reference == 'DESC'? 'ASC': 'DESC';
              var page = thisTag.currentPageReference;
              thisTag.getNoticeReference(page);
          })
        } else {
          $.each(thisTag.notice_list,function(i,e){
            riot.tag('description', '', function(opts) {
              this.root.innerHTML = opts.r;
            });
            riot.mount('#description_' + i, {
              r: e.description
            })
            thisTag.update();
          });
          var totalPages = Math.ceil(thisTag.total/LIMIT_ON_PAGE);
          thisTag.total_page = totalPages;
          var visiblePages = 1;
          if(totalPages != 0){
            visiblePages =  5;
          }
          var $pagination = $('#pagination_notice_info');
          $pagination.twbsPagination('destroy');
          $pagination.twbsPagination({
            totalPages: totalPages,
            visiblePages: visiblePages,
            startPage: thisTag.currentPage,
            initiateStartPageClick: false,
            onPageClick: function (event, page) {
              searchNoticeInfo(page);
            }
          });
        }

        $('input[name=inputActive]').on('click',function(){
            if($(this).is(':checked')){
                $('.dateInput').prop('disabled',false);
            }else{
                $('.dateInput').prop('disabled',true);
                $('.dateInput').val('');
            }
        });
        
        /*S06-add*/
        $('#S06-add-Open').on('click',function(){
            $('#S06-add').fadeIn();
            $('#S06-add .notice_start_date').val('');
            $('#S06-add .notice_end_date').val('');
            $('#S06-add .notice_description').val('');
            $('#S06-add .url_notice').val('');
            $('#S06-add .notice_name').val('');
            $('#S06-add .is_hidden').val(0);
            $('#S06-add .notice_classification').val(null);
            $('#S06-add .image_url').val('');
            $('#S06-add .supp_co_name_notice').val('');
            $('#S06-add .customer_co_name_notice').val('');
            s06AddModal();
        });
        $('#S06-add-Close').on('click',function(){
            $('#S06-add').fadeOut();
        });

        /*S06-edit*/
        $('#S06-edit-Close').on('click',function(){
          thisTag.update({
              customer_co_cd_edit: '',
              supp_co_cd_edit: '',
              to_dealer_co_cd_edit: ''
          });
            $('#S06-edit').fadeOut();
        });

        $('#searchNoticeInfo, #first_tab').click(function(){
            var page = 1;
            thisTag.sort_field = 'createdate';
            thisTag.sort_value = 'DESC';
            window.history.replaceState({},'',  '#s06?tab=1');
            searchNoticeInfo(page);
        });


        /*$('#s06_search .notice_start_date').datetimepicker({
            format: 'Y-m-d',
            onShow:function( ct ){
                this.setOptions({
                    maxDate:$('#s06_search .notice_end_date').val()?$('#s06_search .notice_end_date').val():false
                })
            },
        
            timepicker:false
        });
        
        $('#s06_search .notice_end_date').datetimepicker({
            format: 'Y-m-d', //Y-m-d H:i:s
            onShow:function( ct ){
                this.setOptions({
                    minDate:$('#s06_search .notice_start_date').val()?$('#s06_search .notice_start_date').val():false
                })
            },
        
            timepicker:false
        });
        
        $('#S06-add .notice_start_date').datetimepicker({
            format: 'Y-m-d',
            onShow:function( ct ){
                this.setOptions({
                maxDate:$('#S06-add .notice_end_date').val()?$('#S06-add .notice_end_date').val():false
                })
            },
            timepicker:false
        });

        $('#S06-add .notice_end_date').datetimepicker({
            format: 'Y-m-d',
            onShow:function( ct ){
                this.setOptions({
                    minDate:$('#S06-add .notice_start_date').val()?$('#S06-add .notice_start_date').val():false
                })
            },

            timepicker:false
        });
       
        $('#S06-edit .notice_start_date').datetimepicker({
            format: 'Y-m-d',
            onShow:function( ct ){
                this.setOptions({
                    maxDate:$('#S06-edit .notice_end_date').val()?$('#S06-edit .notice_end_date').val():false
                })
            },
        
            timepicker:false
        });
        $('#S06-edit .notice_end_date').datetimepicker({
            format: 'Y-m-d',
            onShow:function( ct ){
                this.setOptions({
                    minDate:$('#S06-edit .notice_start_date').val()?$('#S06-edit .notice_start_date').val():false
                })
            },
            
            timepicker:false
        });*/

        $('#s06_search .reset-btn').click(function(){
            
            $('#s06_search .period-cls').prop('checked', true);
            $('#s06_search .date-div-cls').hide();
            $('#s06_search .notice_start_date').val('');
            $('#s06_search .notice_end_date').val('');

            $('#s06_search .cus-cls').prop('checked', false);
            $('#s06_search .customer_co_name_notice').val('');

            $('#s06_search .man-cls').prop('checked', false);
            $('#s06_search .supp_co_name_notice').val('');

            $('#s06_search .dealer-cls').prop('checked', false);
            $('#s06_search .to_dealer_co_name_notice').val('');

            $('#s06_search .dealer_co_name_notice').val('');
            thisTag.customer_co_cd = '';
            thisTag.to_dealer_co_cd = '';
            thisTag.supp_co_cd = '';
            thisTag.setSearchDealer();
        });

        $('#S06-add .reset-btn').click(function(){
            $('#S06-add .notice_start_date').val('');
            $('#S06-add .notice_end_date').val('');
            $('#S06-add .image_url').val('');
            $('#S06-add .notice_description').val('');
            $('#S06-add .url_notice').val('');
            $('#S06-add .notice_name').val('');
            $('#S06-add .is_hidden').val(0);
            $('#S06-add .notice_classification').val(null);
            $('#S06-add .image_url').val('');
            $('#S06-add .customer_co_name_notice').val('');
            $('#S06-add .cust-inp-cls').hide();
            $('#S06-add #custName').prop('checked', true);
            $('#S06-add #hidden_customer_co_cd_checkbox_add').prop('checked', false);
            $('#S06-add #hidden_customer_co_cd_checkbox_add').prop('disabled', false);
            $('#S06-add .supp_co_name_notice').val('');
            $('#S06-add .manu-inp-cls').hide();
            $('#S06-add #manuName').prop('checked', true);
            $('#S06-add .to_dealer_co_name_notice').val('');
            $('#S06-add .supp_co_name_notice_add').val('');
            $('#S06-add .customer_co_name_notice_add').val('');
            $('#S06-add .to_dealer_co_name_notice_add').val('');
            $('#S06-add .dealer-inp-cls').hide();
            $('#S06-add #toDealerName').prop('checked', true);
            $('#S06-add #hidden_dealer_co_cd_checkbox_add').prop('checked', false);
            $('#S06-add #hidden_dealer_co_cd_checkbox_add').prop('disabled', false);
            $("#S06-add .notice_type option:first").attr('selected','selected');
            $("#noticeImage").val('');
            $("#noticeImage").nextAll('.show-image-detail:first').attr('src', '');
            thisTag.update({
                customer_co_cd_add:'',
                supp_co_cd_add: '',
                to_dealer_co_cd_add: '',
                show_dealer: 1,
                show_customer: 1,
            });
            thisTag.resetAllHiddenSelect(HIDDEN_CUSTOMER);
            thisTag.resetAllHiddenSelect(HIDDEN_DEALER);
        });

        // $('#S06-edit .reset-btn').click(function(){
        //     $('#S06-edit .notice_start_date').val('');
        //     $('#S06-edit .notice_end_date').val('');
        //     $('#S06-edit .notice_description').val('');
        //     $('#S06-edit .url_notice').val('');
        //     $('#S06-edit .notice_name').val('');
        //     $('#S06-edit .is_hidden').val(0);
        //     $('#S06-edit .notice_classification').val(null);
        //     $('#S06-edit .image_url').val('');
        // });
        // var cnt = 0;
        $('.sorting').change(function(e){
            // cnt++;
            // if(cnt%2==0){
            //         $('.sorting').removeClass('sorting_asc');
            //         $(this).addClass('sorting_desc');
            //         $(this).attr('sort_value','DESC');
            // }else{
            //         $('.sorting').removeClass('sorting_desc');
            //         $(this).addClass('sorting_asc');
            //         $(this).attr('sort_value','ASC');
            // }
//                sortData(that);

            var sort_field = 'createdate';
            var sort_value = $(this).val();

            thisTag.sort_field = sort_field;
            thisTag.sort_value = sort_value;
            var page = 1;
            searchNoticeInfo(page);
        });

        $("#manuName").change(function() {
            
            this.checked ? $('#S06-add .manu-inp-cls').hide() : $('#S06-add .manu-inp-cls').show();
    
        });

        $("#editManuName").change(function() {
            
            this.checked ? $('.edit-manu-inp-cls').hide() : $('.edit-manu-inp-cls').show();
    
        });

      $("#toDealerName").change(function() {
          if (this.checked) {
            $('#S06-add .dealer-inp-cls').hide();
            $('#hidden_dealer_co_cd_checkbox_add').prop("disabled", false);
          } else {
            $('#S06-add .dealer-inp-cls').show();
            $('#hidden_dealer_co_cd_checkbox_add').prop("checked", false);
            $('#hidden_dealer_co_cd_checkbox_add').prop("disabled", true);
            thisTag.resetAllHiddenSelect(HIDDEN_DEALER);
          }
      });

      $("#toDealerNameEdit").change(function() {
          if (this.checked) {
            $('#S06-edit .dealer-inp-cls').hide();
            $('#hidden_dealer_co_cd_checkbox_edit').prop("disabled", false);
          } else {
            $('#S06-edit .dealer-inp-cls').show();
            $('#hidden_dealer_co_cd_checkbox_edit').prop("checked", false);
            $('#hidden_dealer_co_cd_checkbox_edit').prop("disabled", true);
            thisTag.resetAllHiddenSelect(HIDDEN_DEALER);
          }
      });

      $("#editManuName").change(function() {

          this.checked ? $('.edit-dealer-inp-cls').hide() : $('.edit-dealer-inp-cls').show();

      });

        $("#custName").change(function() {
          if (this.checked) {
            $('#S06-add .cust-inp-cls').hide();
            $('#hidden_customer_co_cd_checkbox_add').prop("disabled", false);
          } else {
            $('#S06-add .cust-inp-cls').show();
            $('#hidden_customer_co_cd_checkbox_add').prop("checked", false);            
            $('#hidden_customer_co_cd_checkbox_add').prop("disabled", true);
            thisTag.resetAllHiddenSelect(HIDDEN_CUSTOMER);
          }
    
        });

        $("#editCustName").change(function() {
          if (this.checked) {
            $('.edit-cust-inp-cls').hide();
            $('#hidden_customer_co_cd_checkbox_edit').prop("disabled", false);
          } else {
            $('.edit-cust-inp-cls').show();
            $('#hidden_customer_co_cd_checkbox_edit').prop("checked", false);
            $('#hidden_customer_co_cd_checkbox_edit').prop("disabled", true);
            thisTag.resetAllHiddenSelect(HIDDEN_CUSTOMER);
          }
    
        });

        $(".period-cls").change(function() {
            
            this.checked ? $('.date-div-cls').hide() : $('.date-div-cls').show();
            $('#s06_search .notice_start_date').val('');
            $('#s06_search .notice_end_date').val('');
    
        });

        $(".cus-cls").change(function() {
            
            if ( this.checked ) {
              thisTag.customer_co_cd = ''; 
              $('#s06_search .customer_co_name_notice').val('');
              $('.customer-cls').hide();
            }
            else { $('.customer-cls').show(); }
    
        });

        $(".man-cls").change(function() {
            
            if ( this.checked ) {
              thisTag.supp_co_cd = '';
              $('#s06_search .supp_co_name_notice').val('');
              $('.manu-class').hide();
            }
            else { $('.manu-class').show(); }
    
        });

        $(".dealer-cls").change(function() {
            
            if ( this.checked ) {
              thisTag.to_dealer_co_cd = '';
              $('#s06_search .to_dealer_co_name_notice').val('');
              $('.dealer-class').hide();
            }
            else { $('.dealer-class').show(); }

    
        });

        // autocomplete for search
        $('.customer_co_name_notice').autocompleter({ limit:10000,highlightMatches:true, source: thisTag.list_dealer_comp_name });
        $('.customer_co_name_notice').on('change',function(e){
            var value = $(this).val();
            if(value == ''){
                thisTag.customer_co_cd = '';
                return false;
            }
            $.each(thisTag.list_dealer_comp_name, function(k,v){
            if(v['value'].indexOf(value) !== -1){
              thisTag.customer_co_cd = v['comp_code'];
              return false;
            }
          });
        });

        $('.supp_co_name_notice').autocompleter({ limit:10000,highlightMatches:true, source: thisTag.list_comp_name });
        $('.supp_co_name_notice').on('change',function(e){
            var value = $(this).val();
            if(value == ''){
                thisTag.supp_co_cd = '';
                return false;
            }
            $.each(thisTag.list_comp_name, function(k,v){
              if(v['value'].indexOf(value) !== -1){
                thisTag.supp_co_cd = v['comp_code'];
                return false;
              }
            });
        });

        $('.to_dealer_co_name_notice').autocompleter({ limit:10000,highlightMatches:true, source: thisTag.all_dealer_comp_name_list });
        $('.to_dealer_co_name_notice').on('change',function(e){
          var value = $(this).val();
          if(value == ''){
              thisTag.to_dealer_co_cd = '';
              return false;
          }
          $.each(thisTag.all_dealer_comp_name_list, function(k,v){
            if(v['value'].indexOf(value) !== -1){
              thisTag.to_dealer_co_cd = v['comp_code'];
              return false;
            }
          });

        });

        $('.dealer_co_name_notice').autocompleter({ limit:10000,highlightMatches:true, source: thisTag.all_dealer_comp_name_list });
        $('.dealer_co_name_notice').on('change',function(e){
          var value = $(this).val();
          if(value == ''){
              thisTag.dealer_co_cd = '';
              return false;
          }
          $.each(thisTag.all_dealer_comp_name_list, function(k,v){
            if(v['value'].indexOf(value) !== -1){
              thisTag.dealer_co_cd = v['comp_code'];
              return false;
            }
          });

        });

        // autocomplete for add/edit
      $('.customer_co_name_notice_add').autocompleter({ limit:10000,highlightMatches:true, source: thisTag.list_dealer_comp_name });
      $('.customer_co_name_notice_add').on('change',function(e){
          var value = $(this).val();
          if(value == ''){
              thisTag.customer_co_cd_add = '';
              return false;
          }
          $.each(thisTag.list_dealer_comp_name, function(k,v){
          if(v['value'].indexOf(value) !== -1){
            thisTag.customer_co_cd_add = v['comp_code'];
            return false;
          }
        });
      });

      $('.supp_co_name_notice_add').autocompleter({ limit:10000,highlightMatches:true, source: thisTag.list_comp_name });
      $('.supp_co_name_notice_add').on('change',function(e){
          var value = $(this).val();
          if(value == ''){
              thisTag.supp_co_cd_add = '';
              return false;
          }
          $.each(thisTag.list_comp_name, function(k,v){
            if(v['value'].indexOf(value) !== -1){
              thisTag.supp_co_cd_add = v['comp_code'];
              return false;
            }
          });
      });

      $('.to_dealer_co_name_notice_add').autocompleter({ limit:10000,highlightMatches:true, source: thisTag.all_dealer_comp_name_list });
      $('.to_dealer_co_name_notice_add').on('change',function(e){
        var value = $(this).val();
        if(value == ''){
            thisTag.to_dealer_co_cd_add = '';
            return false;
        }
        $.each(thisTag.all_dealer_comp_name_list, function(k,v){
          if(v['value'].indexOf(value) !== -1){
            thisTag.to_dealer_co_cd_add = v['comp_code'];
            return false;
          }
        });
      });
      
      thisTag.setSearchDealer();

        this.s06DeleteModal = function( seq ) {

          var confirm = window.confirm('削除します。よろしいですか。');
          if( confirm ) {

            var query = [];
            var accessTokenCognito = localStorage.getItem('accessTokenCognito');
            query.push('token=' + accessTokenCognito);
            var url = URL_API + '/api/notice/delete';

            url += '?' + query.join('&');
            
            var data = [];
            data.push({
                seq: seq
            });

           $.ajax({
                url: url,
                type: 'POST',
                timeout: 60000,
                data: {
                    seq: seq
                },
                success: function (res) {
                  
                    if(res.status == 100){
                        riot.mount('app','maintain',{ messege:res.messege });
                        return false;
                    }
                    if(res.status == 'not_authorize'){
                        var url = "#";
                        $(location).attr("href", url );
                        return false;
                    }
                    if(res.message == 'success'){
                        alert('削除しました。');
                        searchNoticeInfo(thisTag.currentPage);
                    }
                },
                error: function (xhr, stt, err) {
                    alert('error');
                }
            }); 

          } 

        }

    });
    this.resetS06Edit = function(e){
        var editItem = thisTag.editItem;
        thisTag.editItem = [];
        thisTag.update(thisTag.editItem);
        thisTag.editItem = editItem;
        thisTag.update(thisTag.editItem);

        if(thisTag.editItem['description'] == '' || thisTag.editItem['description'] == null){
            $("#description_notice_edit").val('');
        }
        if(thisTag.editItem['url'] == '' || thisTag.editItem['url'] == null){
            $("#url_notice_edit").val('');
        }
        if(thisTag.editItem['name'] == '' || thisTag.editItem['name'] == null){
            $("#name_notice_edit").val('');
        }
        thisTag.resetEdit(editItem);

    };
    function s06AddModal(e){
        $('#S06-add').fadeIn();
        $('#S06-add .reset-btn').trigger('click');
        $('.supp_co_name_notice').autocompleter({ limit:10000,highlightMatches:true, source: thisTag.list_comp_name });
        $('.supp_co_name_notice').on('change',function(e){
            var value = $(this).val();
            if(value == ''){
                thisTag.supp_co_cd = '';
                return false;
            }
            $.each(thisTag.list_comp_name, function(k,v){
            if(v['value'].indexOf(value) !== -1){
              thisTag.supp_co_cd = v['comp_code'];
              return false;
            }
          });
        });

        $('.customer_co_name_notice').autocompleter({ limit:10000,highlightMatches:true, source: thisTag.list_dealer_comp_name });
        $('.customer_co_name_notice').on('change',function(e){
            var value = $(this).val();
            if(value == ''){
                thisTag.customer_co_cd = '';
                return false;
            }
            $.each(thisTag.list_dealer_comp_name, function(k,v){
            if(v['value'].indexOf(value) !== -1){
              thisTag.customer_co_cd = v['comp_code'];
              return false;
            }
          });
        });
    };
    s06EditModal(e){
        $('#S06-edit').fadeIn();
        $('#img-loader').show();
        var item = e.item.item;
        
        thisTag.show_dealer_edit = item.notice_type == ONLY_CUSTOMER ? '' : 1;
        thisTag.show_customer_edit = item.notice_type == ONLY_DEALER ? '' : 1;
        thisTag.update(thisTag.show_dealer_edit);
        thisTag.update(thisTag.show_customer_edit);
        thisTag.editItem = item;

        thisTag.resetEdit(item);
        thisTag.update(thisTag.editItem);
        $('#img-loader').hide();
    };
    // function searchNoticeInfo(page){
    //     thisTag.currentPage = page;
        
    //     var notice_start_date =  $('#s06_search .notice_start_date').val();
    //     var notice_end_date =  $('#s06_search .notice_end_date').val();
        
    //     var query = [];
    //     var accessTokenCognito = localStorage.getItem('accessTokenCognito');
    //         query.push('token=' + accessTokenCognito);
    //         query.push('page='+page);
    //         query.push('sort_field='+thisTag.sort_field);
    //         query.push('sort_value='+thisTag.sort_value);
    //         query.push('limit=' +   LIMIT_ON_PAGE);
    //     var url = URL_API + '/api/get_notice_info';
        
    //     url += '?' + query.join('&');
        
    //     var data = {};
    //     var public_statuses = [0, 1];
    //     var inputActive = 0;
    //     if($('#s06_search .inputActive').prop( "checked" )){
    //        inputActive = 1;
    //     }
    //     if($('#s06_search .currently_in_progress').prop( "checked" )){
    //         notice_currently_in_progress = 1;
    //         data = {
    //             notice_currently_in_progress: (notice_currently_in_progress == '')? null: notice_currently_in_progress,
    //             is_hidden: public_statuses,
    //             inputActive: inputActive,
    //             notice_start_date: notice_start_date,
    //             notice_end_date: notice_end_date
    //         };
    //     }else{
    //         data = {
    //             is_hidden: public_statuses,
    //             inputActive: inputActive,
    //             notice_start_date: notice_start_date,
    //             notice_end_date: notice_end_date
    //         };
    //     }

    //     $.ajax({
    //         url: url,
    //         type: 'GET',
    //         timeout: 60000,
    //         data: {
    //             notice_info: data
    //         },
    //         success: function (res) {
    //             if(res.status == 100){
    //                 riot.mount('app','maintain',{ messege:res.messege });
    //                 return false;
    //             }
    //             if(res.message == 'success'){
    //                 $('.info_page').show();
    //                 var data = res;
    //                 thisTag.notice_list = data.list;
    //                 var totalPages = Math.ceil(data.total/LIMIT_ON_PAGE);
    //                     thisTag.total_page = totalPages;
    //                 var visiblePages = 1;
    //                 if(totalPages != 0){
    //                     visiblePages =  5;
    //                 } 
    //                 var $pagination = $('#pagination_notice_info');
    //                 $pagination.twbsPagination('destroy');
    //                 $pagination.twbsPagination({
    //                     totalPages: totalPages,
    //                     visiblePages: visiblePages,
    //                     startPage: thisTag.currentPage,
    //                     initiateStartPageClick: false,
    //                     onPageClick: function (event, page) {
    //                         searchNoticeInfo(page);
    //                     }
    //                 });

    //                 thisTag.update(thisTag.notice_list);

    //             }
    //         },
    //         error: function (xhr, stt, err) {
    //             alert('error');
    //         }
    //     });
    // }
    function searchNoticeInfo(page){
        thisTag.currentPage = page;
            
        var query = [];
        var checked = 'checked';
        var accessTokenCognito = localStorage.getItem('accessTokenCognito');
            query.push('token=' + accessTokenCognito);
            query.push('page='+page);
            query.push('sort_field='+thisTag.sort_field);
            query.push('sort_value='+thisTag.sort_value);
            query.push('limit=' +   LIMIT_ON_PAGE);


        var start_date = $('#s06_search .notice_start_date').val();
        var end_date = $('#s06_search .notice_end_date').val();

          if( $('.cus-cls').prop('checked') != true ) {

            if( thisTag.customer_co_cd ) {

              query.push('search_customer_co_cd='+thisTag.customer_co_cd);

            }

          } else {

            query.push('search_customer_co_cd='+checked);

          }

          if( $('.man-cls').prop('checked') != true ) {

            if( thisTag.supp_co_cd ) {

              query.push('search_supp_co_cd='+thisTag.supp_co_cd);
              
            }

          } else {

            query.push('search_supp_co_cd='+checked);

          }
          
          if (thisTag.memberType == 0) {

            if( $('.dealer-cls').prop('checked') != true ) {

              if( thisTag.to_dealer_co_cd ) {
                if (thisTag.to_dealer_co_cd != 'all') {

                  query.push('search_to_dealer_co_cd='+thisTag.to_dealer_co_cd);

                }

              }

            } else {

              query.push('search_to_dealer_co_cd='+checked);

            }
          }

          if (thisTag.memberType == 0) {

            // if( $('.dealer-cls').prop('checked') != true ) {

              if( thisTag.dealer_co_cd && $('#s06_search .dealer_co_name_notice').val().trim() ) {

                query.push('search_dealer_co_cd='+thisTag.dealer_co_cd);
                
              }

            // } 
            // else {

            //   query.push('search_dealer_co_cd='+checked);

            // }

          }

          if( $('.period-cls').prop('checked') != true) {

            if( start_date.length > 0 ) {

              query.push('search_start_date='+start_date);

            } if( end_date.length > 0 ) {

              query.push('search_end_date='+end_date);

            } 
              
          } else {

            if( start_date.length <= 0 && end_date.length <= 0 ) {

                query.push('search_start_date='+checked);
                query.push('search_end_date='+checked);
                
            }
          }

        var url = URL_API + '/api/get_notice_info';
        url += '?' + query.join('&');
        
        data = {
            // is_hidden:0,
            screen: 's06'
        };
        $.ajax({
            url: url,
            type: 'GET',
            timeout: 60000,
            data: {
                notice_info: data
            },
            success: function (res) {
                if(res.status == 100){
                    riot.mount('app','maintain',{ messege:res.messege });
                    return false;
                }
                if(res.message == 'success'){
                    $('.info_page').show();
                    var data = res;
                    thisTag.notice_list = data.list;
                  $.each(thisTag.notice_list, function(index, element){
                    if(element.hidden_customer_co_cd) {
                      thisTag.notice_list[index].hidden_customer_co_cd = thisTag.notice_list[index].hidden_customer_co_cd.split(',');
                    }
                    if(element.hidden_dealer_co_cd) {
                      thisTag.notice_list[index].hidden_dealer_co_cd = thisTag.notice_list[index].hidden_dealer_co_cd.split(',');
                    }
                  })
                    var totalPages = Math.ceil(data.total/LIMIT_ON_PAGE);
                        thisTag.total_page = totalPages;
                    var visiblePages = 1;
                    if(totalPages != 0){
                        visiblePages =  5;
                    } 
                    var $pagination = $('#pagination_notice_info');
                    $pagination.twbsPagination('destroy');
                    $pagination.twbsPagination({
                        totalPages: totalPages,
                        visiblePages: visiblePages,
                        startPage: thisTag.currentPage,
                        initiateStartPageClick: false,
                        onPageClick: function (event, page) {
                            searchNoticeInfo(page);
                        }
                    });
                    
                    thisTag.update(thisTag.notice_list);
                    $.each(thisTag.notice_list,function(i,e){
                        riot.tag('description', '', function(opts) {   
                          this.root.innerHTML = opts.r;
                        });
                        riot.mount('#description_' + i, {
                          r: e.description
                        })
                        thisTag.update();
                    });

                }
            },
            error: function (xhr, stt, err) {
                alert('error');
            }
        });
    }
    this.addNotice = function(e){
        var notice_name = $('#S06-add .notice_name').val();
        if(notice_name == ''){
            alert('件名は入力必須です。');
            return false;
        }
        if(notice_name.length > 255){
            alert('件名を255文字以内で入力してください。');
            return false;
        }
        var notice_type = ONLY_CUSTOMER;
        if (thisTag.memberType == 0) {
          notice_type = $('#S06-add .notice_type').val();
        }
        var notice_is_hidden = $('#S06-add .is_hidden').val();
        var notice_start_date =  $('#S06-add .notice_start_date').val();
        var notice_end_date =  $('#S06-add .notice_end_date').val();
        var notice_description = $('#S06-add .notice_description').val();
            notice_description = notice_description.replace(/\n/g, "<br>");
        var hidden_customer_co_cd = Array.from(thisTag.list_hidden_customer_co_cd_selected, function(element) {
          return element.comp_code;
        });
        var hidden_dealer_co_cd = Array.from(thisTag.list_hidden_dealer_co_cd_selected, function(element) {
          return element.comp_code;
        });
        
        if (notice_type != ONLY_DEALER) {

          if( $('#custName').is(":checked") ) {
  
            thisTag.customer_co_cd_add = null;
  
          } else {
            
            if( !thisTag.customer_co_cd_add ) {
  
              alert('カスタマを選択してください。');
              return false;
  
            }
  
          }
          
          if ($('#hidden_customer_co_cd_checkbox_add').is(":checked") && hidden_customer_co_cd.length == 0) {
            alert('非通知カスタマ名は入力必須です。');
            return false;
          }
          
          if( $('#manuName').is(":checked") ) {
      
            thisTag.supp_co_cd_add = null;
      
          } else {
      
            if( !thisTag.supp_co_cd_add ) {
      
              alert('販売元メーカーを選択してください。');
              return false;
      
            }
      
          }

        } else {
          thisTag.customer_co_cd_add = null;
          hidden_customer_co_cd = null;
          thisTag.supp_co_cd_add = null;
        }
        
        if (thisTag.memberType == 0) {

          if (notice_type != ONLY_CUSTOMER) {

            if( $('#toDealerName').is(":checked") ) {
              thisTag.to_dealer_co_cd_add = 'all';
            } else {
              if( !thisTag.to_dealer_co_cd_add ) {

                alert('販売店を選択してください。');
                return false;
              }
            }

            if ($('#hidden_dealer_co_cd_checkbox_add').is(":checked") && hidden_dealer_co_cd.length == 0) {
              alert('非通知販売店名は入力必須です。');
              return false
            }
          
          } else {
            hidden_dealer_co_cd = null;
            thisTag.to_dealer_co_cd_add = null;
          }
        }
        
        var url_notice = $('#S06-add .url_notice').val();
        if(url_notice.length > 255){
            alert('ページURLは255文字以内で入力してください。');
            return false;
        }

        var image_url = $("#noticeImage")[0].files[0];
        var formData = new FormData();
        formData.append('file',$("#noticeImage")[0].files[0]);

        if(!thisTag.validateExtensionUploadImage('#noticeImage')) {
          alert("ファイルタイプ：.jpg、.jpeg、.png、.gif のみアップロード可能です");
          return false;
        }
        if($("#noticeImage")[0].files.length > 0 && !thisTag.validateSizeUploadImage('#noticeImage')) {
          alert("3MBまでファイルをアップロードしてください");
          return false;
        }
        
        var notice_classification = $('#S06-add .notice_classification').val();
        
        var querySuggest = [];
        var accessTokenCognito = localStorage.getItem('accessTokenCognito');
        querySuggest.push('token=' + accessTokenCognito);
        var url = URL_API + '/api/notice/create';
        
        url += '?' + querySuggest.join('&');

        var data = [];
        data.push({
            name: notice_name,
            is_hidden: notice_is_hidden,
            notice_start_date: notice_start_date,
            notice_end_date: notice_end_date,
            description: notice_description,
            url: url_notice,
            image_url: image_url,
            notice_classification: notice_classification,
            customer_co_cd: thisTag.customer_co_cd_add,
            supp_co_cd: thisTag.supp_co_cd_add,
            hidden_customer_co_cd: hidden_customer_co_cd,
            to_dealer_co_cd: thisTag.to_dealer_co_cd_add,
            hidden_dealer_co_cd: hidden_dealer_co_cd,
            notice_type: notice_type
        });

        formData.append('notice_info', JSON.stringify(data));

        $.ajax({
            url: url,
            type: 'POST',
            timeout: 60000,
            data: formData,
            mimeType: "multipart/form-data",
            contentType: false,
            cache : false,
            processData: false,
            success: function (res) {
              res = JSON.parse(res);
              if(res.status == 100){
                  riot.mount('app','maintain',{ messege:res.messege });
                  return false;
              }
              if(res.message == 'success'){
                  alert('登録しました。');
                  $( "#S06-add-Close" ).trigger( "click" );
                  $('#S06-add .reset-btn').trigger( "click" );
                  searchNoticeInfo(thisTag.currentPage);
              }else if(res.message == 'errors'){
                  var errors = res.errors[0];
                  var msg = [];
                  for( var k in errors){
                      for(var h in errors[k]){
                          msg.push(errors[k][h]);
                      }
                  }
                  alert(msg.join("\n "));
              }
            },
            error: function (xhr, stt, err) {
                alert('error');
            }
        });
    } 


    this.editNotice = function(e){
        var seq = $('#S06-edit .notice_seq').val();
        var notice_name = $('#S06-edit .notice_name').val();
        if(notice_name == ''){
            alert('件名は入力必須です。');
            return false;
        }
        if(notice_name.length > 255){
            alert('件名を255文字以内で入力してください。');
            return false;
        }
        var notice_type = thisTag.editItem.notice_type;
        var notice_is_hidden = $('#S06-edit .is_hidden').val();
        var notice_start_date =  $('#S06-edit .notice_start_date').val();
        var notice_end_date =  $('#S06-edit .notice_end_date').val();
        var notice_description = $('#S06-edit .notice_description').val();
        var url_notice = $('#S06-edit .url_notice').val();
        var hidden_customer_co_cd = Array.from(thisTag.list_hidden_customer_co_cd_selected, function(element) {
          return element.comp_code;
        });
        var hidden_dealer_co_cd = Array.from(thisTag.list_hidden_dealer_co_cd_selected, function(element) {
          return element.comp_code;
        });
      
        if (notice_type != ONLY_DEALER) {
        
          if( $('#editCustName').is(":checked") ) {
    
            thisTag.customer_co_cd_edit = null;
    
          } else {
    
            if( !thisTag.customer_co_cd_edit ) {
    
              alert('カスタマを選択してください。');
              return false;
    
            }
    
          }

          if ($('#hidden_customer_co_cd_checkbox_edit').is(":checked") && hidden_customer_co_cd.length == 0) {
            alert('非通知カスタマ名は入力必須です。');
            return false;
          }
  
          if( $('#editManuName').is(":checked") ) {
  
            thisTag.supp_co_cd_edit = null;
  
          } else {
  
            if( !thisTag.supp_co_cd_edit ) {
  
              alert('販売元メーカーを選択してください。');
              return false;
  
            }
  
          }

        } else {
          thisTag.customer_co_cd_edit = null;
          hidden_customer_co_cd = null;
          thisTag.supp_co_cd_edit = null;
        }

        if (thisTag.memberType == 0) {
          if (notice_type != ONLY_CUSTOMER) {

            if( $('#toDealerNameEdit').is(":checked") ) {
              thisTag.to_dealer_co_cd_edit = 'all';
            } else {
              if( !thisTag.to_dealer_co_cd_edit || thisTag.to_dealer_co_cd_edit == 'all' ) {

                alert('販売店を選択してください。');
                return false;
              }
            }

            if ($('#hidden_dealer_co_cd_checkbox_edit').is(":checked") && hidden_dealer_co_cd.length == 0) {
              alert('非通知販売店名は入力必須です。');
              return false
            }

          } else {
            hidden_dealer_co_cd = null;
            thisTag.to_dealer_co_cd_edit = null;
          }
        }
        
      

        if(url_notice.length > 255){
            alert('ページURLは255文字以内で入力してください。');
            return false;
        }

        // var notice_supp_co_cd = $('#notice_customer_co_cd').val();
        // var notice_customer_co_cd = $('#notice_supp_co_cd').val();
        var image_url = $('#S06-edit .image_url').val();
        var formData = new FormData();
        if(!thisTag.validateExtensionUploadImage('#noticeImageEdit')) {
          alert("ファイルタイプ：.jpg、.jpeg、.png、.gif のみアップロード可能です");
          return false;
        }
        if($("#noticeImageEdit")[0].files.length > 0 && !thisTag.validateSizeUploadImage('#noticeImageEdit')) {
          alert("3MBまでファイルをアップロードしてください");
          return false;
        }
        formData.append('file',$("#noticeImageEdit")[0].files[0]);

        var notice_classification = $('#S06-edit .notice_classification').val();
        
        var querySuggest = [];
        var accessTokenCognito = localStorage.getItem('accessTokenCognito');
        querySuggest.push('token=' + accessTokenCognito);
        var url = URL_API + '/api/notice/put';

        url += '?' + querySuggest.join('&');

        var data = [];
        if (image_url == '') {
          data.push({
              seq: seq,
              name: notice_name,
              is_hidden: notice_is_hidden,
              notice_start_date: notice_start_date,
              notice_end_date: notice_end_date,
              description: notice_description,
              url: url_notice,
              notice_classification: notice_classification,
              customer_co_cd: thisTag.customer_co_cd_edit,
              supp_co_cd: thisTag.supp_co_cd_edit,
              hidden_customer_co_cd: hidden_customer_co_cd,
              to_dealer_co_cd: thisTag.to_dealer_co_cd_edit,
              hidden_dealer_co_cd: hidden_dealer_co_cd
          });
        } else {
          data.push({
              seq: seq,
              name: notice_name,
              is_hidden: notice_is_hidden,
              notice_start_date: notice_start_date,
              notice_end_date: notice_end_date,
              description: notice_description,
              url: url_notice,
              image_url: image_url,
              notice_classification: notice_classification,
              customer_co_cd: thisTag.customer_co_cd_edit,
              supp_co_cd: thisTag.supp_co_cd_edit,
              hidden_customer_co_cd: hidden_customer_co_cd,
              to_dealer_co_cd: thisTag.to_dealer_co_cd_edit,
              hidden_dealer_co_cd: hidden_dealer_co_cd
          });
        }

        formData.append('notice_info', JSON.stringify(data));

        $.ajax({
            url: url,
            type: 'POST',
            timeout: 60000,
            data: formData,
            mimeType: "multipart/form-data",
            contentType: false,
            cache : false,
            processData: false,
            success: function (res) {
              res = JSON.parse(res);
              if(res.status == 100){
                  riot.mount('app','maintain',{ messege:res.messege });
                  return false;
              }
              if(res.message == 'success'){
                  alert('更新しました。');
                  $( "#S06-edit-Close" ).trigger( "click" );
                  searchNoticeInfo(thisTag.currentPage);
              }else if(res.message == 'errors'){
                  var errors = res.errors[0];
                  var msg = [];
                  for( var k in errors){
                      for(var h in errors[k]){
                          msg.push(errors[k][h]);
                      }
                  }
                  alert(msg.join("\n "));
              }
            },
            error: function (xhr, stt, err) {
                alert('error');
            }
        });
        
    }

    this.validateExtensionUploadImage = function(className) {
      // validate extension
      var extension = $(className).val().replace(/^.*\./, '');
      if (extension == $(className).val()) {
          extension = '';
      } else {
          extension = extension.toLowerCase();
      }

      if($.inArray(extension, ['jpeg', 'jpg', 'png', 'gif', '']) == -1) {
        return false;
      }
      return true;
    }
    this.validateSizeUploadImage = function(className) {
      if(!className) {
        return false;
      }
      var size = $(className)[0].files[0].size;
      if(size > 3145728) {
        return false;
      }
      return true;
    }
    
    this.openPopupListHiddenName = function (e) {
      var index = e.item.index;
      var hidden_type = e.target.attributes.hidden_type.value;
      if (hidden_type == HIDDEN_CUSTOMER) {
        var hidden_list = this.notice_list[index].hidden_customer_co_cd;
      } else {
        var hidden_list = this.notice_list[index].hidden_dealer_co_cd;
      }
      var query = [];
      var accessTokenCognito = localStorage.getItem('accessTokenCognito');
      query.push('token=' + accessTokenCognito);
      // query.push('hidden_type=' + hidden_type);
      thisTag.hidden_type = hidden_type;
      thisTag.update(thisTag.hidden_type);

      var url = URL_API + '/api/s06/getCompNameHiddenNameS06';
      
      url += '?' + query.join('&');

      $.ajax({
        url: url,
        method: 'GET',
        timeout: 60000,
        data: {
          comp_code: hidden_list
        },
        success: function(res) {
          thisTag.list_hidden_co_cd_popup = res.name_list;
          thisTag.update(thisTag.list_hidden_co_cd_popup);
          $('#popup-hidden-list').fadeIn();
        },
        error: function(err) {

        }
      });
    }

    this.resetAllHiddenSelect = function(hidden_type) {
        if (hidden_type == HIDDEN_CUSTOMER) {
          $(".hidden_customer_co_cd_checkbox").prop("checked", false);
          thisTag.list_hidden_customer_co_cd_select = [];
          thisTag.list_hidden_customer_co_cd_selected = [];
          thisTag.update(thisTag.list_hidden_customer_co_cd_select);
          thisTag.update(thisTag.list_hidden_customer_co_cd_selected)
        } else {         
          $(".hidden_dealer_co_cd_checkbox").prop("checked", false);
          thisTag.list_hidden_dealer_co_cd_select = [];
          thisTag.list_hidden_dealer_co_cd_selected = [];
          thisTag.update(thisTag.list_hidden_dealer_co_cd_select);
          thisTag.update(thisTag.list_hidden_dealer_co_cd_selected);
        }
    }
    
    this.hiddenCustomerCoCdCheckbox = function(e) {
      if($(e.target).is(":checked")){
        var modal = $(e.target).parents('.o_modal');
        if (modal.attr('id') == 'S06-add') {
          thisTag.getCompanies(HIDDEN_CUSTOMER,'add','');
        } else {
          thisTag.getCompanies(HIDDEN_CUSTOMER,'edit','');
        }
      } else {
         thisTag.resetAllHiddenSelect(HIDDEN_CUSTOMER);
      }
    }
    
    this.hiddenDealerCoCdCheckbox = function(e) {
      if($(e.target).is(":checked")){
        var modal = $(e.target).parents('.o_modal');
        if (modal.attr('id') == 'S06-add') {
          thisTag.getCompanies(HIDDEN_DEALER,'add','');
        } else {
          thisTag.getCompanies(HIDDEN_DEALER,'edit','');
        }
      } else {
        thisTag.resetAllHiddenSelect(HIDDEN_DEALER);
      }
    }
    
    this.getCompanies = function(hidden_type, action, hidden_co_cd) {
      if (hidden_type == HIDDEN_CUSTOMER) {
        thisTag.list_hidden_customer_co_cd_select = thisTag.list_dealer_comp_name;
        thisTag.update(thisTag.list_hidden_customer_co_cd_select);
      } else {
        thisTag.list_hidden_dealer_co_cd_select = thisTag.all_dealer_comp_name_list;
        thisTag.update(thisTag.list_hidden_dealer_co_cd_select);
      }
      if (hidden_co_cd && action == 'edit') {
        thisTag.checkedOldValueEdit(hidden_co_cd, hidden_type);
      }

    }
    
    this.pickHiddenDealerCoCd = function(e) {
      var comp_code = $(e.target).children("option:selected").val();
      var comp_name = $(e.target).children("option:selected").text();
      var selected = {comp_code: comp_code, label: comp_name};

      if(!comp_code || !comp_name) {
        return false;
      }

      if(thisTag.list_hidden_dealer_co_cd_selected.length > 0) {
        if(!thisTag.checkHiddenDealerCoCdSelectedExist(selected, HIDDEN_DEALER)) {
          return false;
        }

        thisTag.list_hidden_dealer_co_cd_selected.push(selected);
        thisTag.update(thisTag.list_hidden_dealer_co_cd_selected);
      } else {
        thisTag.list_hidden_dealer_co_cd_selected.push(selected);
        thisTag.update(thisTag.list_hidden_dealer_co_cd_selected);
      }
    }
    
    this.pickHiddenCustomerCoCd = function (e) {
      var comp_code = $(e.target).children("option:selected").val();
      var comp_name = $(e.target).children("option:selected").text();
      var selected = {comp_code: comp_code, label: comp_name};

      if(!comp_code || !comp_name) {
        return false;
      }

      if(thisTag.list_hidden_customer_co_cd_selected.length > 0) {
        if(!thisTag.checkHiddenDealerCoCdSelectedExist(selected, HIDDEN_CUSTOMER)) {
          return false;
        }

        thisTag.list_hidden_customer_co_cd_selected.push(selected);
        thisTag.update(thisTag.list_hidden_customer_co_cd_selected);
      } else {
        thisTag.list_hidden_customer_co_cd_selected.push(selected);
        thisTag.update(thisTag.list_hidden_customer_co_cd_selected);
      }
    }
    
    this.checkHiddenDealerCoCdSelectedExist = function(selected, hidden_type) {
      if (hidden_type == HIDDEN_CUSTOMER) {
        for (var i = thisTag.list_hidden_customer_co_cd_selected.length - 1; i >= 0; i--) {
          if(thisTag.list_hidden_customer_co_cd_selected[i].comp_code == selected.comp_code) {
            return false;
          }
        }
      } else {
        for (var i = thisTag.list_hidden_dealer_co_cd_selected.length - 1; i >= 0; i--) {
          if(thisTag.list_hidden_dealer_co_cd_selected[i].comp_code == selected.comp_code) {
            return false;
          }
        }
      }
      return true;
    }
    
    this.removeHiddenCoCd = function(e) {
      var comp_code = $(e.target).attr('comp_code');
      var hidden_type = $(e.target).attr('hidden_type');
      if (hidden_type == HIDDEN_CUSTOMER) {
        thisTag.list_hidden_customer_co_cd_selected = $.grep(thisTag.list_hidden_customer_co_cd_selected, function(element, index) {
           return element.comp_code != comp_code;
        })
        thisTag.update(thisTag.list_hidden_customer_co_cd_selected);
      } else {
        thisTag.list_hidden_dealer_co_cd_selected = $.grep(thisTag.list_hidden_dealer_co_cd_selected, function(element, index) {
          return element.comp_code != comp_code;
        })
        thisTag.update(thisTag.list_hidden_dealer_co_cd_selected);
      }
    }
    
    this.checkedOldValueEdit = function(hidden_co_cd, hidden_type) {
      if (hidden_type == HIDDEN_CUSTOMER) {
        for (var i = 0; i < thisTag.list_hidden_customer_co_cd_select.length; i++) {
            for (var j = hidden_co_cd.length - 1; j >= 0; j--) {
              if(hidden_co_cd[j] == thisTag.list_hidden_customer_co_cd_select[i].comp_code) {
                thisTag.list_hidden_customer_co_cd_selected.push(thisTag.list_hidden_customer_co_cd_select[i]);
              }
            }
          }
          thisTag.update(thisTag.list_hidden_customer_co_cd_selected);
      } else {
        for (var i = 0; i < thisTag.list_hidden_dealer_co_cd_select.length; i++) {
          for (var j = hidden_co_cd.length - 1; j >= 0; j--) {
            if(hidden_co_cd[j] == thisTag.list_hidden_dealer_co_cd_select[i].comp_code) {
              thisTag.list_hidden_dealer_co_cd_selected.push(thisTag.list_hidden_dealer_co_cd_select[i]);
            }
          }
        }
        thisTag.update(thisTag.list_hidden_dealer_co_cd_selected);
      }
    }
    
    this.resetEdit = function (item) {
      thisTag.update({
          customer_co_cd_edit: thisTag.editItem['customer_co_cd'],
          supp_co_cd_edit: thisTag.editItem['supp_co_cd'],
          to_dealer_co_cd_edit: thisTag.editItem['to_dealer_co_cd'] == 'all' ? '' : thisTag.editItem['to_dealer_co_cd']
      });
      
      thisTag.resetAllHiddenSelect(HIDDEN_CUSTOMER);
      thisTag.resetAllHiddenSelect(HIDDEN_DEALER);
      
      if (item.customer_co_cd != null && item.customer_co_cd.length > 0) {
        $("#editCustName").prop("checked", false);
        $("#hidden_customer_co_cd_checkbox_edit").prop("checked", false);
        $("#S06-edit .edit-cust-inp-cls").show();
        $("#hidden_customer_co_cd_checkbox_edit").prop('disabled', true);
      } else {
        $("#editCustName").prop("checked", true);
        $("#S06-edit .edit-cust-inp-cls").hide();
        $("#hidden_customer_co_cd_checkbox_edit").prop("disabled", false);
        $("#customer_co_name_notice_edit").val('');
        if(item.hidden_customer_co_cd && item.hidden_customer_co_cd.length > 0) {
          $("#hidden_customer_co_cd_checkbox_edit").prop("checked", true);
          thisTag.getCompanies(HIDDEN_CUSTOMER, 'edit',item.hidden_customer_co_cd);
        } else {
          $("#hidden_customer_co_cd_checkbox_edit").prop("checked", false);
        }
      }
  
      if (item.to_dealer_co_cd != 'all' && item.to_dealer_co_cd != null && item.to_dealer_co_cd.length > 0) {
        $("#toDealerNameEdit").prop("checked", false);
        $(".to_dealer_co_name_notice_edit").val(item.to_dealer_comp_name);
        $("#hidden_dealer_co_cd_checkbox_edit").prop("checked", false);
        $("#S06-edit .dealer-inp-cls").show();
        $("#hidden_dealer_co_cd_checkbox_edit").prop("disabled", true);
      } else {
        $("#toDealerNameEdit").prop("checked", true);
        $("#S06-edit .dealer-inp-cls").hide();
        $("#hidden_dealer_co_cd_checkbox_edit").prop("disabled", false);
        $(".to_dealer_co_name_notice_edit").val('');
        if(item.hidden_dealer_co_cd && item.hidden_dealer_co_cd.length > 0) {
          $("#hidden_dealer_co_cd_checkbox_edit").prop("checked", true);
          thisTag.getCompanies(HIDDEN_DEALER, 'edit', item.hidden_dealer_co_cd);
        } else {
          $("#hidden_dealer_co_cd_checkbox_edit").prop("checked", false);
        }
      }
  
     if (item.supp_co_cd != null && item.supp_co_cd.length > 0) {
       $("#editManuName").prop("checked", false);
       $(".supp_co_name_notice_edit").val(item.supp_co_name);
       $("#S06-edit .edit-manu-inp-cls").show();
     } else {
       $("#editManuName").prop("checked", true);
       $("#S06-edit .edit-manu-inp-cls").hide();
       $(".supp_co_name_notice_edit").val('');
     }
     $("#noticeImageEdit").val('');
     $("#noticeImageEdit").nextAll('.show-image-detail:first').attr('src', item.image_url);
     thisTag.getSuggestList('edit');
    }
    
    this.getNoticeReference = function (page) {
      var querySuggest = [];
      var accessTokenCognito = localStorage.getItem('accessTokenCognito');
      querySuggest.push('limit=' + LIMIT_ON_PAGE);
      querySuggest.push('page=' + page);
      querySuggest.push('token=' + accessTokenCognito);
      querySuggest.push('sort_value=' + $("#sortCreateDate").val());
      querySuggest.push('sort_field=createdate');
      querySuggest.push('search_start_date=checked');
      querySuggest.push('search_end_date=checked');
      var url = URL_API + '/api/get_notice_info';
      var data = {};

      data = {
          is_hidden:[0,2],
          tab: 2,
          screen: 's06'
      };

      url += '?' + querySuggest.join('&');
      $.ajax({
          url: url,
          type: 'GET',
          timeout: 60000,
          data: {
              notice_info: data
          },
          success: function (res) {
              if(res.status == 100){
                  riot.mount('app','maintain',{ messege:res.messege });
                  return false;
              }
              if(res.message == 'success'){
              var data = res;
              thisTag.list_info = data.list;

              var totalPages = Math.ceil(data.total/LIMIT_ON_PAGE);
              var visiblePages = 1;
              if(totalPages != 0){
                  visiblePages =  5;
              } 
              var $pagination = $('#pagination_notice_info_reference');
              $pagination.twbsPagination('destroy');
              $pagination.twbsPagination({
                  totalPages: totalPages,
                  visiblePages: visiblePages,
                  startPage: thisTag.currentPageReference,
                  initiateStartPageClick: false,
                  onPageClick: function (event, page) {
                    thisTag.currentPageReference = page;
                    thisTag.getNoticeReference(page);
                  }
              });
              thisTag.update(thisTag.list_info);
              $.each(thisTag.list_info,function(i,e){
                  riot.tag('description', '', function(opts) {   
                      this.root.innerHTML = opts.r;
                  });
                  riot.mount('#description_' + i, {
                      r: e.description
                  })
                  thisTag.update();
              });
              $('#sortCreateDate').change(function(){
                  thisTag.sort_value_reference = thisTag.sort_value_reference == 'DESC'? 'ASC': 'DESC';
                  var page = thisTag.currentPageReference;
                  thisTag.getNoticeReference(page);
              })
            }
            
          },
          error: function (xhr, stt, err) {
              alert('error');
          }
      });
    }
    
          
    this.getSuggestList = function (action) {
       if (action == 'edit') {
         
         $(".customer_co_name_notice_edit").autocompleter("destroy");
         $('.customer_co_name_notice_edit').autocompleter({ 
           limit:10000,
           highlightMatches:true, 
           source: thisTag.list_dealer_comp_name, 
           callback: function(value, index, object) {
             if($(".customer_co_name_notice_edit").val() != '' && object.comp_code) {
               thisTag.update({customer_co_cd_edit: object.comp_code});
             } else {
               thisTag.update({customer_co_cd_edit: ''});
             }
           }
         });
         
         $(".supp_co_name_notice_edit").autocompleter("destroy");
         $('.supp_co_name_notice_edit').autocompleter({ 
           limit:10000,
           highlightMatches:true, 
           source: thisTag.list_comp_name, 
           callback: function(value, index, object) {
             if($(".supp_co_name_notice_edit").val() != '' && object.comp_code) {
               thisTag.update({supp_co_cd_edit: object.comp_code});
             } else {
               thisTag.update({supp_co_cd_edit: ''});
             }
           }
         });
         
         $(".to_dealer_co_name_notice_edit").autocompleter("destroy");
         $('.to_dealer_co_name_notice_edit').autocompleter({ 
           limit:10000,
           highlightMatches:true, 
           source: thisTag.all_dealer_comp_name_list, 
           callback: function(value, index, object) {
             if($(".to_dealer_co_name_notice_edit").val() != '' && object.comp_code) {
               thisTag.update({to_dealer_co_cd_edit: object.comp_code});
             } else {
               thisTag.update({to_dealer_co_cd_edit: ''});
             }
           }
         });
         
       }
    }

    this.setSearchDealer = function () {
      if (thisTag.memberType == 0) {
        thisTag.dealer_co_cd = user_info.kikan_code;
        $.each(thisTag.all_dealer_comp_name_list, function(k,v){
          if(v['comp_code'] == thisTag.dealer_co_cd){
            $('.dealer_co_name_notice').val(v['value']);
            return false;
          }
        });
      }
    }

  </script>
  <script>
  DatepickerIntialize();
  </script>
</info-config>
