<search-po-punchout>
    <link rel="stylesheet" href="css/search-top.css">
    <link rel="stylesheet" href="css/animate.css">
    <notice-box></notice-box>
    <div class="main">
        <div class="content">
            <div class="page-title">
                <h2>キーワード検索</h2>
            </div>
            <div class="form-wrapper">
                <div class="form-item">
                    <form onsubmit={ submit }>
                        <table>
                            <tr>
                                <td style="width: 150px !important;">キーワード</td>
                                <td colspan="2">
                                    <input type="text" name="keyword" id="keyword" placeholder="販売元メーカー名・製造元メーカー名・品番・品名・容量・等級名・ＣＡＳ ＮＯ．・EANコード">
                                    <input type="hidden" name="cas_code" id="cas_code">
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td class="form-text">
                                    ※複数の語を空白で区切ると絞込み検索(AND)ができます
                                </td>
                            </tr>
                            <tr class="only_s004">
                                <td colspan="3">
                                    <div style = 'border: 0.5px solid #3e70a5; margin-top: 15px; margin-bottom: 15px'></div>
                                </td>
                            </tr>
                            <tr class="only_s004">
                                <td style="">品番</td>
                                <td>
                                    <input type="text" name="supplier_code" id="supplier_code" placeholder="品番を入力" autocomplete="off">
                                </td>
                                <td>
                                    <select id="no_type">
                                        <option value="1">完全一致</option>
                                        <option value="2">から始まる</option>
                                        <option value="3">で終わる</option>
                                        <option value="4" selected>を含む</option>
                                        <option value="5">含まない</option>
                                    </select>
                                </td>
                            </tr>
                            <tr class="only_s004">
                                <td>品名</td>
                                <td>
                                    <input type="text" name="name" id="name" placeholder="品名を入力" autocomplete="off">
                                </td>
                                <td>
                                    <select id="name_type">
                                        <option value="1">完全一致</option>
                                        <option value="2">から始まる</option>
                                        <option value="3">で終わる</option>
                                        <option value="4" selected>を含む</option>
                                        <option value="5">含まない</option>
                                    </select>
                                </td>
                            </tr>
                            <tr class="only_s004">
                                <td>製造元/ブランド</td>
                                <td colspan="2">
                                    <div class="div-wraper-autocompleter">
                                        <input type="text" name="maker_name" id="maker_name" placeholder="メーカー名を入力（サジェスト）">
                                    </div>
                                    <div class="multi_select"></div>
                                </td>
                            </tr>
                            <tr class="only_s004">
                                <td>CAS No.</td>
                                <td colspan="2">
                                    <input type="text" name="search_cas_code" id="search_cas_code" placeholder="CAS No.を入力">
                                </td>
                            </tr>
                            <tr id="search-campaign">
                                <td></td>
                                <td>
                                    <div>
                                        <label for="search_campaign" style="display: inline;">キャンペーン中の商品のみ検索</label>
                                        <input type="checkbox" name="search_campaign" id="search_campaign" style="display: inline; width: auto;">
                                    </div>
                                </td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>表示件数</td>
                                <td>
                                    <select id="limit" style="width:60px">
                                        <option selected="{limit_po_on_page == 20 ? 'selected':''}">20</option>
                                        <option selected="{limit_po_on_page == 50 ? 'selected':''}">50</option>
                                    </select>
                                    件
                                </td>
                            </tr>
                            <tr>
                                <td class="searchBtnTd">
                                    <button class="reset-btn" type="reset"><i class="fa fa-refresh" aria-hidden="true"></i>条件クリア</button>
                                </td>
                                 <td>
                                     <button style="color: red; display: none" type="button" id="ec27-Open">カタログ外商品のお見積りはこちら</button>
                                 </td>
                                <td align="right" colspan="2">
                                    <button class="search-btn" type="submit">検索</button>
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>
            <div id="not-found" class="not-found text-center" style="display:none">
                <img src="img/search-not-found.png" alt="Result not found">
                <p style="margin-top:-80px;font-weight:bold;font-size:20px">検索結果は0件でした。他のキーワードで再度検索してみてください。</p>
            </div>
            <div id="search-result">
                <div id="paging" class="text-center">
                    <ul class="pagination" id="pagination"></ul>
                </div>
            </div>
            <search-result-punchout></search-result-punchout>
            <ec27></ec27>
        </div>
    </div>
    <script>
        ec10_current_search = 'search-po';
        this.limit_on_page = ec10_limit_on_page;
        this.basic_is_active = opts.basic_is_active;
        this.suggest_list = opts.suggest_list;
        this.conditions = [
            {condition: '完全一致'},
            {condition: 'から始まる'},
            {condition: 'を含む'},
        ];
        var user_info = JSON.parse(getItem('EcUserInfo'));
        this.total = 1;
        var thisTag = this;
        this.list_show = user_info.list_navigation.S;
        this.list_show_F = user_info.list_navigation.F;
        this.list_show_B = user_info.list_navigation.B;
        toggle(e) {
            this.basic_is_active = !this.basic_is_active;
            this.antibody_is_active = !this.antibody_is_active;
        }

        var accessTokenCognito = getItem('accessTokenCognito');
        const notFoundResult=(total)=>{
            if(total==0){
              $("#not-found").css("display","block");
              $("#search-result").css("display","none");
            }else{
              $("#not-found").css("display","none");
              $("#search-result").css("display","block");
            }
        }
        this.on('mount', function () {
            var suggest_list = JSON.parse(getItem('suggest_list'));
            var check_detail = arColumn(this.list_show, 'navigation_id', 'S004');
            if (check_detail.length > 0) {
                if (check_detail[0].display_status == 'N') {
                    $(".only_s004").remove();
                    // $("#panel_2").remove();
                    // $("#more-option").remove();
                }
            }
            var check_detail = arColumn(this.list_show_F, 'navigation_id', 'F013');
            if (check_detail.length > 0) {
                if (check_detail[0].display_status == 'N') {
                    $("#search-campaign").remove();
                }
            } else {
                $("#search-campaign").remove();
            }
            var check_detail = arColumn(this.list_show_B, 'navigation_id', 'B013');
            if (check_detail.length > 0) {
                $('#ec27-Open').text(arColumn(this.list_show_B, 'navigation_id', 'B013')[0]['display_contents']);
                if (check_detail[0].display_status == 'N') {
                    $("#ec27-Open").remove();
                }
                if(!check_detail[0].display_status){
                    $("#ec27-Open").remove();
                }
            } else {
                $("#ec27-Open").remove();
            }

            $('#maker_name').autocomplete({
                open: function( event, ui ) {
                    return event.target.value;
                },
                source: function( request, response  ) {
                    var convertMatcher3 = '';
                    if (request.term.length > 0) {
                        convertMatcher3 = new RegExp("^" + $.ui.autocomplete.escapeRegex( mb_convert_kana(request.term, 'RNSKHC')), 'i');
                    }
                    var convertMatcher = request.term.replace(/[\uff01-\uff5e]/g,function(ch) { return String.fromCharCode(ch.charCodeAt(0) - 0xfee0); });
                    convertMatcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( convertMatcher ), "i" );
                    var convertMatcher2 = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term.toFullWidth() ), "i" );
                    var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term ), "i" );
                    response( $.grep( JSON.parse(JSON.stringify(suggest_list)), function( item ){
                        return  convertMatcher2.test(item) || convertMatcher3.test(item) || convertMatcher.test(item) || matcher.test( item );
                    }) );
                },
                select: function( event, ui ) {
                    $('.multi_select').append('<p>'+ui.item.value+'<i class="fa fa-times x-multi_select-search" aria-hidden="true"></i></p>');
                    $('#maker_name').val('');
                    return false;
                }
            });

            $(document).on('click', '.x-multi_select-search', function() {
                $(this).parent().remove();
            });
            $('#keyword').val(ec10_keyword);
            if (ec10_keyword != '') {
                if (ec10_cas_code) {
                    $('.form-item form')[0].reset();
                    $('#search_cas_code').val(ec10_cas_code);
                    submit();
                    ec10_cas_code = '';
                    return;
                }
                if(check_login){
                    submit();
                } else {
                    var result_search = JSON.parse(getItem('result_search')) ? JSON.parse(getItem('result_search')) : [];
                    if (result_search.length > 0) {
                        thisTag.searchBack();
                    }
                }
            } else if (ec10_cas_code) {
                $('.form-item form')[0].reset();

                $('#search_cas_code').val(ec10_cas_code);
                submit();
            } else {
                if(ec12_back_po == 'search-po'){
                    var result_search = JSON.parse(getItem('result_search')) ? JSON.parse(getItem('result_search')) : [];
                    if (result_search.length > 0) {
                        thisTag.searchBack();
                    }
                    // submit();
                }
            }
        })
        this.backToTop = function(){
            $('body,html').animate({
                scrollTop: 0
            }, 0);
        }

        this.searchBack = function(){
            $('#ec27-Open').show();
            var result_search = JSON.parse(getItem('result_search'));
            var last_search = result_search[result_search.length-1];
            var panel = last_search.panel;
            var result_search_page = last_search.page;
            var keyword = last_search.keyword;
            var search_supplier_code = last_search.search_supplier_code;
            var search_name_jp = last_search.search_name_jp;
            var search_maker_name = last_search.search_maker_name;
            var search_cas_code = last_search.search_cas_code;
            var no_type = last_search.no_type;
            var name_type = last_search.name_type;
            var search_campaign = last_search.search_campaign;
            // if (panel == 'panel_2') {
            // $('.tab-area').find('#more-option').addClass('active');
            // $('.panel-area').find('#panel_2').addClass('active');
            // $('.tab-area').find('#keyword-option').removeClass('active');
            // $('.panel-area').find('#panel_1').removeClass('active');
            $('#supplier_code').val(search_supplier_code);
            $('#name').val(search_name_jp);
            if (search_maker_name.length > 0) {
                var html = '';
                for (var i = 0; i < search_maker_name.length; i++) {
                    var item = search_maker_name[i];
                    html += '<p>'+item+'<i class="fa fa-times x-multi_select-search" aria-hidden="true"></i></p>';
                }
                $('.multi_select').append(html);
            }
            $('#search_cas_code').val(search_cas_code);
            $('#no_type').val(no_type);
            $('#name_type').val(name_type);
            // $('#keyword').prop('disabled', true);
            // } else {
            //     $('.tab-area').find('#keyword-option').addClass('active');
            //     $('.panel-area').find('#panel_1').addClass('active');
            //     $('.tab-area').find('#more-option').removeClass('active');
            //     $('.panel-area').find('#panel_2').removeClass('active');
            $('#keyword').val(keyword);
            // $('#keyword').prop('disabled', false);
            // }
            if (search_campaign) {
                $('#search_campaign').prop('checked', true);
            }
            if(ec12_back_po == 'search-po' && login_back == true){
                result_search.pop();
            }
            setItem('result_search', JSON.stringify(result_search));
            riot.mount('search-result-punchout', {results: last_search.product_list,total:last_search.total, tag: 'search/simple-po'});
            thisTag.backToTop();
            var $pagination = $('#pagination');
            var totalPages = Math.ceil(last_search.total/$('#limit').val());
            $pagination.twbsPagination('destroy');
            $pagination.twbsPagination({
                totalPages: totalPages,
                visiblePages: 5,
                startPage: result_search_page,
                initiateStartPageClick: false,
                onPageClick: function (event, page) {
                    var url = URL_API + '/v1/get_product_ec102';
                    // var dis_keyword = false;
                    // dis_keyword = $('#keyword').prop('disabled');
                    var keyword = $('#keyword').val();
                    var search_supplier_code = $('#supplier_code').val();
                    var search_name_jp = $('#name').val();
                    var search_maker_name = $('#maker_name').val();
                    var search_cas_code = $('#search_cas_code').val();
                    var no_type = $('#no_type').val();
                    var name_type = $('#name_type').val();
                    var lstSuggest = new Array();
                    var checkKeyword = trimSpaces(keyword).split(/[ 　]/);
                    if (checkKeyword.length >= 6) {
                        alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                        return;
                    }
                    if (search_supplier_code != null) {
                        var checkKeyword = trimSpaces(search_supplier_code).split(/[ 　]/);
                        if (checkKeyword.length >= 6) {
                            alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                            return;
                        }
                    }
                    if (search_name_jp != null) {
                        var checkKeyword = trimSpaces(search_name_jp).split(/[ 　]/);
                        if (checkKeyword.length >= 6) {
                            alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                            return;
                        }
                    }
                    $('.multi_select').find('p').each(function(index, el) {
                        var lstText = $(this).text();
                        lstSuggest.push(lstText);
                    });
                    var query = [];
                    query.push('token=' + accessTokenCognito);
                    query.push('page=' + page);
                    query.push('limit=' + $('#limit').val());
                    if (keyword) {
                        // if (keyword && !dis_keyword) {
                        query.push('keywords=' + encodeURIComponent(keyword));
                    }
                    // if (panel == 'panel_2') {
                    if (search_supplier_code) {
                        query.push('search_supplier_code=' + encodeURIComponent(search_supplier_code));
                    }
                    if (search_name_jp) {
                        query.push('search_name_jp=' + encodeURIComponent(search_name_jp));
                    }
                    if (lstSuggest.length > 0) {
                        query.push('search_maker_name=' + encodeURIComponent(JSON.stringify((lstSuggest))));
                    }
                    if (search_cas_code) {
                        query.push('search_cas_code=' + encodeURIComponent(search_cas_code));
                    }
                    if (search_supplier_code && no_type) {
                        query.push('no_type=' + encodeURIComponent(no_type));
                    }
                    if (search_name_jp && name_type) {
                        query.push('name_type=' + encodeURIComponent(name_type));
                    }
                    // }
                    if ($('#search_campaign').is(':checked')) {
                        query.push('search_campaign=true');
                    }
                    if (ec10_cas_code) {
                        query.push('cas_value=' + ec10_cas_code);
                    }
                    url += '?' + query.join('&');
                    $.ajax({
                        url: url,
                        type: 'GET',
                        success: function (data) {
                            if(data.status == 100){
                                riot.mount('app','maintain',{ messege:data.messege });
                                return false;
                            }
                            if(data.http == 400){
                                alert(data.message);
                                return false;
                            }
                            thisTag.total = data.total;
                            ec10_total_page_po = data.total;
                            var total = data.total;
                            var results = data.product_list;
                            var newArray = [];
                            data.page = page;
                            data.keyword = keyword;
                            data.search_supplier_code = search_supplier_code;
                            data.search_name_jp = search_name_jp;
                            data.search_maker_name = lstSuggest;
                            data.search_cas_code = search_cas_code;
                            data.no_type = no_type;
                            data.name_type = name_type;
                            data.search_campaign = false;
                            if ($('#search_campaign').is(':checked')) {
                                data.search_campaign = true;
                            }
                            newArray = JSON.parse(getItem('result_search')) ? JSON.parse(getItem('result_search')) : [];
                            if (Array.isArray(newArray)) {
                                newArray.push(data);
                            } else {
                                newArray = [];
                            }
                            // newArray.push(data);
                            setItem('result_search', JSON.stringify(newArray));
                            // localStorage.setItem('result_search', JSON.stringify(data));
                            // localStorage.setItem('result_search_page', page);
                            riot.mount('search-result-punchout', {results: results,total:total, tag: 'search/simple-po'});
                            thisTag.backToTop();
                        },
                        error: function (xhr, stt, error) {
                            alert('error');
                        }
                    });
                }
            });
        }
        submit = function (e) {
            $('#ec27-Open').show();
            if(ec10_current_search == 'search-po'){
                ec12_back_po = 'search-po';
            }
            // var dis_keyword = false;
            // dis_keyword = $('#keyword').prop('disabled');
            var keyword = $('#keyword').val();
            var search_supplier_code = $('#supplier_code').val();
            var search_name_jp = $('#name').val();
            var search_maker_name = $('#maker_name').val();
            var search_cas_code = $('#search_cas_code').val();
            var no_type = $('#no_type').val();
            var name_type = $('#name_type').val();
            var checkKeyword = trimSpaces(keyword).split(/[ 　]/);
            if (checkKeyword.length >= 6) {
                alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                return;
            }
            if (search_supplier_code != null) {
                var checkKeyword = trimSpaces(search_supplier_code).split(/[ 　]/);
                if (checkKeyword.length >= 6) {
                    alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                    return;
                }
            }
            if (search_name_jp != null) {
                var checkKeyword = trimSpaces(search_name_jp).split(/[ 　]/);
                if (checkKeyword.length >= 6) {
                    alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                    return;
                }
            }
            if (e) {
                ec10_cas_code = '';
                thisTag.total = 1;
                ec10_po_current_page = 1;
                ec10_total_page_po = 1;
            }
            var lstSuggest = new Array();
            $('.multi_select').find('p').each(function(index, el) {
                var lstText = $(this).text();
                lstSuggest.push(lstText);
            });
            // var panel = JSON.parse(localStorage.getItem('data-panel')) ? JSON.parse(localStorage.getItem('data-panel')) : '';
            var $pagination = $('#pagination');
            var totalPages = Math.ceil(ec10_total_page_po/$('#limit').val());
            $pagination.twbsPagination('destroy');
            $pagination.twbsPagination({
                totalPages: totalPages,
                visiblePages: 5,
                startPage: ec10_po_current_page,
                onPageClick: function (event, page) {
                    ec10_limit_on_page = $('#limit').val();
                    ec10_po_current_page = page;
                    var url = URL_API + '/v1/get_product_ec102';
                    var query = [];
                    query.push('token=' + accessTokenCognito);
                    query.push('page=' + page);
                    query.push('limit=' + $('#limit').val());
                    if (keyword) {
                        // if (keyword && !dis_keyword) {
                        query.push('keywords=' + encodeURIComponent(keyword));
                    }
                    // if (panel == 'panel_2') {
                    if (search_supplier_code) {
                        query.push('search_supplier_code=' + encodeURIComponent(search_supplier_code));
                    }
                    if (search_name_jp) {
                        query.push('search_name_jp=' + encodeURIComponent(search_name_jp));
                    }
                    if (lstSuggest.length > 0) {
                        query.push('search_maker_name=' + encodeURIComponent(JSON.stringify((lstSuggest))));
                    }
                    if (search_cas_code) {
                        query.push('search_cas_code=' + encodeURIComponent(search_cas_code));
                    }
                    if (search_supplier_code && no_type) {
                        query.push('no_type=' + encodeURIComponent(no_type));
                    }
                    if (search_name_jp && name_type) {
                        query.push('name_type=' + encodeURIComponent(name_type));
                    }
                    // }
                    if (ec10_cas_code) {
                        query.push('cas_value=' + ec10_cas_code);
                    }
                    if ($('#search_campaign').is(':checked')) {
                        query.push('search_campaign=true');
                    }
                    console.log(query)
                    // write in storage
                    ec10_keyword = keyword;
                    // end write
                    url += '?' + query.join('&');
                    $.ajax({
                        type: 'GET',
                        url: url,
                        timeout: 60000,
                        success: function (data, text) {
                            notFoundResult(data.total);
                            if(data.status == 100){
                                riot.mount('app','maintain',{ messege:data.messege });
                                return false;
                            }
                            if(data.http == 400){
                                alert(data.message);
                                return false;
                            }
                            thisTag.total = data.total;
                            var total = data.total;
                            var panel = JSON.parse(getItem('data-panel')) ? JSON.parse(getItem('data-panel')) : '';
                            ec10_total_page_po = total;
                            var results = data.product_list;
                            var newArray = [];
                            data.page = page;
                            data.panel = panel;
                            data.keyword = keyword;
                            data.search_supplier_code = search_supplier_code;
                            data.search_name_jp = search_name_jp;
                            data.search_maker_name = lstSuggest;
                            data.search_cas_code = search_cas_code;
                            data.no_type = no_type;
                            data.name_type = name_type;
                            data.search_campaign = false;
                            if ($('#search_campaign').is(':checked')) {
                                data.search_campaign = true;
                            }
                            newArray = JSON.parse(getItem('result_search')) ? JSON.parse(getItem('result_search')) : [];
                            if (Array.isArray(newArray)) {
                                newArray.push(data);
                            } else {
                                newArray = [];
                            }
                            // newArray.push(data);
                            setItem('result_search', JSON.stringify(newArray));
                            // localStorage.setItem('result_search_page', page);
                            riot.mount('search-result-punchout', {results: results,total:total, tag: 'search/simple-po'});
                            thisTag.backToTop();
                            var totalPages = Math.ceil(data.total/$('#limit').val());
                            var $pagination = $('#pagination');
                            $pagination.twbsPagination('destroy');
                            $pagination.twbsPagination({
                                totalPages: totalPages,
                                visiblePages: 5,
                                initiateStartPageClick: false,
                                startPage: ec10_po_current_page,
                                onPageClick: function (event, page) {

                                    ec10_po_current_page = page;
                                    // console.log(ec10_po_current_page);
                                    var url = URL_API + '/v1/get_product_ec102';
                                    // var dis_keyword = false;
                                    // dis_keyword = $('#keyword').prop('disabled');
                                    var keyword = $('#keyword').val();
                                    var search_supplier_code = $('#supplier_code').val();
                                    var search_name_jp = $('#name').val();
                                    var search_maker_name = $('#maker_name').val();
                                    var search_cas_code = $('#search_cas_code').val();
                                    var no_type = $('#no_type').val();
                                    var name_type = $('#name_type').val();
                                    var checkKeyword = trimSpaces(keyword).split(/[ 　]/);
                                    if (checkKeyword.length >= 6) {
                                        alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                                        return;
                                    }
                                    if (search_supplier_code != null) {
                                        var checkKeyword = trimSpaces(search_supplier_code).split(/[ 　]/);
                                        if (checkKeyword.length >= 6) {
                                            alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                                            return;
                                        }
                                    }
                                    if (search_name_jp != null) {
                                        var checkKeyword = trimSpaces(search_name_jp).split(/[ 　]/);
                                        if (checkKeyword.length >= 6) {
                                            alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                                            return;
                                        }
                                    }
                                    var lstSuggest = new Array();
                                    $('.multi_select').find('p').each(function(index, el) {
                                        var lstText = $(this).text();
                                        lstSuggest.push(lstText);
                                    });
                                    var query = [];
                                    query.push('token=' + accessTokenCognito);
                                    query.push('page=' + ec10_po_current_page);
                                    query.push('limit=' + $('#limit').val());
                                    if (keyword) {
                                        // if (keyword && !dis_keyword) {
                                        query.push('keywords=' + encodeURIComponent(keyword));
                                    }
                                    // if (panel == 'panel_2') {
                                    if (search_supplier_code) {
                                        query.push('search_supplier_code=' + encodeURIComponent(search_supplier_code));
                                    }
                                    if (search_name_jp) {
                                        query.push('search_name_jp=' + encodeURIComponent(search_name_jp));
                                    }
                                    if (lstSuggest.length > 0) {
                                        query.push('search_maker_name=' + encodeURIComponent(JSON.stringify((lstSuggest))));
                                    }
                                    if (search_cas_code) {
                                        query.push('search_cas_code=' + encodeURIComponent(search_cas_code));
                                    }
                                    if (search_supplier_code && no_type) {
                                        query.push('no_type=' + encodeURIComponent(no_type));
                                    }
                                    if (search_name_jp && name_type) {
                                        query.push('name_type=' + encodeURIComponent(name_type));
                                    }
                                    // }
                                    if (ec10_cas_code) {
                                        query.push('cas_value=' + ec10_cas_code);
                                    }
                                    if ($('#search_campaign').is(':checked')) {
                                        query.push('search_campaign=true');
                                    }

                                    url += '?' + query.join('&');
                                    $.ajax({
                                        url: url,
                                        type: 'GET',
                                        success: function (data) {
                                            if(data.status == 100){
                                                riot.mount('app','maintain',{ messege:data.messege });
                                                return false;
                                            }
                                            if(data.http == 400){
                                                alert(data.message);
                                                return false;
                                            }
                                            thisTag.total = data.total;
                                            ec10_total_page_po = data.total;
                                            var total = data.total;
                                            var panel = JSON.parse(getItem('data-panel')) ? JSON.parse(getItem('data-panel')) : '';
                                            var results = data.product_list;
                                            var newArray = [];
                                            data.page = page;
                                            data.panel = panel;
                                            data.keyword = keyword;
                                            data.search_supplier_code = search_supplier_code;
                                            data.search_name_jp = search_name_jp;
                                            data.search_maker_name = lstSuggest ;
                                            data.search_cas_code = search_cas_code;
                                            data.no_type = no_type;
                                            data.name_type = name_type;
                                            data.search_campaign = false;
                                            if ($('#search_campaign').is(':checked')) {
                                                data.search_campaign = true;
                                            }
                                            newArray = JSON.parse(getItem('result_search')) ? JSON.parse(getItem('result_search')) : [];
                                            if (Array.isArray(newArray)) {
                                                newArray.push(data);
                                            } else {
                                                newArray = [];
                                            }
                                            // newArray.push(data);
                                            setItem('result_search', JSON.stringify(newArray));
                                            // localStorage.setItem('result_search', JSON.stringify(data));
                                            // localStorage.setItem('result_search_page', page);
                                            riot.mount('search-result-punchout', {results: results,total:total, tag: 'search/simple-po'});
                                            thisTag.backToTop();
                                        },
                                        error: function (xhr, stt, error) {
                                            alert('error');
                                        }
                                    });
                                }
                            });
                        },
                        error: function (xhr, stt, error) {
                            alert('error');
                        }
                    });
                }
            });
        }
        $(function() {
            $('#ec27-Open').on('click',function(){
                $('#img-loader').hide();
                var accessTokenCognito = localStorage.getItem('accessTokenCognito');
                var dealer = [];
                var url_dealer = URL_API + '/api/get_dealer_customers_ec27?token=' + accessTokenCognito

                $.ajax({
                    url: url_dealer,
                    type: 'GET',
                    timeout: 60000,
                    async:false,
                    success: function (data) {
                        if(data.status == 100){
                            riot.mount('app','maintain',{ messege:data.messege });
                            return false;
                        }
                        if(data.status == 'not_authorize'){
                            var url = "#";
                            $(location).attr("href", url );
                            return false;
                        }
                        dealer = data.dealer;
                    },
                    error: function (xhr, stt, err) {
                        alert('error');
                    }
                });
                riot.mount('ec27',{ dealer: dealer });
                $('#ec27-form').fadeIn();
            });
            $('#maker_name').autocomplete({
                open: function( event, ui ) {
                    return event.target.value;
                },
                source: function( request, response  ) {
                    var convertMatcher3 = '';
                    if (request.term.length > 0) {
                        convertMatcher3 = new RegExp("^" + $.ui.autocomplete.escapeRegex( mb_convert_kana(request.term, 'RNSKHC')), 'i');
                    }
                    var convertMatcher = request.term.replace(/[\uff01-\uff5e]/g,function(ch) { return String.fromCharCode(ch.charCodeAt(0) - 0xfee0); });
                    convertMatcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( convertMatcher ), "i" );
                    var convertMatcher2 = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term.toFullWidth() ), "i" );
                    var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term ), "i" );
                    response( $.grep( JSON.parse(JSON.stringify(thisTag.suggest_list)), function( item ){
                        return  convertMatcher2.test(item) || convertMatcher3.test(item) || convertMatcher.test(item) || matcher.test( item );
                    }) );
                },
                select: function( event, ui ) {
                    $('#maker_name').val('');
                    $('.multi_select').append('<p>'+ui.item.value+'<i class="fa fa-times x-multi_select-search" aria-hidden="true"></i></p>');
                    return false;
                }
            });

            $(document).on('click', '.x-multi_select-search', function() {
                $(this).parent().remove();
            });
            $('.reset-btn').on('click', function() {
                $('.multi_select').find('p').remove();
                clearTypeSearch(); 
            })
            var panel = JSON.parse(getItem('data-panel')) ? JSON.parse(getItem('data-panel')) : 'panel_1';
            localStorage.setItem('data-panel', JSON.stringify(panel));

        });
        String.prototype.toHalfWidth = function() {
            return this.replace(/[Ａ-Ｚａ-ｚ０-９ァ-ン]/g, function(s) {return String.fromCharCode(s.charCodeAt(0) - 0xFEE0)});
        };

        String.prototype.toFullWidth = function() {
            return this.replace(/[A-Za-z0-9\uFF65-\uFF9F]/g, function(s) { return String.fromCharCode(s.charCodeAt(0) + 0xFEE0)});
        };
    </script>
</search-po-punchout>

<description-po-punchout>
    <link rel="stylesheet" href="css/product-details.css">
    <link rel="stylesheet" href="css/popup.css">
    <div class="main">
        <div class="product-details content">
            <div class="page-title">
                <h2>商品情報詳細</h2>
                <div class="btn-wrapper">
                    <!--  <button type="button" class="color-btn green-btn" id="idExportPdf" style="display: { arColumn(list_button, 'navigation_id', 'B004').length ?  'inline' : 'none'  }" onclick="{ exportPdf }">{ arColumn(list_button, 'navigation_id', 'B004').length ? arColumn(list_button, 'navigation_id', 'B004')[0]['display_contents'] : '' }</button> -->

                    <a href="#view-pdf/{encodeURIComponent(product_id)}/1" class="pdf-tab-view color-btn green-btn" id="pdf-tab-view" target="_blank" style="display: { arColumn(list_button, 'navigation_id', 'B004').length && permission != 5 ?  'inline' : 'none'  }">{ arColumn(list_button, 'navigation_id', 'B004').length ? arColumn(list_button, 'navigation_id', 'B004')[0]['display_contents'] : '' }</a>

                    <a href="#" class="pdf-tab-view color-btn green-btn"  style="display: { arColumn(list_button, 'navigation_id', 'B004').length && permission == 5 ?  'inline' : 'none'  }">{ arColumn(list_button, 'navigation_id', 'B004').length ? arColumn(list_button, 'navigation_id', 'B004')[0]['display_contents'] : '' }</a>

                    <button type="button" class="color-btn orange-btn" style="display: {  arColumn(list_button, 'navigation_id', 'B001').length ? 'inline' : 'none'  }" onclick="{ addFavorite }">{ arColumn(list_button, 'navigation_id', 'B001').length ? arColumn(list_button, 'navigation_id', 'B001')[0]['display_contents'] : '' }</button>

                </div>
            </div>
            <table class="detail-table">
                <tr>
                    <th>品番</th>
                    <td colspan="5" data-test="supplier_sku_test_cafe">
                        {product_detail.supplier_sku ? product_detail.supplier_sku : ''}　{product_detail.manufacturer_sku ? '［製造元品番:'+product_detail.manufacturer_sku+'］' : ''}
                        <a if={product_detail.url1} target="_blank" href="{product_detail.url1}"><i class="fa fa-external-link-square"></i>メーカー製品ページ</a>
                        <a if={product_detail.supplier_comp_code=='20000488'} target="_blank" href="https://labchem-wako.fujifilm.com/jp/product/result/product.html?fw={product_detail.supplier_sku}"><i class="fa fa-external-link-square"></i>メーカー製品ページ</a>
                    </td>
                </tr>
                <tr>
                    <th>品名</th>
                    <td colspan="5">
                        <p>{product_detail.name}</p>
                        <p>{product_detail.name_jp == product_detail.name ? '' : product_detail.name_jp}</p>
                    </td>
                </tr>
                <tr>
                    <th>規格</th>
                    <td>{product_detail.class_name_jp}</td>
                    <th>内容量</th>
                    <td>{product_detail.volume_unit_label}</td>
                    <th rowspan="4">商品画像</th>
                    <td class="product-img" rowspan="4">
                        <a href="{product_detail.photo_url}" target="_blank"><img src="{product_detail.photo_url}" id="product_photo" style="max-height:250px;max-width:250px" if={product_detail.photo_url}></a>
                    </td>
                </tr>
                <tr>
                    <th>販売元</th>
                    <td>{product_detail.sales_origin_maker_name}</td>
                    <th>製造元/ブランド</th>
                    <td>{!product_detail.brand_name ? product_detail.maker_name : (!product_detail.maker_name ? product_detail.brand_name : product_detail.maker_name + '/' + product_detail.brand_name) }</td>
                </tr>
                <tr>
                    <th class="cas_no">CAS番号</th>
                    <td>{product_detail.cas_code}</td>
                    <th>EANコード</th>
                    <td>{product_detail.ean}</td>
                </tr>
                <tr>
                    <th>メーカー在庫情報</th>
                    <td class="padding-add-vertical"><p style="margin-bottom:0;">{product_detail.reg_stock}</p><p style="margin-bottom:0;" if = {product_detail.brp_created_time != ''}>更新日時: {product_detail.brp_created_time}</p></td>
                    <th>メーカー標準納期</th>
                    <td>{product_detail.reg_devtime}</td>
                </tr>
                <tr>
                    <th rowspan="4">法規情報</th>
                    <td rowspan="4" colspan="3" if={(arColumn(list_field, 'navigation_id', 'F007').length > 0) && arColumn(list_field, 'navigation_id', 'F007')[0].used_status == 'Y'}>
                    <div if={!(!product_detail.hazadous_name && !product_detail.poisonous_material_name && !product_detail.poisonous_medicine_name && !product_detail.medicine_name && !product_detail.animal_medicine_name && !product_detail.specifical_medicine_name && !product_detail.medical_equipmentl_name && !product_detail.psychotropic_drug_name && !product_detail.stimulant_drug_material_name && !product_detail.stimulant_drug_material_name && !product_detail.cartagenal_name && !product_detail.prtrl_name && !product_detail.cscll_name && !product_detail.biological_origin_name && !product_detail.international_controlled_substance_name && !product_detail.ozone_protect_name && !product_detail.chemical_weapon_name && !product_detail.safety_and_health_act_name && !product_detail.sds_name && !product_detail.radiation_hazard_prevention_name && !product_detail.air_pollution_control_name && !product_detail.water_pollution_control_name && !product_detail.soil_contamination_name)}>
                        <li>{product_detail.hazadous_name ? ( (list_text_check_2.indexOf(product_detail.hazadous_name) >= 0) ? '' : '危険物(消防法): ' + product_detail.hazadous_name) : '危険物(消防法): 情報なし'}</li>

                        <li>{product_detail.poisonous_material_name ? ((list_text_check_2.indexOf(product_detail.poisonous_material_name) >= 0) ? '' : '毒劇物(毒物及び劇物取締法): ' + product_detail.poisonous_material_name) : '毒劇物(毒物及び劇物取締法): 情報なし'}</li>

                        <li>{product_detail.poisonous_medicine_name ? ((list_text_check_2.indexOf(product_detail.poisonous_medicine_name) >= 0) ? '' : '毒劇薬: ' + product_detail.poisonous_medicine_name) : '毒劇薬: 情報なし'}</li>

                        <li>{product_detail.medicine_name ? ((list_text_check_2.indexOf(product_detail.medicine_name) >= 0) ? '' : '医薬品(薬事法): ' + product_detail.medicine_name) : '医薬品(薬事法): 情報なし'}</li>

                        <li>{product_detail.animal_medicine_name ? ((list_text_check_2.indexOf(product_detail.animal_medicine_name) >= 0) ? '' : '動物薬: ' + product_detail.animal_medicine_name) : '動物薬: 情報なし'}</li>

                        <li>{product_detail.specifical_medicine_name ? ((list_text_check_2.indexOf(product_detail.specifical_medicine_name) >= 0) ? '' : '指定薬物: ' + product_detail.specifical_medicine_name) : '指定薬物: 情報なし'}</li>

                        <li>{product_detail.medical_equipmentl_name ? ((list_text_check_2.indexOf(product_detail.medical_equipmentl_name) >= 0) ? '' : '医療機器: ' + product_detail.medical_equipmentl_name) : '医療機器: 情報なし'}</li>

                        <li>{product_detail.psychotropic_drug_name ? ((list_text_check_2.indexOf(product_detail.psychotropic_drug_name) >= 0) ? '' : '麻薬・向精神薬(麻薬および向精神薬取締法) ' + product_detail.psychotropic_drug_name) : '麻薬・向精神薬(麻薬および向精神薬取締法) 情報なし'}</li>

                        <li>{product_detail.stimulant_drug_material_name ? ((list_text_check_2.indexOf(product_detail.stimulant_drug_material_name) >= 0) ? '' : '覚せい剤原料: ' + product_detail.stimulant_drug_material_name) : '覚せい剤原料: 情報なし'}</li>

                        <li>{product_detail.duty_free_alcohol_name ? ((list_text_check_2.indexOf(product_detail.duty_free_alcohol_name) >= 0) ? '' : '免税アルコール: ' + product_detail.duty_free_alcohol_name) : '免税アルコール: 情報なし'}</li>

                        <li>{product_detail.cartagenal_name ? ((list_text_check_2.indexOf(product_detail.cartagenal_name) >= 0) ? '' : 'カルタヘナ: ' + product_detail.cartagenal_name) : 'カルタヘナ: 情報なし'}</li>

                        <li>{product_detail.prtrl_name ? ((list_text_check_2.indexOf(product_detail.prtrl_name) >= 0) ? '' : 'PRTR法: ' + product_detail.prtrl_name) : 'PRTR法: 情報なし'}</li>

                        <li>{product_detail.cscll_name ? ((list_text_check_2.indexOf(product_detail.cscll_name) >= 0) ? '' : '化審法: ' + product_detail.cscll_name) : ''}</li>

                        <li>{product_detail.international_controlled_substance_name ? ((list_text_check_2.indexOf(product_detail.international_controlled_substance_name) >= 0) ? '' : '国際規制物質: ' + product_detail.international_controlled_substance_name) : '国際規制物質: 情報なし'}</li>

                        <li>{product_detail.ozone_protect_name ? ((list_text_check_2.indexOf(product_detail.ozone_protect_name) >= 0) ? '' : 'オゾン層保護法: ' + product_detail.ozone_protect_name) : 'オゾン層保護法: 情報なし'}</li>

                        <li>{product_detail.chemical_weapon_name ? ((list_text_check_2.indexOf(product_detail.chemical_weapon_name) >= 0) ? '' : '化学兵器禁止法: ' + product_detail.chemical_weapon_name) : '化学兵器禁止法: 情報なし'}</li>

                        <li>{product_detail.safety_and_health_act_name ? ((list_text_check_2.indexOf(product_detail.safety_and_health_act_name) >= 0) ? '' : '労働安全衛生法: ' + product_detail.safety_and_health_act_name) : '労働安全衛生法: 情報なし'}</li>

                        <li>{product_detail.sds_name ? ((list_text_check_2.indexOf(product_detail.sds_name) >= 0) ? '' : 'SDS該当区分: ' + product_detail.sds_name) : 'SDS該当区分: 情報なし'}</li>

                        <li>{product_detail.radiation_hazard_prevention_name ? ((list_text_check_2.indexOf(product_detail.radiation_hazard_prevention_name) >= 0) ? '' : '放射線障害防止法: ' + product_detail.radiation_hazard_prevention_name) : '放射線障害防止法: 情報なし'}</li>

                        <li>{product_detail.biological_origin_name ? ((list_text_check_2.indexOf(product_detail.biological_origin_name) >= 0) ? '' : '生物由来製品: ' + product_detail.biological_origin_name) : '生物由来製品: 情報なし'}</li>

                        <li>{product_detail.soil_contamination_name ? ((list_text_check_2.indexOf(product_detail.soil_contamination_name) >= 0) ? '' : '土壌汚染対策法: ' + product_detail.soil_contamination_name) : '土壌汚染対策法: 情報なし'}</li>

                        <!--
                                    { (product_detail.hazadous_name ? ( (list_text_check_2.indexOf(product_detail.hazadous_name) >= 0) ? 1 : f1) : f1) }

                                    {(product_detail.poisonous_material_name ? ( (list_text_check_2.indexOf(product_detail.poisonous_material_name) >= 0) ? 2 : f2) : f2)}
                                    {(product_detail.psychotropic_drug_name ? ( (list_text_check_2.indexOf(product_detail.psychotropic_drug_name) >= 0) ? 3 : f3) : f3)}
                                    {(product_detail.cartagenal_name ? ( (list_text_check_2.indexOf(product_detail.cartagenal_name) >= 0) ? 4 : f4) : f4)}
                                    {(product_detail.prtrl_name ? ( (list_text_check_2.indexOf(product_detail.prtrl_name) >= 0) ? 5 : f5) : f5)}
                                    {(product_detail.safety_and_health_act_name ? ( (list_text_check_2.indexOf(product_detail.safety_and_health_act_name) >= 0) ? 6 : f6) : f6)  }
                         -->
                        <!--
                                        <li if={(
                                          (product_detail.hazadous_name ? ( (list_text_check_2.indexOf(product_detail.hazadous_name) >= 0) ? true : false) : false) &&
                                          (product_detail.poisonous_material_name ? ( (list_text_check_2.indexOf(product_detail.poisonous_material_name) >= 0) ? true : false) : false) &&
                                          (product_detail.poisonous_medicine_name ? ( (list_text_check_2.indexOf(product_detail.poisonous_medicine_name) >= 0) ? true : false) : false) &&
                                          (product_detail.medicine_name ? ( (list_text_check_2.indexOf(product_detail.medicine_name) >= 0) ? true : false) : false) &&
                                          (product_detail.animal_medicine_name ? ( (list_text_check_2.indexOf(product_detail.animal_medicine_name) >= 0) ? true : false) : false) &&
                                          (product_detail.specifical_medicine_name ? ( (list_text_check_2.indexOf(product_detail.specifical_medicine_name) >= 0) ? true : false) : false) &&
                                          (product_detail.medical_equipmentl_name ? ( (list_text_check_2.indexOf(product_detail.medical_equipmentl_name) >= 0) ? true : false) : false) &&
                                          (product_detail.psychotropic_drug_name ? ( (list_text_check_2.indexOf(product_detail.psychotropic_drug_name) >= 0) ? true : false) : false) &&
                                          (product_detail.stimulant_drug_material_name ? ( (list_text_check_2.indexOf(product_detail.stimulant_drug_material_name) >= 0) ? true : false) : false) &&
                                          (product_detail.duty_free_alcohol_name ? ( (list_text_check_2.indexOf(product_detail.duty_free_alcohol_name) >= 0) ? true : false) : false) &&
                                          (product_detail.cartagenal_name ? ( (list_text_check_2.indexOf(product_detail.cartagenal_name) >= 0) ? true : false) : false) &&
                                          (product_detail.prtrl_name ? ( (list_text_check_2.indexOf(product_detail.prtrl_name) >= 0) ? true : false) : false) &&
                                          (product_detail.cscll_name ? ( (list_text_check_2.indexOf(product_detail.cscll_name) >= 0) ? true : false) : false) &&
                                          (product_detail.international_controlled_substance_name ? ( (list_text_check_2.indexOf(product_detail.international_controlled_substance_name) >= 0) ? true : false) : false) &&
                                          (product_detail.ozone_protect_name ? ( (list_text_check_2.indexOf(product_detail.ozone_protect_name) >= 0) ? true : false) : false) &&
                                          (product_detail.chemical_weapon_name ? ( (list_text_check_2.indexOf(product_detail.chemical_weapon_name) >= 0) ? true : false) : false) &&
                                          (product_detail.safety_and_health_act_name ? ( (list_text_check_2.indexOf(product_detail.safety_and_health_act_name) >= 0) ? true : false) : false) &&
                                          (product_detail.sds_name ? ( (list_text_check_2.indexOf(product_detail.sds_name) >= 0) ? true : false) : false) &&
                                          (product_detail.radiation_hazard_prevention_name ? ( (list_text_check_2.indexOf(product_detail.radiation_hazard_prevention_name) >= 0) ? true : false) : false)
                                          (product_detail.water_pollution_control_name ? ( (list_text_check_2.indexOf(product_detail.water_pollution_control_name) >= 0) ? true : false) : false)
                                          (product_detail.air_pollution_control_name ? ( (list_text_check_2.indexOf(product_detail.air_pollution_control_name) >= 0) ? true : false) : false)

                                        )}>非該当</li> -->
                        <li>____________</li>
                        <li>水質汚濁防止法:{product_detail.water_pollution_control_name ? product_detail.water_pollution_control_name : '情報なし'}</li>
                        <li>大気汚染防止法:{product_detail.air_pollution_control_name ? product_detail.air_pollution_control_name : '情報なし'}</li>
                    </div>

                    <div>{(!product_detail.hazadous_name && !product_detail.poisonous_material_name && !product_detail.poisonous_medicine_name && !product_detail.medicine_name && !product_detail.animal_medicine_name && !product_detail.specifical_medicine_name && !product_detail.medical_equipmentl_name && !product_detail.psychotropic_drug_name && !product_detail.stimulant_drug_material_name && !product_detail.stimulant_drug_material_name && !product_detail.cartagenal_name && !product_detail.prtrl_name && !product_detail.cscll_name && !product_detail.biological_origin_name && !product_detail.international_controlled_substance_name && !product_detail.ozone_protect_name && !product_detail.chemical_weapon_name && !product_detail.safety_and_health_act_name && !product_detail.sds_name && !product_detail.radiation_hazard_prevention_name && !product_detail.air_pollution_control_name && !product_detail.water_pollution_control_name && !product_detail.soil_contamination_name) ? '非該当' : ''}</div>
                    <div if={comment_for_regulations_text}>
                        <button class="popupform-comment-for-regulation-open" if={ comment_for_regulations_text != '未発注品' }>{comment_for_regulations_text}</button>
                        <span if={ comment_for_regulations_text == '未発注品' }>{comment_for_regulations_text}</span>
                    </div>
                    </td>
                    <td rowspan="4" colspan="3" if={!(arColumn(list_field, 'navigation_id', 'F007').length > 0)}>

                    <div if={!(!product_detail.hazadous_name && !product_detail.poisonous_material_name && !product_detail.poisonous_medicine_name && !product_detail.medicine_name && !product_detail.animal_medicine_name && !product_detail.specifical_medicine_name && !product_detail.medical_equipmentl_name && !product_detail.psychotropic_drug_name && !product_detail.stimulant_drug_material_name && !product_detail.stimulant_drug_material_name && !product_detail.cartagenal_name && !product_detail.prtrl_name && !product_detail.cscll_name && !product_detail.biological_origin_name && !product_detail.international_controlled_substance_name && !product_detail.ozone_protect_name && !product_detail.chemical_weapon_name && !product_detail.safety_and_health_act_name && !product_detail.sds_name && !product_detail.radiation_hazard_prevention_name && !product_detail.air_pollution_control_name && !product_detail.water_pollution_control_name && !product_detail.soil_contamination_name && !product_detail.comment_for_regulations)}>

                        <div>{(list_text_check_1.indexOf(product_detail.hazadous_name) >= 0) ? ''  : (product_detail.hazadous_name ? '危険物: ' + product_detail.hazadous_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.poisonous_material_name) >= 0) ? '' : (product_detail.poisonous_material_name ? '毒劇物: '+ product_detail.poisonous_material_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.poisonous_medicine_name) >= 0) ? '' : (product_detail.poisonous_medicine_name ? '毒劇薬: '+ product_detail.poisonous_medicine_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.medicine_name) >= 0) ? '' : (product_detail.medicine_name ? '医薬品: '+ product_detail.medicine_name : '') }</div>

                        <div>{(list_text_check_1.indexOf(product_detail.animal_medicine_name) >= 0) ? '' : (product_detail.animal_medicine_name ? '動物薬: '+ product_detail.animal_medicine_name : '') }</div>

                        <div>{(list_text_check_1.indexOf(product_detail.specifical_medicine_name) >= 0) ? ''  : (product_detail.specifical_medicine_name ? '指定薬物: '+ product_detail.specifical_medicine_name : '') }</div>

                        <div>{(list_text_check_1.indexOf(product_detail.medical_equipmentl_name) >= 0) ? '' : (product_detail.medical_equipmentl_name ? '医療機器: '+ product_detail.medical_equipmentl_name : '') }</div>

                        <div>{(list_text_check_1.indexOf(product_detail.psychotropic_drug_name) >= 0) ? '' : (product_detail.psychotropic_drug_name ? '麻薬・向精神薬: '+ product_detail.psychotropic_drug_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.stimulant_drug_material_name) >= 0) ? '' : (product_detail.stimulant_drug_material_name ? '覚せい剤原料: ' + product_detail.stimulant_drug_material_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.duty_free_alcohol_name) >= 0) ? '' : (product_detail.duty_free_alcohol_name ? '免税アルコール: ' + product_detail.duty_free_alcohol_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.cartagenal_name) >= 0) ? ''  : (product_detail.cartagenal_name ? 'カルタヘナ: '+ product_detail.cartagenal_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.prtrl_name) >= 0) ? '' : (product_detail.prtrl_name ? 'PRTR法: '+ product_detail.prtrl_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.cscll_name) >= 0) ? '' : (product_detail.cscll_name ? '化審法: '+ product_detail.cscll_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.international_controlled_substance_name) > 0) ? ''  : (product_detail.international_controlled_substance_name ? '国際規制物質: '+ product_detail.international_controlled_substance_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.ozone_protect_name) >= 0) ? ''  : (product_detail.ozone_protect_name ? 'オゾン層保護法: ' + product_detail.ozone_protect_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.chemical_weapon_name) >= 0) ? '' : (product_detail.chemical_weapon_name ? '化学兵器禁止法: '+ product_detail.chemical_weapon_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.safety_and_health_act_name) >= 0) ? '' : (product_detail.safety_and_health_act_name ? '労働安全衛生法: '+ product_detail.safety_and_health_act_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.sds_name) >= 0) ? '' : (product_detail.sds_name ? 'SDS該当区分: '+ product_detail.sds_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.radiation_hazard_prevention_name) >= 0) ? '' : (product_detail.radiation_hazard_prevention_name ? '放射線障害防止法: ' + product_detail.radiation_hazard_prevention_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.water_pollution_control_name) >= 0) ? '' : (product_detail.water_pollution_control_name ? '水質汚濁防止法: '+ product_detail.water_pollution_control_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.air_pollution_control_name) >= 0) ? '' : (product_detail.air_pollution_control_name ? '大気汚染防止法: '+ product_detail.air_pollution_control_name : '')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.biological_origin_name) >= 0) ? '' : (product_detail.biological_origin_name ? '生物由来製品: '+ product_detail.biological_origin_name : '情報なし')}</div>

                        <div>{(list_text_check_1.indexOf(product_detail.soil_contamination_name) >= 0) ? '' : (product_detail.soil_contamination_name ? '土壌汚染対策法: '+ product_detail.soil_contamination_name : '')}</div>

                        <div if={product_detail.supplier_comp_code != '20000057'}>{(list_text_check_1.indexOf(product_detail.comment_for_regulations) >= 0) ? '' : (product_detail.comment_for_regulations ? product_detail.comment_for_regulations : '')}</div>
                 

                    </div>
                    <div if={comment_for_regulations_text}>
                        <button class="popupform-comment-for-regulation-open" if={ comment_for_regulations != '未発注品' }>{comment_for_regulations_text}</button>
                        <span if={ comment_for_regulations == '未発注品' }>{comment_for_regulations_text}</span>
                    </div>
                    <div if={IWAI_SITE && overseas_goods_flag > 0}>
                        <p>当欄に表示がない製品も含め法規制情報は最新でない可能性があります。</p>
                        <p>再確認後、取扱い出来ない場合もございますが予めご了承ください。</p>
                    </div>
                    <!-- <div>{(!product_detail.hazadous_name && !product_detail.poisonous_material_name && !product_detail.poisonous_medicine_name && !product_detail.medicine_name && !product_detail.animal_medicine_name && !product_detail.specifical_medicine_name && !product_detail.medical_equipmentl_name && !product_detail.psychotropic_drug_name && !product_detail.stimulant_drug_material_name && !product_detail.stimulant_drug_material_name && !product_detail.cartagenal_name && !product_detail.prtrl_name && !product_detail.cscll_name && !product_detail.international_controlled_substance_name && !product_detail.ozone_protect_name && !product_detail.chemical_weapon_name && !product_detail.safety_and_health_act_name && !product_detail.sds_name && !product_detail.radiation_hazard_prevention_name && !product_detail.air_pollution_control_name && !product_detail.water_pollution_control_name) ? 'なし' : ''}</div> -->
                    </td>
                    <th>定価</th>
                    <!--  <td>{ !isNaN(parseInt(product_detail.list_price)) ? parseInt(product_detail.list_price).toLocaleString('en') + '円' : '' }</td> -->
                    <td class="right">
                       <div data-test="price_test_cafe" style="text-align: right;" if={campaign_retail_price_end_date(product_detail.campaign_retail_price,product_detail.campaign_start_date,product_detail.campaign_end_date,product_detail.campaign_published_date,product_detail.campaign_close_date).length > 0} >
                         <div style="display: { parseInt(product_detail.campaign_retail_price) >=1 ? 'block' : 'none' }">［キャンペーン中］</div>
                         <div style="border-top:0px; display: { parseInt(product_detail.campaign_retail_price) >=1 ? 'block' : 'none' }"><strike>{ !isNaN(parseInt(product_detail.list_price)) ? (product_detail.list_price == 0 || product_detail.all_hidden_price ? 'お見積り' : parseInt(product_detail.list_price).toLocaleString('en') + '円' ) : '' }</strike></div>
                         <div style="border-top:0px;"><b style="color: red">{ !isNaN(parseInt(product_detail.campaign_retail_price)) && (product_detail.campaign_retail_price != 0) && !product_detail.all_hidden_price ? ( parseInt(product_detail.campaign_retail_price).toLocaleString('en') + '円' ) : 'お見積り' }</b></div>
                         <div style="border-top:0px; display: { parseInt(product_detail.campaign_retail_price) >=1 ? 'block' : 'none' }" class="campaign_date_0">{ campaign_retail_price_end_date(product_detail.campaign_retail_price,product_detail.campaign_start_date,product_detail.campaign_end_date,product_detail.campaign_published_date,product_detail.campaign_close_date)}</div>
                       </div>
        
                       <div data-test="price_sale_test_cafe" if={!(campaign_retail_price_end_date(product_detail.campaign_retail_price,product_detail.campaign_start_date,product_detail.campaign_end_date,product_detail.campaign_published_date,product_detail.campaign_close_date).length > 0)} >{ !isNaN(parseInt(product_detail.list_price)) ? (product_detail.list_price == 0 || product_detail.all_hidden_price ? 'お見積り' : parseInt(product_detail.list_price).toLocaleString('en') + '円' ) : '' }</div>
                    </td>
                </tr>
                <tr>
                    <th>保存方法</th>
                    <td>{product_detail.storage_temperature}</td>
                </tr>
                <tr>
                    <th>製品データシート</th>
                    <td align="center"><a style="display: {product_detail.url2 ? 'block' : 'none'}" href="{product_detail.url2}" target="_blank">データシート</a></td>
                </tr>
                <tr>
                    <th>SDS情報</th>
                    <td align="center"><a style="display: {product_detail.sds_url ? 'block' : 'none'}" href="{product_detail.sds_url}" target="_blank">データシート</a></td>
                </tr>
                <tr>
                    <th>商品概要</th>
                    <td class="product-overview" colspan="5">
                        <div class="overview-text">{product_detail.product_overview}</div>
                    </td>
                </tr>
                <tr if={showInfoCampaign(product_detail, list_field, kikan_code) || (IWAI_SITE && product_detail.campaign_name && !product_detail.campaign_published_date && !product_detail.campaign_close_date && !product_detail.campaign_start_date && !product_detail.campaign_end_date)}>
                    <th>キャンペーン名</th>
                    <td colspan="5">
                        <a style="display: { product_detail.campaign_url ? 'block' : 'none' }" class="redirect_link_campaign" href="{product_detail.campaign_url ? product_detail.campaign_url : ''}" target="_blank">{product_detail.campaign_name}</a>
                        <p style="display: { !product_detail.campaign_url ? 'block' : 'none' }" class="redirect_link_campaign link_color">{product_detail.campaign_name}</p>
                    </td>
                </tr>
                <tr if={showInfoCampaign(product_detail, list_field, kikan_code) || (IWAI_SITE && product_detail.campaign_name && !product_detail.campaign_published_date && !product_detail.campaign_close_date && !product_detail.campaign_start_date && !product_detail.campaign_end_date)}>
                    <th>キャンペーン適用条件</th>
                    <td colspan="5">
                        <p>{product_detail.campaign_require}</p>
                    </td>
                </tr>
            </table>
            <div class="left" if={(!IWAI_SITE) || (IWAI_SITE && (product_detail.supplier_comp_code == '20000118' || product_detail.supplier_comp_code == '20000190'))} style="margin-top: 10px;">
                <a href={!IWAI_SITE ? 'https://support.bio-purchase.com/notice/' : 'https://www.iwai-chem.co.jp/products/iwec/#module-information'} target="_blank">✔ 掲載情報のご利用にあたって</a>
            </div>
            <table class="dealer-table">
                <thead>
                <tr>
                    <th class="table-title" colspan="9">販売店情報</th>
                </tr>
                <tr>
                    <td>販売店名</td>
                    <td>納入価格</td>
                    <td if={!checkVisibleTime('F014')}>標準納期</td>
                    <td if={!checkVisibleTime('F015')}>発注締め時間</td>
                    <td if={!checkVisibleTime('F016')}>販売店在庫</td>
                    <td if={!checkVisibleTime('F017')}>納期目安</td>
                    <td>数量</td>
                    <td style="min-width:110px;">商品購入</td>
                </tr>
                </thead>
                <tbody>
                <tr each = { element, index in products_dealer_customers_list }>
                    <td>{ element.dealer_co_name + ' ' + element.dealer_dep_name }</td>
                    <td class="right">
                        <!--  <div>
                           { !isNaN(parseInt(element.selling_tanka)) ? ((element.list_price == element.selling_tanka) ? 'お見積り' : Math.round(element.selling_tanka).toLocaleString('en') + '円' )  : '' }
                           <input type="hidden" id="selling_tanka_{index}" value="{element.selling_tanka}">
                         </div>
                         <div>
                           <div style="border-top:0px;">
                             <b style="color:red">
                               { campaign_retail_price_end_date(product_detail.campaign_retail_price,product_detail.campaign_start_date,product_detail.campaign_end_date)}
                             </b>
                         </div> -->

                        <div data-test="price_sale_test_cafe" if={campaign_retail_price_end_date(product_detail.campaign_retail_price,product_detail.campaign_start_date,product_detail.campaign_end_date,product_detail.campaign_published_date,product_detail.campaign_close_date).length > 0} >
                         <!--  <div style="display: { parseInt(product_detail.campaign_retail_price) >=1 ? 'block' : 'none' }">［キャンペーン中］</div>
                          <div style="border-top:0px; display: { parseInt(product_detail.campaign_retail_price) >=1 ? 'block' : 'none' }"><strike>{ !isNaN(parseInt(product_detail.list_price)) ? (product_detail.list_price == 0 ? 'お見積り' : parseInt(product_detail.list_price).toLocaleString('en') + '円' ) : '' }</strike></div>
                          <div style="border-top:0px; display: { parseInt(product_detail.campaign_retail_price) >=1 ? 'block' : 'none' }"><b style="color: red">{ !isNaN(parseInt(element.selling_tanka)) ? ((product_detail.list_price == element.selling_tanka) ? 'お見積り' : parseInt(element.selling_tanka).toLocaleString('en') + '円' ) : '' }</b></div>
                          <div style="border-top:0px; display: { isNaN(parseInt(product_detail.campaign_retail_price)) || parseInt(product_detail.campaign_retail_price) < 1 ? 'block' : 'none' }">{ !isNaN(parseInt(element.selling_tanka)) ? ((product_detail.list_price == element.selling_tanka) ? 'お見積り' : parseInt(element.selling_tanka).toLocaleString('en') + '円' ) : '' }</div>
                          <div style="border-top:0px; display: { parseInt(product_detail.campaign_retail_price) >=1 ? 'block' : 'none' }" class="campaign_date_{index}">{ campaign_retail_price_end_date(product_detail.campaign_retail_price,product_detail.campaign_start_date,product_detail.campaign_end_date,product_detail.campaign_published_date,product_detail.campaign_close_date)}</div> -->
                          <div style="border-top:0px; display: { parseInt(product_detail.campaign_retail_price) >=1 ? 'block' : 'none' }">{ (!isNaN(parseInt(element.selling_tanka)) && (element.selling_tanka != 0)) ? ( parseInt(element.selling_tanka).toLocaleString('en') + '円' ) : 'お見積り' }</div>
                          <!--<div style="border-top:0px; display: { parseInt(product_detail.campaign_retail_price) >=1 ? 'block' : 'none' }">{ !isNaN(parseInt(element.selling_tanka)) ? ((product_detail.list_price == element.selling_tanka) ? 'お見積り' : parseInt(element.selling_tanka).toLocaleString('en') + '円' ) : '' }</div>-->
                        </div>
        
                        <div data-test="price_sale_test_cafe" if={!(campaign_retail_price_end_date(product_detail.campaign_retail_price,product_detail.campaign_start_date,product_detail.campaign_end_date,product_detail.campaign_published_date,product_detail.campaign_close_date).length > 0)} >{ (!isNaN(parseInt(element.selling_tanka)) && (element.selling_tanka != 0)) ? ( parseInt(element.selling_tanka).toLocaleString('en') + '円' ) : 'お見積り' }</div>

                    </td>
                    <td if={!checkVisibleTime('F014')}>{ !checkVisibleTime('F014') ? element.standard_delivery_time : '' }</td>
                    <td if={!checkVisibleTime('F015')}>{ !checkVisibleTime('F015') ? element.closing_time : '' }</td>
                    <td if={!IWAI_SITE && !checkVisibleTime('F016')}><div class="img-loader-F loading_F016" style="display: none">&nbsp;</div><span class="timeout-text" if={element.souko_zaiko_su_text == 'タイムアウト'}>{ element.souko_zaiko_su_text }</span><span if={element.souko_zaiko_su_text != 'タイムアウト'}>{ element.souko_zaiko_su_text }<p if={element.souko_zaiko_su_updated}>({element.souko_zaiko_su_updated}現在)</p></span></td>
                    <td if={!IWAI_SITE && !checkVisibleTime('F017')} style="text-align: center;"><div class="img-loader-F loading_F017" style="display: none">&nbsp;</div><button class="popupform-oversea-open" if={ checkOverSea && checkOverSea != 'タイムアウト' && ( souko_zaiko_su === 0 || souko_zaiko_su === '0' || souko_zaiko_su === '' )}>{ checkOverSea } </button><span if={ checkOverSea && checkOverSea != 'タイムアウト' && souko_zaiko_su !== 0 && souko_zaiko_su !== '0' && souko_zaiko_su !== ''}>{checkOverSea}</span><span class="timeout-text" if={checkOverSea == 'タイムアウト'}>{checkOverSea}</span></td>
                    <td if={IWAI_SITE && !checkVisibleTime('F016')}><div class="img-loader-F loading_F016" style="display: none">&nbsp;</div><span class="timeout-text" if={element.souko_zaiko_su_text == 'タイムアウト'}>{ element.souko_zaiko_su_text }</span><span if={element.souko_zaiko_su_text != 'タイムアウト'}>{ element.souko_zaiko_su_text }
                    <p if={element.souko_zaiko_su_updated}>({element.souko_zaiko_su_updated}現在)</p></span></td>
                    <td if={IWAI_SITE && !checkVisibleTime('F017')} style="text-align: center;"><div class="img-loader-F loading_F017" style="display: none">&nbsp;</div><button class="popupform-oversea-open" if={ element.over_sea_text && element.over_sea_text != 'タイムアウト' && ( souko_zaiko_su === 0 || souko_zaiko_su === '0' || souko_zaiko_su === '' )}>{ element.over_sea_text } </button><span if={ element.over_sea_text && element.over_sea_text != 'タイムアウト' && souko_zaiko_su !== 0 && souko_zaiko_su !== '0' && souko_zaiko_su !== ''}>{element.over_sea_text}</span><span class="timeout-text" if={element.over_sea_text == 'タイムアウト'}>{element.over_sea_text}</span></td>

                    <td align="center"><input type="number" min="1" class="order-input spinner" value="1" id="{ 'quantity' + index }" maxlength="10" oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"></td>
                    <td class="btn-td {element.disable_add_cart ? 'disable_add_cart' : ''}" style="display: {member_authority != 5 ? 'block' : 'none'}" {element.disable_add_cart ? 'disabled' : ''}>
                        <button type="button" class="color-btn red-btn" style="display: { arColumn(list_button, 'navigation_id', 'B002').length ?  'inline' : 'none' ? 'inline' : 'none' };margin:{checkRetailPrice ? '23.5px 0' : '13.5px 0'}" onclick="{ addToCart }" value="{ index }" if={(!isNaN(parseInt(element.selling_tanka)) && (element.selling_tanka != 0) && !element.disable_add_cart && ((checkCampaign && !checkCampaignRetailPrice) || !(checkCampaign)) )}><i class="fa fa-shopping-cart" aria-hidden="true"></i>{ arColumn(list_button, 'navigation_id', 'B002').length ? arColumn(list_button, 'navigation_id', 'B002')[0]['display_contents']  : '' }</button>
                        <button type="button" class="color-btn gray-btn tooltips" style="display: { arColumn(list_button, 'navigation_id', 'B002').length ?  'inline' : 'none' ? 'inline' : 'none' };margin:{checkRetailPrice ? '23.5px 0' : '13.5px 0'}" value="{ index }" if={(isNaN(parseInt(element.selling_tanka)) || (element.selling_tanka == 0) || (checkCampaign && checkCampaignRetailPrice) ) && !element.disable_add_cart} disabled data-tooltip="カートはご利用いただけません。「見積依頼へ」へお進みください。"><i class="fa fa-shopping-cart" aria-hidden="true"></i>{ arColumn(list_button, 'navigation_id', 'B002').length ? arColumn(list_button, 'navigation_id', 'B002')[0]['display_contents']  : '' }</button>
                        <button readonly if={element.disable_add_cart} data-toggle="tooltip" data-container="body" data-html="true" title="他の販売店の商品が既にカートに入っています。<br>他の販売店の商品をチェックアウト後カートに入れることが可能です。" type="button" class="color-btn btn-disabled" style="display: { arColumn(list_button, 'navigation_id', 'B002').length ?  'inline' : 'none' ? 'inline' : 'none' };margin:{checkRetailPrice ? '23.5px 0' : '13.5px 0'}" value="{ index }"><i class="fa fa-shopping-cart" aria-hidden="true" value="{ index }"></i>{ arColumn(list_button, 'navigation_id', 'B002').length ? arColumn(list_button, 'navigation_id', 'B002')[0]['display_contents']  : '' }</button>
                        <button type="button" class="color-btn green-btn" style="display: { arColumn(list_button, 'navigation_id', 'B003').length ? 'inline' : 'none'};margin:{checkRetailPrice ? '23.5px 0' : '13.5px 0'}" onclick="{ addMitsumori }" value="{ index }"><i class="fa fa-arrow-right"></i>{ arColumn(list_button, 'navigation_id', 'B003').length ? arColumn(list_button, 'navigation_id', 'B003')[0]['display_contents']  : '' }</button>
                    </td>
                    <td style="min-width:110px;" if={ member_authority == 5 && products_dealer_customers_list.length && products_dealer_customers_list[0].dealer_tanto_email }>ご購入・お見積りには本サイトへの登録が必要です。 <br>お問合せ先：<a href="javascript:void()" onclick="{ sendMail }">{ products_dealer_customers_list[0].dealer_tanto_email }</a></td>
                    <td style="min-width:110px;" if={ member_authority == 5 && products_dealer_customers_list.length && !products_dealer_customers_list[0].dealer_tanto_email}>
                        現在このサイトから商品の購入はできません。
                    </td>
                    <td if={ !member_authority == 5 && !products_dealer_customers_list.length }></td>
                </tr>
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="8" style="text-align: right;border:none">
                        <!-- <div class="wrapper-link-search-back">
                          <a href="#search/simple" class="link-search-back">商品検索画面に戻る</a>
                        </div> -->
                    </td>
                </tr>
                </tfoot>
            </table>
            <div class="modal-wrapper">
                <div class="o_modal" id="login-popupform" style="display:none">
                    <div class="o_modal_box">
                        <div class="o_modal_head">
                            <a id="login-popupform-Close" onclick="{ 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>
                        </div>
                    </div>
                </div>
            </div>

            <div class="modal-wrapper">
                <div class="o_modal" id="popupform-oversea" style="display:none">
                    <div class="o_modal_box">
                        <div class="o_modal_head">
                            <a id="popupform-oversea-close-link"><i class="fa fa-times"></i></a>
                        </div>
                        <div class="o_modal_body">
                            <div class="o_modal_main">
                                <h3 class="modal-title">納期注意事項</h3>
                                <p>※納期目安は確実な納期ではありません。</p>
                                　               <p>詳細な納期はお問い合わせ願います。</p>
                                <br />
                                <p>※国内外ともに在庫無しの場合は納期目安表示の対象外となります。</p>
                                <!-- <p style="text-align: right;"><button id="popupform-oversea-close-button">閉じる</button></p> -->
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="modal-wrapper">
                <div class="o_modal" id="popupform-comment-for-regulation" style="display:none">
                    <div class="o_modal_box">
                        <div class="o_modal_head">
                            <a id="popupform-comment-for-regulation-close-link"><i class="fa fa-times"></i></a>
                        </div>
                        <div class="o_modal_body">
                            <div class="o_modal_main">
                                <h3 class="modal-title">法規情報について</h3>
                                <table class="table table-striped">
                                    <thead>
                                    <tr>
                                        <th><b>法規情報 表記</b></th>
                                        <th><b>内容</b></th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr>
                                        <td>毒</td>
                                        <td>医薬用外毒物</td>
                                    </tr>
                                    <tr>
                                        <td>劇 </td>
                                        <td>医薬用外劇物</td>
                                    </tr>
                                    <tr>
                                        <td>労 </td>
                                        <td>
                                            <p>労働安全衛生法57条第１項 表示対象物質</p>
                                            <p>労働安全衛生法57条2　　　通知対象物質</p>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>原 </td>
                                        <td>特定麻薬向精神薬原料</td>
                                    </tr>
                                    <tr>
                                        <td>PR </td>
                                        <td>化学物質排出把握管理促進法（ＰＲＴＲ法）指定化学物質</td>
                                    </tr>
                                    <tr>
                                        <td>カ </td>
                                        <td>カルタヘナ法対象物質</td>
                                    </tr>
                                    <tr>
                                        <td>危 </td>
                                        <td>消防法危険物</td>
                                    </tr>
                                    <tr>
                                        <td>危◯△ </td>
                                        <td>危険物第◯類第△石油類　（◯△=数値） </td>
                                    </tr>
                                    <tr>
                                        <td>危４ア </td>
                                        <td>危険物第４類アルコール類</td>
                                    </tr>
                                    <tr>
                                        <td>危４特 </td>
                                        <td>危険物第４類特殊引火物</td>
                                    </tr>
                                    <tr>
                                        <td>危４油 </td>
                                        <td>危険物第４類動植物油類</td>
                                    </tr>
                                    </tbody>
                                </table>
                                <p>凡例）カ労危４ア：　「カルタヘナ法、安衛法通知対象物質、危険物第４類アルコール類　に該当」</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- <div class="login-form" style="display:none">

            </div> -->
            <script>
                this.IWAI_SITE = IWAI_SITE;
                var user_info = JSON.parse(getItem('EcUserInfo'));
                this.product_id = opts.result['product_id'];
                this.list_button = user_info.list_navigation.B;
                this.list_field = user_info.list_navigation.F;
                this.kikan_code = user_info.kikan_code;
                this.member_authority = user_info.member_authority;
                this.product_detail = opts.result['product_detail'][0];
                this.supplier_comp_code = opts.result['product_detail'][0]['supplier_comp_code'];
                this.souko_zaiko_su = opts.result['souko_zaiko_su'];
                this.products_dealer_customers_list = opts.result['products_dealer_customers_list'];
                this.email = this.products_dealer_customers_list.length > 0 ? this.products_dealer_customers_list[0].dealer_tanto_email : '';
                this.list_text_check_1 = ['非消防法危険物 又は未チェック', '非該当', '対象外', '情報なし', '未確認', '未設定', ''];
                this.list_text_check_2 = ['非消防法危険物 又は未チェック', '非該当', '対象外'];
                this.permission = '';
                this.comment_for_regulations = opts.result['product_detail'][0]['comment_for_regulations'];
                this.comment_for_regulations_text = '';
                this.overseas_goods_flag = '';
                this.souko_zaiko_su = '';
                this.souko_zaiko_su_text = '';
                this.souko_zaiko_su_updated = '';
                this.checkOverSea = '';
                this.checkCampaign = campaign_retail_price_end_date(this.product_detail.campaign_retail_price,this.product_detail.campaign_start_date,this.product_detail.campaign_end_date,this.product_detail.campaign_published_date,this.product_detail.campaign_close_date).length > 0;
                this.checkCampaignRetailPrice = isNaN(parseInt(this.product_detail.campaign_retail_price)) || parseInt(this.product_detail.campaign_retail_price) < 1;
                var thisTag = this;
                // ES old
                this.checkRetailPrice = campaign_retail_price(thisTag.product_detail['campaign_retail_price'],thisTag.product_detail['campaign_start_date'],thisTag.product_detail['campaign_end_date']) != '' ? true : false;
                // ES BRP
                // this.checkRetailPrice = campaign_retail_price(thisTag.product_detail['campaign_suggest_delivery_price'],thisTag.product_detail['campaign_start'],thisTag.product_detail['campaign_end']) != '' ? true : false;
                var product_detail_global = opts.result['product_detail'][0];
                var products_dealer_customers_list_global = opts.result['products_dealer_customers_list'];
                this.on("mount", function(){
                    if(IWAI_SITE) {
                        var cas_no = 'CAS番号';
                        if((arColumn(thisTag.list_field, 'navigation_id', 'F019').length > 0) && arColumn(thisTag.list_field, 'navigation_id', 'F019')[0].display_status == 'Y'){
                          cas_no = 'CAS RN<sup>&reg;</sup>';
                        }
                        $('.cas_no').html(cas_no);
                    }
                    $.each(thisTag.products_dealer_customers_list, function(i, e){
                        var campaign_date = $(".campaign_date_"+i).html() ? $(".campaign_date_"+i).html().split("|") : '';
                        var campaign_start_date = campaign_date[0] ? campaign_date[0] + '～<br>' : '';
                        var campaign_end_date = campaign_date[1] ? campaign_date[1] + 'まで' : '';
                        $(".campaign_date_" + i).html(campaign_start_date + "" + campaign_end_date);
                    })
                });
                function countTotalCart(){
                    var accessTokenCognito = localStorage.getItem('accessTokenCognito');
                    var url = URL_API + '/api/cart/count-total-cart-for-punchout';
                    var query = [];
                    query.push('token=' +accessTokenCognito);
                    url += '?' + query.join('&');
                    fetch(url)
                    .then(response => response.json())
                    .then(json => totalCart(json))
                }
                function totalCart(totalItem){
                      if(totalItem.total==0){
                        $(".cart-quantity").css('color','#444'); 
                        $(".cart-quantity").css('background','#EFEDE5');
                      }else{
                        $(".cart-quantity").css('color','#fff'); 
                        $(".cart-quantity").css('background','#dc3545');
                      }
                      if(totalItem.total>9){
                        $(".cart-quantity").css('font-size','10px'); 
                        $(".cart-quantity").css('padding','10px 8px'); 
                      }
                      if(totalItem.total>100){
                        $(".cart-quantity").css('padding','12px 8px'); 
                        $(".cart-quantity").css('margin','-18px 24px 0px 0px'); 
                      }
                      $(".cart-quantity").html(totalItem.total); 
                }
                $(function(){
                    $("[data-toggle=tooltip]").tooltip();
                    if(IWAI_SITE) {
                      $(".redirect_link_campaign").click(function(e) {
                        if(!$(e.target).attr('href')){
                          e.preventDefault();
                        }
                      });
                    }
                    thisTag.buttonViewMore();
                    popupFormOverSea();
                    var spinner = $( ".spinner" ).spinner();
                    $('.openEc41').on('click', function () {
                        var index = $(this).attr('index');
                        if ($('#check_cart_delivery_' + index).val() == 0) {
                            var suryo = $('#quantity' + index).val();
                            var accessTokenCognito = getItem('accessTokenCognito');
                            var url = URL_API + '/api/punchout/cart/create?token=' + accessTokenCognito;
                            var data = [];
                            var item_name = product_detail_global.name_jp;
                            if(product_detail_global.name_jp != '' && product_detail_global.name != ''){
                                item_name = product_detail_global.name;
                            }
                            data.push({
                                'supp_sku': product_detail_global.supplier_sku,
                                'item_name': item_name,
                                'item_sku': product_detail_global.sku,
                                'capacity': product_detail_global.volume_unit_label,
                                'kikaku': product_detail_global.class_name_jp,
                                'teika_tanka': product_detail_global.list_price,
                                'maker_name': product_detail_global.maker_name,
                                'supp_co_cd': product_detail_global.supplier_comp_code,
                                'supp_co_name': product_detail_global.sales_origin_maker_name,
                                'dealer_co_cd': products_dealer_customers_list_global[index].dealer_co_cd,
                                'tanka' : products_dealer_customers_list_global[index].selling_tanka,
                                'suryo' : suryo,
                                'status': 2
                            });
                            $.ajax({
                                url: url,
                                type: 'POST',
                                timeout: 20000,
                                data: {
                                    data: data
                                },
                                success: function (res) {
                                    if(res.status == 100){
                                        riot.mount('app','maintain',{ messege:res.messege });
                                        return false;
                                    }
                                    if(data.status == 'not_authorize'){
                                        var url = "#";
                                        $(location).attr("href", url );
                                        return false;
                                    }
                                    var cart = res.listCart[0];
                                    $('#cart_seq_' + index).val(cart.cart_seq);
                                    $('#quantity_' + index).text(cart.suryo);
                                    $('#check_cart_delivery_' + index).val(1);
                                    $('#ec41_' + index).fadeIn();
                                },
                                error: function (xhr, stt, err) {
                                    alert('エラー');
                                }
                            });
                        } else {
                            $('#ec41_' + index).fadeIn();
                        }
                    });
                    $(document).on('click','.closeEc41', function() {
                        var index = $(this).attr('index');
                        $('#check_cart_delivery_' + index).val(0);
                        $('#deliverydate_'+index).val('');
                        $('#comment_spp_'+index).val('');
                        $('#ec41_' + index).fadeOut();
                    });
                    $( ".order-input" ).spinner({
                        stop: function( event, ui ) {
                            var quantity = event.target.id;
                            var order_input = $("#"+ quantity).val();
                            if(order_input != ''){
                                if(order_input <= 0){
                                    alert('0以上の正数を入力してください。');
                                    $('#' + quantity).val('1');
                                }
                                $(".pdf-tab-view").attr('href','#view-pdf/'+thisTag.product_id+'/' + order_input);
                            } else {
                                $(".pdf-tab-view").attr('href','#view-pdf/'+thisTag.product_id+'/0');
                            }
                        }
                    });
                    checkVisibleCommentForRegulations();
                    checkPermission();
                    callOwlAndBrp();
                });

                callOwlAndBrp = function(e){
                    // window.setTimeout(function(){
                    var check_detail = arColumn(thisTag.list_field, 'navigation_id', 'F016');
                    if(!IWAI_SITE) {
                        getSoukoZaikoSu();
                    }
                    else {
                      if (check_detail.length > 0) {
                        if (check_detail[0].used_status != 'N' && check_detail[0].display_status != 'N') {
                          getSoukoZaikoSu();
                        }
                      }
                    }
                    // if (check_detail.length > 0) {
                    //   if (check_detail[0].used_status != 'N' && check_detail[0].display_status != 'N') {
                    // }
                    //}
                    // var check_detail = arColumn(thisTag.list_field, 'navigation_id', 'F017');
                    // if (check_detail.length > 0) {
                    //   if (check_detail[0].used_status != 'N' && check_detail[0].display_status != 'N') {
                    //      getOverseasBrp();
                    //     thisTag.checkOverSea = checkOverSea(thisTag.souko_zaiko_su, thisTag.overseas_goods_flag);
                    //     thisTag.update(thisTag.checkOverSea)
                    //     popupFormOverSea();
                    //   }
                    // }
                    // }, 1000);
                }

                getOverseasBrp = function(e){
                    var supplier_comp_code = thisTag.product_detail.supplier_comp_code;
                    var maker_name = thisTag.product_detail.maker_name;
                    var maker_code = thisTag.product_detail.maker_code;
                    var maker_brand = thisTag.product_detail.maker_brand;
                    var querySuggest = [];
                    var accessTokenCognito = getItem('accessTokenCognito');
                    querySuggest.push('token=' + accessTokenCognito);
                    if(supplier_comp_code){
                        querySuggest.push('supplier_comp_code=' + supplier_comp_code);
                    }
                    if(maker_brand){
                        querySuggest.push('maker_brand=' + encodeURIComponent(maker_brand));
                    }
                    if(maker_name){
                        querySuggest.push('maker_name=' + encodeURIComponent(maker_name));
                    }
                    if(maker_code){
                        querySuggest.push('maker_code=' + encodeURIComponent(maker_code));
                    }
                    var url = URL_API + '/api/get_single_manufacture';
                    url += '?' + querySuggest.join('&');
                    $.ajax({
                        url: url,
                        type: 'GET',
                        timeout: 20000,
                        // async:false,
                        beforeSend: function() {
                            $('#img-loader').hide();
                            $(".loading_F017").show();
                        },
                        afterSend: function() {
                            $(".loading_F017").hide();
                        },
                        success: function (data) {
                            if(data.status == 100){
                                riot.mount('app','maintain',{ messege:data.messege });
                                return false;
                            }
                            if(data.status == 'not_authorize'){
                                var url = "#";
                                $(location).attr("href", url );
                                return false;
                            }
                            if(data.message == 'success'){
                                var overseas_goods_flag = data.result.overseas_goods_flag;
                                thisTag.overseas_goods_flag = overseas_goods_flag;
                                thisTag.update(thisTag.overseas_goods_flag);
                                $.each(thisTag.products_dealer_customers_list, function(i, e){
                                    if((IWAI_SITE && e.souko_zaiko_su >= 0 && !checkEmpty(e.souko_zaiko_su)) || (!IWAI_SITE && e.souko_zaiko_su)){
                                        thisTag.products_dealer_customers_list[i]['over_sea_text'] = checkOverSea(e.souko_zaiko_su, thisTag.overseas_goods_flag)
                                    } else {
                                        thisTag.products_dealer_customers_list[i]['over_sea_text'] = 'タイムアウト';
                                    }
                                });
                                thisTag.update(thisTag.products_dealer_customers_list);
                                popupFormOverSea();
                            }
                            $(".loading_F017").hide();
                            if(data.message == 'error'){
                                thisTag.checkOverSea = 'タイムアウト';
                                thisTag.update(thisTag.checkOverSea);
                            }
                        },
                        error: function (xhr, stt, err) {
                            $(".loading_F017").hide();
                            thisTag.overseas_goods_flag = 'タイムアウト';
                            thisTag.update(thisTag.overseas_goods_flag);
                        }
                    });
                }
                updateSoukoZaikoSu = function(list_owl, param){
                    var result = {};
                    var list_result = [];
                    var max_souko = 0;
                    $.each(thisTag.products_dealer_customers_list, function(index_dealer_cus, value_dealer_cus){
                      if(list_owl.length == 0){
                        thisTag.products_dealer_customers_list[index_dealer_cus]['souko_zaiko_su_updated'] = '';
                        thisTag.products_dealer_customers_list[index_dealer_cus]['souko_zaiko_su_text'] = '取寄品';
                        thisTag.products_dealer_customers_list[index_dealer_cus]['souko_zaiko_su'] = '';
                      }
                      $.each(list_owl, function(i, e){
                        var souko_list = [];
                        if(!IWAI_SITE) {
                          $.each(param.list_dealer_cd, function(index_dealer_cd, dealer_cd){
                            var item = param.sku + "_" + dealer_cd;
                            if(i == item){
                              var souko_zaiko_su = parseInt(e.souko_zaiko_su);
                              var souko_zaiko_su_updated = e.updated;
                              if(value_dealer_cus.dealer_co_cd == dealer_cd){
                                thisTag.products_dealer_customers_list[index_dealer_cus]['souko_zaiko_su_updated'] = souko_zaiko_su_updated;
                                thisTag.products_dealer_customers_list[index_dealer_cus]['souko_zaiko_su_text'] = souko_zaiko_su ? (souko_zaiko_su >= 3 ? '3以上' : souko_zaiko_su)  : '取寄品';
                                thisTag.products_dealer_customers_list[index_dealer_cus]['souko_zaiko_su'] = souko_zaiko_su ;
                              }
                            } else {
                              thisTag.products_dealer_customers_list[index_dealer_cus]['souko_zaiko_su_updated'] = '';
                              thisTag.products_dealer_customers_list[index_dealer_cus]['souko_zaiko_su_text'] = '取寄品';
                              thisTag.products_dealer_customers_list[index_dealer_cus]['souko_zaiko_su'] = '';
                            }
                          });
                        }
                        else {
                          var item = param.sku + "_" + value_dealer_cus.dealer_co_cd;
                          if(i == item){
                            var souko_zaiko_su = e.souko_zaiko_su >= 0 && !checkEmpty(e.souko_zaiko_su) ? parseInt(e.souko_zaiko_su) : '';
                            var souko_zaiko_su_updated = e.updated;
                              thisTag.products_dealer_customers_list[index_dealer_cus]['souko_zaiko_su_updated'] = souko_zaiko_su_updated;
                              thisTag.products_dealer_customers_list[index_dealer_cus]['souko_zaiko_su_text'] = souko_zaiko_su >= 0 ? (souko_zaiko_su >= 3 ? '3以上' : souko_zaiko_su)  : '取寄品';
                              thisTag.products_dealer_customers_list[index_dealer_cus]['souko_zaiko_su'] = souko_zaiko_su ;
                            
                          } else {
                            thisTag.products_dealer_customers_list[index_dealer_cus]['souko_zaiko_su_updated'] = '';
                            thisTag.products_dealer_customers_list[index_dealer_cus]['souko_zaiko_su_text'] = '取寄品';
                            thisTag.products_dealer_customers_list[index_dealer_cus]['souko_zaiko_su'] = '';
                          }
                        }
                      });
                    }); 
                    thisTag.update(thisTag.products_dealer_customers_list);
                }
                getSoukoZaikoSu = function(e){
                    var querySuggest = [];
                    var sku = thisTag.product_detail.sku;
                    var products_dealer_customers_list = thisTag.products_dealer_customers_list;
                    var supplier_comp_code = thisTag.product_detail.supplier_comp_code;
                    var list_dealer_cd = [];
                    $.each(products_dealer_customers_list, function(i, e){
                        list_dealer_cd.push(e.dealer_co_cd);
                    });
                    var accessTokenCognito = getItem('accessTokenCognito');
                    querySuggest.push('token=' + accessTokenCognito);
                    querySuggest.push('sku=' + encodeURIComponent(sku));
                    querySuggest.push('list_dealer_cd=' + list_dealer_cd.join(","));
                    var url = URL_API + '/api/owl/get_souko_zaiko_su';
                    url += '?' + querySuggest.join('&');
                    $.ajax({
                        url: url,
                        type: 'GET',
                        timeout: 2000,
                        // async:false,
                        beforeSend: function() {
                            $('#img-loader').hide();
                            $(".loading_F016").show();
                        },
                        afterSend: function() {
                            $(".loading_F016").hide();
                        },
                        success: function (data) {
                            if(data.status == 100){
                                riot.mount('app','maintain',{ messege:data.messege });
                                return false;
                            }
                            if(data.status == 'not_authorize'){
                                var url = "#";
                                $(location).attr("href", url );
                                return false;
                            }
                            if(data.message == 'success'){
                                var list_souko = data.list_owl;
                                var param = {
                                    sku: sku,
                                    list_dealer_cd: list_dealer_cd
                                };
                                updateSoukoZaikoSu(list_souko, param);
                            }
                            $(".loading_F016").hide();
                            var check_detail = arColumn(thisTag.list_field, 'navigation_id', 'F017');
                            if (check_detail.length > 0) {
                                if (check_detail[0].used_status != 'N' && check_detail[0].display_status != 'N') {
                                    getOverseasBrp();
                                }
                            }
                        },
                        error: function (xhr, stt, err) {
                            $(".loading_F016").hide();
                            thisTag.checkOverSea = 'タイムアウト';
                            thisTag.update(thisTag.checkOverSea);
                            thisTag.souko_zaiko_su = 'タイムアウト';
                            thisTag.update(thisTag.souko_zaiko_su);
                        }
                    });
                }

                popupFormOverSea = function (){
                    $('.popupform-oversea-open').on('click',function(e){
                        $('#popupform-oversea').fadeIn();
                    });
                    $('#popupform-oversea-close-link').on('click',function(e){
                        $('#popupform-oversea').fadeOut();
                    });
                    $('#popupform-oversea-close-button').on('click',function(e){
                        $('#popupform-oversea').fadeOut();
                    });
                }
                popupFormCommentForRegulations = function(e){
                    $('.popupform-comment-for-regulation-open').on('click',function(e){
                        $('#popupform-comment-for-regulation').fadeIn();
                    });
                    $('#popupform-comment-for-regulation-close-link').on('click',function(e){
                        $('#popupform-comment-for-regulation').fadeOut();
                    });
                    $('#popupform-comment-for-regulation-close-button').on('click',function(e){
                        $('#popupform-comment-for-regulation').fadeOut();
                    });
                }
                checkVisibleTime = function (navigation_id) { // with navigation type F
                    var check_detail = arColumn(thisTag.list_field, 'navigation_id', navigation_id);
                    if (check_detail.length > 0) {
                        if (check_detail[0].used_status == 'N' || check_detail[0].display_status == 'N') {
                            return true;
                        }
                    }
                    return false;
                }
                checkOverSea = function (souko_zaiko_su, over_sea){
                    var text = 'タイムアウト';
                    if(!souko_zaiko_su || souko_zaiko_su === '0' || souko_zaiko_su === 0){
                        if(over_sea !== 0 && over_sea !== '0'){
                            text = "１０～１４営業日";
                        } else {
                            text = '２～５営業日';
                        }
                    } else {
                        if(over_sea === 0 || over_sea === '0'){
                            text = "１～３営業日";
                        } else {
                            text = '１～３営業日';
                        }
                    }
                    return text;
                }
                checkVisibleCommentForRegulations = function(e){
                    // thisTag.supplier_comp_code  = '20000057';
                    // thisTag.comment_for_regulations = '未発注品casc';
                    var comment_for_regulations = thisTag.comment_for_regulations;
                    var supplier_comp_code = thisTag.supplier_comp_code;
                    if(supplier_comp_code == '20000057' && comment_for_regulations){
                        if(comment_for_regulations == '未発注品'){
                            thisTag.comment_for_regulations_text = 'ご依頼をいただいた上で改めて法規制の確認をさせていただきますため、取り扱いができない場合がございますのでご留意ください。';
                        } else {
                            thisTag.comment_for_regulations_text = comment_for_regulations;
                        }
                    } else {
                        thisTag.comment_for_regulations_text = '';
                    }
                    thisTag.update(thisTag.comment_for_regulations_text);
                    popupFormCommentForRegulations();
                }
                this.buttonViewMore = function(e){
                    $(".view-more-mobile").click(function(){
                        var parent_item = $(this).parent('.items-label').parent('.items');
                        var items = parent_item.children(".items-content");
                        if(!items.hasClass("open-content")){
                            $(this).text('縮小');
                            items.addClass("open-content");
                        } else {
                            $(this).text('拡大');
                            items.removeClass("open-content");
                        }
                    });
                }

                checkPermission = function (e){

                    var accessTokenCognito = getItem('accessTokenCognito');
                    var url = URL_API + '/api/check_permission?token=' + accessTokenCognito;
                    $.ajax({
                        url: url,
                        type: 'GET',
                        timeout: 20000,
                        success: function (data) {
                            if(data.status == 100){
                                riot.mount('app','maintain',{ messege:data.messege });
                                return false;
                            }
                            if(data.status == 'not_authorize'){
                                var url = "#";
                                $(location).attr("href", url );
                                return false;
                            }
                            if(data.message == 'success'){
                                var member_authority = data.permission.member_authority;
                                thisTag.permission = member_authority;

                                thisTag.update(thisTag.permission);
                            }
                        },
                        error: function (xhr, stt, err) {
                            alert('エラー');
                        }
                    });
                }
                addToCart = function (e) {
                    var index = e.target.value;

                    var quantity = $('#quantity' + index).val();
                    var date = new Date();
                    var order_date = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
                    var accessTokenCognito = getItem('accessTokenCognito');
                    var url = URL_API + '/api/punchout/cart/create?token=' + accessTokenCognito + '&is_ariba=' + true;
                    var data = [];
                    var name = '';
                    var agent = getItem('agent_id');

                    if (this.product_detail['name_jp'] != '' && this.product_detail['name_jp'] != null) {
                        name = this.product_detail['name_jp'];
                    } else {
                        name = this.product_detail['name'];
                    }
                    if(quantity == '-'){
                        quantity = '';
                    }
                    data.push({
                        'supp_sku': this.product_detail.supplier_sku,
                        'item_name': name,
                        'item_sku': this.product_detail.sku,
                        'capacity': this.product_detail.volume_unit_label,
                        'kikaku': this.product_detail.class_name_jp,
                        // 'teika_tanka': this.product_detail.list_price,
                        'maker_name': this.product_detail.maker_name,
                        'supp_co_cd': this.product_detail.supplier_comp_code,
                        'supp_co_name': this.product_detail.sales_origin_maker_name,
                        'dealer_co_cd': this.products_dealer_customers_list[index].dealer_co_cd !== 'undefined' ? this.products_dealer_customers_list[index].dealer_co_cd : '',
                        'dealer_dep_cd': this.products_dealer_customers_list[index].dealer_dep_cd !== 'undefined' ? this.products_dealer_customers_list[index].dealer_dep_cd : '',
                        'tanka': $("#selling_tanka_" + index).val(),
                        'suryo': quantity,
                        'agent_users_id': agent,
                        //                'order_date': order_date,
                        'status': 0
                    });
                    $.ajax({
                        url: url,
                        type: 'POST',
                        timeout: 20000,
                        data: {
                            data: data,
                            screen: 'ec12'
                        },
                        success: function (data) {
                            countTotalCart();
                            if(data.status == 100){
                                riot.mount('app','maintain',{ messege:data.messege });
                                return false;
                            }
                            if(data.status == 'not_authorize'){
                                var url = "#";
                                $(location).attr("href", url );
                                return false;
                            }
                            // alert('カートに追加しました。');
                            //                    riot.route('/carts/cartlist');
                            if (data.message && data.errors) {
                                alert("処理が実行できませんでした。時間をおいて再度お試しください。同様のメッセージが再度出る場合はお手数ですがシステム提供者にご連絡ください。");
                            } else {
                                alert('カートに追加しました。\nカート画面から発注処理を行ってください。');
                                if (data.table && data.table == 'carts_po_budget') {

                                    $.each(thisTag.products_dealer_customers_list, function(i, e){
                                        if (e.dealer_co_cd != data.listCart[0].dealer_co_cd || e.dealer_dep_cd != data.listCart[0].dealer_dep_cd) {
                                            e.disable_add_cart = true;
                                        }
                                    })
                                    thisTag.update(thisTag.products_dealer_customers_list);
                                    $("[data-toggle=tooltip]").tooltip();
                                }
                            }
                        },
                        error: function (xhr, stt, err) {
                            alert('エラー');
                        }
                    });
                };
                deliveryDate = function (e) {
                    var index = e.target.value;
                    var car_seq = $('#cart_seq_' + index).val();
                    var suryo = $('#quantity_' + index).text();
                    var kakuko = $('.kakudo:checked').val();
                    var deliverydate = $('#deliverydate_'+index).val();
                    var comment_spp = $('#comment_spp_'+index).val();
                    var accessTokenCognito = getItem('accessTokenCognito');
                    var url = URL_API + '/api/punchout/cart/create?token=' + accessTokenCognito;
                    var agent = getItem('agent_id');
                    var data = [];
                    data.push({
                        'cart_seq': car_seq,
                        //                'suryo' : suryo,
                        'kakuko': kakuko,
                        'deliverydate': deliverydate,
                        'agent_users_id': agent,
                        'comment_spp': comment_spp
                    });
                    $.ajax({
                        url: url,
                        type: 'POST',
                        timeout: 20000,
                        data: {
                            data: data,
                            screen: 'ec12'
                        },
                        success: function (data) {
                            if(data.status == 100){
                                riot.mount('app','maintain',{ messege:data.messege });
                                return false;
                            }
                            if(data.status == 'not_authorize'){
                                var url = "#";
                                $(location).attr("href", url );
                                return false;
                            }
                            alert('納期照会に追加しました。');
                            //                    riot.route('/delivery/inquiries_list');
                        },
                        error: function (xhr, stt, err) {
                            alert('エラー');
                        }
                    });
                };
                addFavorite = function () {
                    var accessTokenCognito = getItem('accessTokenCognito');
                    var url = URL_API + '/api/punchout/cart/create?token=' + accessTokenCognito;
                    var agent = getItem('agent_id');
                    var data = [];
                    var name = '';
                    if (this.product_detail['name_jp'] != '' && this.product_detail['name_jp'] != null) {
                        name = this.product_detail['name_jp'];
                    } else {
                        name = this.product_detail['name'];
                    }
                    data.push({
                        'supp_sku': this.product_detail.supplier_sku,
                        'item_name': name,
                        'item_sku': this.product_detail.sku,
                        'capacity': this.product_detail.volume_unit_label,
                        'kikaku': this.product_detail.class_name_jp,
                        // 'teika_tanka': this.product_detail.list_price,
                        'agent_users_id': agent,
                        'maker_name': this.product_detail.maker_name,
                        'supp_co_cd': this.product_detail.supplier_comp_code,
                        'supp_co_name': this.product_detail.sales_origin_maker_name,
                        'price_group': this.product_detail.price_group,
                        'dealer_co_cd': this.products_dealer_customers_list[0] ? this.products_dealer_customers_list[0].dealer_co_cd : '',
                        'dealer_dep_cd': this.products_dealer_customers_list[0] ? this.products_dealer_customers_list[0].dealer_dep_cd : '',
                        'favorite_status': 1
                    });

                    $.ajax({
                        url: url,
                        type: 'POST',
                        timeout: 20000,
                        data: {
                            data: data,
                            screen: 'ec12'
                        },
                        success: function (data) {
                            if(data.status == 100){
                                riot.mount('app','maintain',{ messege:data.messege });
                                return false;
                            }
                            if(data.status == 'not_authorize'){
                                var url = "#";
                                $(location).attr("href", url );
                                return false;
                            }
                            if(data.message == 'success'){
                                alert('お気に入りリストに追加しました。');
                                return false;
                            }

                            if(data.message == 'errors'){
                                var errors = [];
                                $.each(data.errors,function(key,item){
                                    errors.push(item + '\n');
                                });

                                var err = errors.join('');
                                alert(err);
                                return false;
                            }
                            //                    riot.route('/carts/cartlist');
                        },
                        error: function (xhr, stt, err) {
                            alert('エラー');
                        }
                    });
                }
                addMitsumori = function (e) {
                    var index = e.target.value;
                    var quantity = $('#quantity' + index).val();
                    var accessTokenCognito = getItem('accessTokenCognito');
                    var url = URL_API + '/api/punchout/cart/create?token=' + accessTokenCognito;
                    var agent = getItem('agent_id');
                    var data = [];
                    var name = '';
                    if (this.product_detail['name_jp'] != '' && this.product_detail['name_jp'] != null) {
                        name = this.product_detail['name_jp'];
                    } else {
                        name = this.product_detail['name'];
                    }
                    data.push({
                        'supp_sku': this.product_detail.supplier_sku,
                        'item_name': name,
                        'agent_users_id': agent,
                        'item_sku': this.product_detail.sku,
                        'capacity': this.product_detail.volume_unit_label,
                        'kikaku': this.product_detail.class_name_jp,
                        'teika_tanka': this.product_detail.list_price,
                        'maker_name': this.product_detail.maker_name,
                        'supp_co_cd': this.product_detail.supplier_comp_code,
                        'supp_co_name': this.product_detail.sales_origin_maker_name,
                        'dealer_co_cd': this.products_dealer_customers_list[index].dealer_co_cd,
                        'dealer_dep_cd': this.products_dealer_customers_list[index].dealer_dep_cd,
                        'tanka': Math.round(this.products_dealer_customers_list[index].selling_tanka),
                        'suryo': quantity,
                        'mitsumori_status': 1,
                        'mitsumori_request_date': new Date().toJSON().slice(0,10).replace(/-/g,'-')
                    });

                    $.ajax({
                        url: url,
                        type: 'POST',
                        timeout: 20000,
                        data: {
                            data: data,
                            screen: 'ec12'
                        },
                        success: function (data) {
                            if(data.status == 100){
                                riot.mount('app','maintain',{ messege:data.messege });
                                return false;
                            }
                            if(data.status == 'not_authorize'){
                                var url = "#";
                                $(location).attr("href", url );
                                return false;
                            }
                            alert('見積フォルダに追加しました。\n見積フォルダから見積依頼処理を行ってください。');
                            //                    riot.route('/carts/cartlist');
                        },
                        error: function (xhr, stt, err) {
                            alert('エラー');
                        }
                    });
                }

                exportPdf = function() {

                    var orderInput = $(".order-input").val();
                    var windowheight = $( window ).height();
                    var accessTokenCognito = getItem('accessTokenCognito');
                    var url = URL_API + '/api/ec12PO/export_pdf?token=' + accessTokenCognito;
                    var data = [];
                    data.push({
                        'order_input': orderInput,
                        'products_dealer_customers_list': this.products_dealer_customers_list,
                        'product_detail': this.product_detail,
                    });
                    $.ajax({
                        url: url,
                        type: 'POST',
                        timeout: 20000,
                        data: {
                            data: data
                        },
                        success: function (data) {
                            if(data.status == 100){
                                riot.mount('app','maintain',{ messege:data.messege });
                                return false;
                            }
                            if(data.status == 'not_authorize'){
                                var url = "#";
                                $(location).attr("href", url );
                                return false;
                            }
                            // $('.pdf-tab-view').attr('href',data.pdf_url);
                            $('.pdf-tab-view').attr('href',data.pdf_url);
                            // $('.pdf-tab-view').trigger("click");
                            // $('.o_modal').css('display', 'block');
                            // $(".popup-pdf").html('<iframe style="overflow:hidden;" height="'+windowheight+'" width="100%" allowfullscreen scrolling="no" src="'+data.pdf_url+'" frameborder="0" allowfullscreen></iframe>');
                            document.getElementById("pdf-tab-view").click();
                            // $( ".pdf-tab-view" ).click();
                            //alert('見積依頼しました。');
                            //                    riot.route('/carts/cartlist');
                        },
                        error: function (xhr, stt, err) {
                            alert('エラー');
                        }
                    });

                }
                this.close = function(){
                    $('#S02-3').fadeOut();
                }

                sendMail = function() {
                    if(thisTag.products_dealer_customers_list[0].dealer_tanto_email){
                        window.location.href = "mailto:"+thisTag.email+"?subject=BPMサイト登録のお問合せ";
                    }
                }

            </script>
</description-po-punchout>

<search-result-punchout>
    <link if={IWAI_SITE} rel="stylesheet" type="text/css" href="css/popup.css?v=20190516">
    <div class="result-wrapper">
        <div class="total-number">
            <dl if={!IWAI_SITE} style="display:{total ? 'block' : 'none'}"></dl>
            <dl if={IWAI_SITE} class="size_small" style="display:{total_all ? 'block;margin: 10px 0px;' : 'none'}">
                <dt>検索件数</dt>
                <dd if={!IWAI_SITE} ><b>{ total }</b>件</dd>
                <dd if={IWAI_SITE} ><b>{ total_all }</b>件　</dd><span style="display:{total_all > 1000 ? 'inline; font-size:11px' : 'none'}">検索結果が1000件を超えた為、1000件まで表示</span>
            </dl>
        </div>
        <table class="blue-table">
            <thead if={results.length > 0}>
            <tr>
                <th>
                    <div>販売元品番</div> <!-- supplier_sku -->
                    <div>製造元品番</div> <!-- manufacturer_sku -->
                </th>
                <th style="width:40%">品名</th> <!-- name/name_jp -->
                <th>容量/<br/>規格</th> <!-- volume_unit_label/class_name_jp -->
                <th>法規情報</th>
                <th>定価</th> <!-- list_price -->
                <th>
                    <div>販売元</div> <!-- sales_origin_maker_name -->
                    <div>製造元/ブランド</div> <!-- maker_name/brand_name -->
                </th>
                <th>納入価格</th>
                <th if={IWAI_SITE} >納期目安</th>
                <th if={IWAI_SITE} >販売店在庫</th>
            </tr>
            </thead>
            <tbody>
            <tr each={item,index in results }>
                <td>
                    <div data-test="supplier_sku_test_cafe"><a target="{IWAI_SITE ? '_blank' : ''}" href={ '#search/basic_details-punchout/' + encodeURIComponent(item.sku)}>{ item.supplier_sku }</a></div>
                    <div>{ item.manufacturer_sku }</div>
                </td>
                <td class="name-td">
                    <div style="display:flex; justify-content:space-between;">
                        <section style="margin:10px;">
                            <p if="{!IWAI_SITE}">{ item.name }{(item.supplier_comp_code == SUPPLIER_COMP_CODE && item.msg4 !== MSG4 && item.msg4 !== '') ? '【' + item.msg4 + '】' : ''}</p>
                            <p if="{!IWAI_SITE}">{ item.name_jp == item.name ? '' : item.name_jp }</p>
                            <p if="{IWAI_SITE}">{ item.name_jp }</p> 
                            <ul style="text-align:left !important;" class="btnList">
                                <li class="d-block" if={showInfoCampaign(item, list_field, kikan_code) || (IWAI_SITE && item.campaign_name && !item.campaign_published_date && !item.campaign_close_date && !item.campaign_start_date && !item.campaign_end_date)}>
                                    <a if={item.campaign_url} href={item.campaign_url} target="_blank"><i class="fa fa-external-link-square"></i>{item.campaign_name}</a>
                                    <span if={!item.campaign_url} class="link_campaign">{item.campaign_name}</span>
                                </li>
                                <li><a href="{ item.url1 }" target="_blank" style="display:{item.url1 ? 'inline' : 'none'}"><i class="fa fa-external-link-square"></i>メーカー製品ページ</a></li>
                                <li if={item.supplier_comp_code=='20000488'}><a href="https://labchem-wako.fujifilm.com/jp/product/result/product.html?fw={item.supplier_sku}" target="_blank"><i class="fa fa-external-link-square"></i>メーカー製品ページ</a></li>
                                
                                <li if={!IWAI_SITE} ><a href="javascript:void(0)" onclick="{ searchCasCode }" cas_code="{ item.cas_code }" class="cas-code" style="display: {item.cas_code ? 'inline' : 'none'}">【CAS.No { item.cas_code } 検索】</a></li>
                                <li if={IWAI_SITE} ><a href="javascript:void(0)" onclick="{ searchCasCodeIwai }" cas_code="{ item.cas_code }" class="cas-code" style="display: {item.cas_code ? 'inline' : 'none'}">【CAS RN<sup>&reg;</sup> { item.cas_code } 検索】</a></li>
                            </ul>
                        </section>
                        <section style="margin:10px;" class="product-img" rowspan="4">
                            <a href="{item.photo_url}" target="_blank"><img src="{item.photo_url}" id="product_photo" style="max-height:100px;max-width:100px" if={item.photo_url}></a>
                        </section>
                    </div>
                </td>
                <td>{ item.volume_unit_label } { item.class_name_jp }</td>
                <td class="left">
                    <ul if={(arColumn(list_field, 'navigation_id', 'F007').length > 0) && arColumn(list_field, 'navigation_id', 'F007')[0].used_status == 'Y'}>
                    <li>{item.hazadous_name ? ( (list_text_check_2.indexOf(item.hazadous_name) >= 0) ? '' : '危険物(消防法): ' + item.hazadous_name) : '危険物(消防法): 情報なし'}</li>
                    <li>{item.poisonous_material_name ? ((list_text_check_2.indexOf(item.poisonous_material_name) >= 0) ? '' : '毒劇物(毒物及び劇物取締法): ' + item.poisonous_material_name) : '毒劇物(毒物及び劇物取締法): 情報なし'}</li>
                    <li>{item.psychotropic_drug_name ? ((list_text_check_2.indexOf(item.psychotropic_drug_name) >= 0) ? '' : '麻薬・向精神薬(麻薬および向精神薬取締法) ' + item.psychotropic_drug_name) : '麻薬・向精神薬(麻薬および向精神薬取締法) 情報なし'}</li>
                    <li>{item.cartagenal_name ? ((list_text_check_2.indexOf(item.cartagenal_name) >= 0) ? '' : 'カルタヘナ: ' + item.cartagenal_name) : 'カルタヘナ: 情報なし'}</li>
                    <li>{item.prtrl_name ? ((list_text_check_2.indexOf(item.prtrl_name) >= 0) ? '' : 'PRTR法: ' + item.prtrl_name) : 'PRTR法: 情報なし'}</li>
                    <li>{item.safety_and_health_act_name ? ((list_text_check_2.indexOf(item.safety_and_health_act_name) >= 0) ? '' : '労働安全衛生法: ' + item.safety_and_health_act_name) : '労働安全衛生法: 情報なし'}</li>
                    <li>{item.comment_for_regulations ? ((list_text_check_2.indexOf(item.comment_for_regulations) >= 0) ? '' : '' + item.comment_for_regulations) : ''}</li>
                    <li>{item.biological_origin_name ? ((list_text_check_2.indexOf(item.biological_origin_name) >= 0) ? '' : '生物由来製品: ' + item.biological_origin_name) : '生物由来製品: 情報なし'}</li>
                    <li>{item.soil_contamination_name ? ((list_text_check_2.indexOf(item.soil_contamination_name) >= 0) ? '' : '土壌汚染対策法: ' + item.soil_contamination_name) : '土壌汚染対策法: 情報なし'}</li>

                    <li if={(   (item.hazadous_name ? ( (list_text_check_2.indexOf(item.hazadous_name) >= 0) ? true : false) : false) &&
                        (item.poisonous_material_name ? ( (list_text_check_2.indexOf(item.poisonous_material_name) >= 0) ? true : false) : false) &&
                        (item.psychotropic_drug_name ? ( (list_text_check_2.indexOf(item.psychotropic_drug_name) >= 0) ? true : false) : false) &&
                        (item.cartagenal_name ? ( (list_text_check_2.indexOf(item.cartagenal_name) >= 0) ? true : false) : false) &&
                        (item.prtrl_name ? ( (list_text_check_2.indexOf(item.prtrl_name) >= 0) ? true : false) : false) &&
                        (item.biological_origin_name ? ( (list_text_check_2.indexOf(item.biological_origin_name) >= 0) ? true : false) : false) &&
                        (item.soil_contamination_name ? ( (list_text_check_2.indexOf(item.soil_contamination_name) >= 0) ? true : false) : false) && 
                        (item.safety_and_health_act_name ? ( (list_text_check_2.indexOf(item.safety_and_health_act_name) >= 0) ? true : false) : false) && 
                        (item.comment_for_regulations ? ( (list_text_check_2.indexOf(item.comment_for_regulations) >= 0) ? true : false) : false) )}>非該当</li>
                    <li>____________</li>
                    <li>水質汚濁防止法:{item.water_pollution_control_name ? item.water_pollution_control_name : '情報なし'}</li>
                    <li>大気汚染防止法:{item.air_pollution_control_name ? item.air_pollution_control_name : '情報なし'}</li>
                    </ul>
                    <ul if={!(arColumn(list_field, 'navigation_id', 'F007').length > 0)}>
                    <li>{(list_text_check_1.indexOf(item.hazadous_name) >= 0) ? '' : (item.hazadous_name ? '危険物: ' + item.hazadous_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.poisonous_material_name) >= 0) ? '' : (item.poisonous_material_name ? '毒劇物: ' + item.poisonous_material_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.poisonous_medicine_name) >= 0) ? '' : (item.poisonous_medicine_name ? '毒劇薬: ' + item.poisonous_medicine_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.medicine_name) >= 0) ? '' : (item.medicine_name ? '医薬品: ' + item.medicine_name : '') }</li>

                    <li>{(list_text_check_1.indexOf(item.animal_medicine_name) >= 0) ? '' : (item.animal_medicine_name ? '動物薬: ' + item.animal_medicine_name : '') }</li>

                    <li>{(list_text_check_1.indexOf(item.specifical_medicine_name) >= 0) ? '' : (item.specifical_medicine_name ? '指定薬物: ' + item.specifical_medicine_name : '') }</li>

                    <li>{(list_text_check_1.indexOf(item.medical_equipmentl_name) >= 0) ? '' : (item.medical_equipmentl_name ? '医療機器: ' + item.medical_equipmentl_name : '') }</li>

                    <li>{(list_text_check_1.indexOf(item.psychotropic_drug_name) >= 0) ? '' : (item.psychotropic_drug_name ? '麻薬・向精神薬: ' + item.psychotropic_drug_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.stimulant_drug_material_name) >= 0) ? '' : (item.stimulant_drug_material_name ? '覚せい剤原料: ' + item.stimulant_drug_material_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.duty_free_alcohol_name) >= 0) ? '' : (item.duty_free_alcohol_name ? '免税アルコール: ' + item.duty_free_alcohol_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.cartagenal_name) >= 0) ? '' : (item.cartagenal_name ? 'カルタヘナ: ' + item.cartagenal_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.prtrl_name) >= 0) ? '' : (item.prtrl_name ? 'PRTR法: ' + item.prtrl_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.cscll_name) >= 0) ? '' : (item.cscll_name ? '化審法: ' + item.cscll_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.international_controlled_substance_name) > 0) ? '' : (item.international_controlled_substance_name ? '国際規制物質: ' + item.international_controlled_substance_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.ozone_protect_name) >= 0) ? '' : (item.ozone_protect_name ? 'オゾン層保護法: ' + item.ozone_protect_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.chemical_weapon_name) >= 0) ? '' : (item.chemical_weapon_name ? '化学兵器禁止法: ' + item.chemical_weapon_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.safety_and_health_act_name) >= 0) ? ''  : (item.safety_and_health_act_name ? '労働安全衛生法: ' + item.safety_and_health_act_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.comment_for_regulations) >= 0) ? ''  : (item.comment_for_regulations ? '' + item.comment_for_regulations : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.sds_name) >= 0) ? '' : (item.sds_name ? 'SDS該当区分: ' + item.sds_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.radiation_hazard_prevention_name) >= 0) ? '' : (item.radiation_hazard_prevention_name ? '放射線障害防止法: ' + item.radiation_hazard_prevention_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.water_pollution_control_name) >= 0) ? '' : (item.water_pollution_control_name ? '水質汚濁防止法: ' + item.water_pollution_control_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.air_pollution_control_name) >= 0) ? '' : (item.air_pollution_control_name ? '大気汚染防止法: ' + item.air_pollution_control_name : '')}</li>

                    <li>{(list_text_check_1.indexOf(item.biological_origin_name) >= 0) ? '' : (item.biological_origin_name ? '生物由来製品: ' + item.biological_origin_name : '')}</li>
                  
                    <li>{(list_text_check_1.indexOf(item.soil_contamination_name) >= 0) ? '' : (item.soil_contamination_name ? '土壌汚染対策法: ' + item.soil_contamination_name : '')}</li>

                    <!-- <li>{(!item.hazadous_name && !item.poisonous_material_name && !item.poisonous_medicine_name && !item.medicine_name && !item.animal_medicine_name && !item.specifical_medicine_name && !item.medical_equipmentl_name && !item.psychotropic_drug_name && !item.stimulant_drug_material_name && !item.stimulant_drug_material_name && !item.cartagenal_name && !item.prtrl_name && !item.cscll_name && !item.international_controlled_substance_name && !item.ozone_protect_name && !item.chemical_weapon_name && !item.safety_and_health_act_name && !item.sds_name && !item.radiation_hazard_prevention_name && !item.air_pollution_control_name && !item.water_pollution_control_name) ? 'なし' : ''}</li> -->
                    </ul>
                    <div if={checkVisibleCommentForRegulations(item)}>
                        ____________
                        <br>
                        <span>{checkVisibleCommentForRegulations(item)}</span>
                    </div>
                </td>
                <td class="right" style="white-space:nowrap">
                <div>
                  <div data-test="price_sale_test_cafe" if={campaign_retail_price_end_date(item.campaign_retail_price,item.campaign_start_date,item.campaign_end_date,item.campaign_published_date,item.campaign_close_date).length > 0} >
                  <div>［キャンペーン中］</div>
                  <div style="display: block">
                    <div style="border-top:0px;"><strike>{ !isNaN(parseInt(item.list_price)) ? (item.list_price == 0 || item.all_hidden_price ? 'お見積り' : parseInt(item.list_price).toLocaleString('en') + '円' ) : '' }</strike></div>
                    <div style="border-top:0px;"><b style="color: red">{ !isNaN(parseInt(item.campaign_retail_price)) && (item.campaign_retail_price != 0) && !item.all_hidden_price ? ( parseInt(item.campaign_retail_price).toLocaleString('en') + '円' ) : 'お見積り' }</b></div>
                  </div>
                  <div style="border-top:0px; display: { isNaN(parseInt(item.campaign_retail_price)) || parseInt(item.campaign_retail_price) < 1 ? 'block' : 'none' }"><a href={ '#search/basic_details/' + encodeURIComponent(item.sku)} style="color:red;text-decoration: none">商品詳細ページへ</a></div>
                  <div style="border-top:0px;" class="campaign_date_{index}">{ campaign_retail_price_end_date(item.campaign_retail_price,item.campaign_start_date,item.campaign_end_date,item.campaign_published_date,item.campaign_close_date)}</div>
                  </div>
                  <div data-test="price_test_cafe" if={!(campaign_retail_price_end_date(item.campaign_retail_price,item.campaign_start_date,item.campaign_end_date,item.campaign_published_date,item.campaign_close_date).length > 0)}>{ !isNaN(parseInt(item.list_price)) ? (item.list_price == 0 || item.all_hidden_price ? 'お見積り' : parseInt(item.list_price).toLocaleString('en') + '円' ) : '' }</div>
                </div>

              </td>
                <td>
                    <div data-test="sales_origin_maker_name_test_cafe">{ item.sales_origin_maker_name }</div>
                    <div data-test="maker_name_test_cafe">{ !item.brand_name ? item.maker_name : (!item.maker_name ? item.brand_name : item.maker_name + '/' + item.brand_name) }</div>
                </td>
                <td class="right" style="white-space:nowrap">
                    <div data-test="price_sale_test_cafe" if={campaign_retail_price_end_date(item.campaign_retail_price,item.campaign_start_date,item.campaign_end_date,item.campaign_published_date,item.campaign_close_date).length > 0} >
                        <div>
                          <div style="display: block">
        
                           <div style="border-top:0px;">{ !isNaN(parseInt(item.min_price)) && (item.min_price != 0) ? ( parseInt(item.min_price).toLocaleString('en') + '円' ) : 'お見積り' }</div>
                         </div>
                         <div style="border-top:0px; display: { isNaN(parseInt(item.campaign_retail_price)) || parseInt(item.campaign_retail_price) < 1 ? 'block' : 'none' }"><a href={ '#search/basic_details/' + encodeURIComponent(item.sku)} style="color:red;text-decoration: none">商品詳細ページへ</a></div>
                        </div>
                     </div>
                    <div data-test="price_sale_test_cafe"  if={!(campaign_retail_price_end_date(item.campaign_retail_price,item.campaign_start_date,item.campaign_end_date,item.campaign_published_date,item.campaign_close_date).length > 0)} >{ !isNaN(parseInt(item.min_price)) && (item.min_price != 0) ? ( parseInt(item.min_price).toLocaleString('en') + '円' ) : 'お見積り' }</div>
                </td>
                <td if={IWAI_SITE} >
                <span if={item.over_sea_text != 'タイムアウト'}><button class="popupform-oversea-open" if={ item.over_sea_text && ( item.souko_zaiko_su === 0 || item.souko_zaiko_su === '0' || item.souko_zaiko_su === '' || item.souko_zaiko_su == null )  }>{ item.over_sea_text } </button></span>

                <span if={ item.over_sea_text && item.over_sea_text != 'タイムアウト' && item.souko_zaiko_su !== 0 && item.souko_zaiko_su !== '0' && item.souko_zaiko_su !== ''}>{item.over_sea_text}</span>
                <span class='timeout-text' if={item.over_sea_text == 'タイムアウト'}>タイムアウト</span>
              </td>
              <td if={IWAI_SITE} >
                <span if={item.souko_zaiko_su_text != 'タイムアウト'}>{item.souko_zaiko_su_text}</span>
                <span class='timeout-text' if={item.souko_zaiko_su_text == 'タイムアウト'}>タイムアウト</span>
              </td>
            </tr>
            </tbody>
        </table>
    </div>

    <div class="modal-wrapper">
        <div class="o_modal" id="price-list-modal">
            <div class="o_modal_box">
                <div class="o_modal_head">
                    <a id="price-list-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="price-list-box">
                            <p>{parseInt(price_list).toLocaleString('en')}</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="modal-wrapper">
        <div class="o_modal" id="popupform-oversea" style="display:none;">
          <div class="o_modal_box">
            <div class="o_modal_head">
              <a id="popupform-oversea-close-link"><i class="fa fa-times"></i></a>
            </div>
            <div class="o_modal_body">
              <div class="o_modal_main">
                <h3 class="modal-title">納期注意事項</h3>
                <p>※納期目安は確実な納期ではありません。</p>
　               <p>詳細な納期はお問い合わせ願います。</p>
                <br />
                <p>※国内外ともに在庫無しの場合は納期目安表示の対象外となります。</p>
                <!-- <p style="text-align: right;"><button id="popupform-oversea-close-button">閉じる</button></p> -->
              </div>
            </div>
          </div>
        </div>
    </div>

    <script>

        this.IWAI_SITE = IWAI_SITE;
        var user_info = JSON.parse(getItem('EcUserInfo'));
        this.kikan_code = user_info.kikan_code;
        this.results = opts.results;
        this.total = opts.total;
        if (IWAI_SITE) {
            this.total_all = opts.total_all;
        }
        this.price_list = [];
        var thisTag = this;
        var tag = opts.tag;
        this.list_field = user_info.list_navigation.F;
        this.list_text_check_1 = ['非消防法危険物 又は未チェック', '非該当', '対象外', '情報なし', '未確認', '未設定', ''];
        this.list_text_check_2 = ['非消防法危険物 又は未チェック', '非該当', '対象外'];
        this.SUPPLIER_COMP_CODE = SUPPLIER_COMP_CODE;
        this.MSG4 = MSG4;
        this.on("mount", function(){
            if (!IWAI_SITE) {
              this.max_date_updated = '';
            } else {
              thisTag.getManufacturerOwl(thisTag.results);
            }
            $.each(thisTag.results, function(i, e){
                var campaign_date = $(".campaign_date_"+i).html() ? $(".campaign_date_"+i).html().split("|") : '';
                var campaign_start_date = campaign_date[0] ? campaign_date[0] + '～<br>' : '';
                var campaign_end_date = campaign_date[1] ? campaign_date[1] + 'まで' : '';
                $(".campaign_date_" + i).html(campaign_start_date + "" + campaign_end_date);
            })
        });
        $(function(){
            $('.price_list_open').on('click',function(){
                $('#price-list-modal').fadeIn();
            });

            $('#price-list-close').on('click',function(){
                $('#price-list-modal').fadeOut();
            });
        });
        this.checkVisibleCommentForRegulations = function(e){
            var supplier_comp_code = e.supplier_comp_code;
            // var supplier_comp_code = '20000057';
            var comment_for_regulations = e.comment_for_regulations;
            // var comment_for_regulations = '未発注品';
            if( supplier_comp_code == '20000057' && comment_for_regulations){
                if(comment_for_regulations == '未発注品'){
                    return 'ご依頼をいただいた上で改めて法規制の確認をさせていただきますため、取り扱いができない場合がございますのでご留意ください。';
                } else {
                    return comment_for_regulations;
                }
            } else {
                return '';
            }
        }
        this.priceListOpen = function (e){
            console.log(e);
            var accessTokenCognito = getItem('accessTokenCognito');
            var url = URL_API + '/api/get_products_dealer_customers_list';
            var query = [];
            var dealer_co_cd = e.item.item.supplier_comp_code;
            var supp_co_cd = e.item.item.supplier_comp_code;
            var maker_name = e.item.item.maker_name;
            var item_sku = e.item.item.sku;
            var list_price = e.item.item.list_price;
            query.push('token=' + accessTokenCognito);
            query.push('dealer_co_cd=' + dealer_co_cd);
            query.push('list_price=' + list_price);
            query.push('item_sku=' + item_sku);
            query.push('maker_name=' + maker_name);
            query.push('supp_co_cd=' + supp_co_cd);
            url += '?' + query.join('&');
            $.ajax({
                url: url,
                type: 'GET',
                success: function (data) {
                    if(data.status == 100){
                        riot.mount('app','maintain',{ messege:data.messege });
                        return false;
                    }
                    thisTag.price_list = data.dealer_customer_list;
                    thisTag.update(thisTag.price_list);
                    $('#price-list-modal').fadeIn();
                },
                error: function (xhr, stt, error) {
                    alert('error');
                }
            });
        }
        this.searchCasCode = function (e) {
            var cas_code = e.target.getAttribute('cas_code') ? e.target.getAttribute('cas_code') : '9736a52d-0cf5-4aa5-81c8-82dc85f0c81c'; // fix when cas_code null
            if (tag == 'search/simple') {
                ec10_cas_code = cas_code;
                ec10_keyword = '';
                riot.mount('search');
            }
            if (tag == 'search/simple-po') {
                ec10_cas_code = cas_code;
                // ec10_keyword = '';
                riot.mount('search-po-punchout');
            }
            if  (tag == 'search/basic') {
                ec11_cas_code = cas_code;
                ec11_sales_origin_maker_name = '';
                ec11_maker_name = '';
                ec11_name_name_jp = '';
                ec11_supplier_manufacturer_sku = '';
                riot.mount('search-1');
            }
        }
        this.searchCasCodeIwai = function (e) {
            var cas_code = e.target.getAttribute('cas_code') ? e.target.getAttribute('cas_code') : '9736a52d-0cf5-4aa5-81c8-82dc85f0c81c'; // fix when cas_code null
            if (tag == 'search/simple-po') {
                ec10_cas_code = cas_code;
                ec10_keyword = '';
                riot.mount('search-po-punchout-iwai');
            }
        }
        function campaign_retail_price(price,start,end){
            console.log(price);
            console.log(start);
            console.log(end);
            var start_date = start.getTime();
            var end_date = end.getTime();
            var now = new Date();
            var now_date = now.getTime();

            if(start_date >= now_date || now_date <= end_date){
                return price;
            }
            return '';
        }

        this.popupFormOverSea = function (){
            $('.popupform-oversea-open').on('click',function(e){
              $('#popupform-oversea').fadeIn();
            });
            $('#popupform-oversea-close-link').on('click',function(e){
              $('#popupform-oversea').fadeOut();
            });
            $('#popupform-oversea-close-button').on('click',function(e){
              $('#popupform-oversea').fadeOut();
            });
          }
          this.checkOverSea = function (souko_zaiko_su, over_sea){
              var text = 'タイムアウト';
              if(!souko_zaiko_su || souko_zaiko_su === '0' || souko_zaiko_su === 0){
                  if(over_sea !== 0 && over_sea !== '0'){
                      text = "１０～１４営業日";
                  } else {
                      text = '２～５営業日';
                  }
              } else {
                  if(over_sea === 0 || over_sea === '0'){
                      text = "１～３営業日";
                  } else {
                      text = '１～３営業日';
                  }
              }
              return text;
          } 
          this.arrParamToGetManufacturerOwl = function (arr) {
              var param = [];
              $.each(arr, function(i, e) {
                  var item = {};
                  if(e.list_dealer_cd){
                      item.list_dealer_cd = e.list_dealer_cd;
                  }
                  if(e.supplier_comp_code){
                      item.supplier_comp_code = e.supplier_comp_code;
                  }
                  if(e.sku){
                      item.sku = e.sku;
                  }
                  if(e.maker_name){
                      item.maker_name = e.maker_name;
                  }
                  if(e.maker_code){
                      item.maker_code = e.maker_code;
                  }

                  param.push(item);
                  
              });
              return param;
          }
          this.checkManufacturerToGetOversea = function(arr, param){
              var result = '';
              // console.log("==============Arr==================");
              // console.log(arr);
              $.each(arr, function(i, e){
                  if(param.supplier_comp_code){
                      // console.log("========================Param====================");
                      // console.log(param);
                      
                      if(param.maker_name){
                          // console.log("=======================Item 1=========================");
                          var item = "_" + param.maker_name + "_" + param.supplier_comp_code;
                          if(i == item){
                              // console.log(i + "===yes===_" + param.maker_name + "_" + param.supplier_comp_code);
                              result = e;
                          }
                          // console.log(1);
                      } else {
                          // console.log("=======================Item 2=========================");
                          var item = "__" + param.supplier_comp_code;
                          if(i == item){
                              // console.log(i + "===yes===" + "__" + param.supplier_comp_code);
                              result = e;
                          }
                          // console.log(2);
                      }
                     
                  }
              });
              return result;
          }
          this.checkOwlToGetSoukoZaikoSu = function(list_owl, param){
              var result = {};
              var list_result = [];
              var max_souko = 0;
              $.each(list_owl, function(i, e){
                var souko_list = [];
                $.each(param.list_dealer_cd, function(index_dealer_cd, dealer_cd){
                  var item = param.sku + "_" + dealer_cd;
                  // console.log(dealer_cd);
                  // console.log(item);
                  if(i == item){
                    list_result.push({
                      souko_zaiko_su: e.souko_zaiko_su,
                      souko_zaiko_su_updated: e.updated
                    });
                    souko_list.push(e.souko_zaiko_su);
                  }
                });
                // console.log(souko_list);
                if(souko_list){
                  max_souko = Math.max(souko_list);
                  // console.log(max_souko);
                  $.each(list_result, function(index_souko, value_souko){
                    // console.log(value_souko.souko_zaiko_su);
                    if(max_souko == value_souko.souko_zaiko_su){
                      result = value_souko;
                    }
                  });
                }
                // console.log(result);
                  
              });
              return result;
          }
          this.getManufacturerOwl = function (product_list) {
              if(!Array.isArray(product_list) || !product_list.length){
                  return false;
              } 
          
              var arr_list_param = thisTag.arrParamToGetManufacturerOwl(product_list);
              var param = [];
              var accessTokenCognito = localStorage.getItem('accessTokenCognito');
              param.push('token=' + accessTokenCognito);
              var url = URL_API + '/api/get_list_manufacture_owl';
              url += '?' + param.join('&');
              $.ajax({  
                  url: url,
                  type: 'POST',
                  timeout: 30000,
                  // async:false,
                  data: {
                      param: arr_list_param
                  },
                  beforeSend: function() {
                      // $('#img-loader').hide();
                      // $(".loading_F017").show();
                  },
                  afterSend: function() {
                      // $(".loading_F017").hide();
                  },
                  success: function (data) {
                      if(data.status == 100){
                          riot.mount('app','maintain',{ messege:data.messege });
                          return false;
                      }
                      if(data.status == 'not_authorize'){
                          var url = "#";
                          $(location).attr("href", url );
                          return false;
                      }
                      if(data.message == 'success'){
                          var list_manufacturer = data.list_manufacturer;
                          var list_owl = data.list_owl;
                          var list_owl_updated = [];
                          $.each(product_list, function(i, e){
                              let param = {
                                  list_dealer_cd: e.list_dealer_cd,
                                  supplier_comp_code: e.supplier_comp_code,
                                  maker_name: e.maker_name,
                                  maker_code: e.maker_code,
                                  sku: e.sku,
                              };

                              let manufacturer_result = thisTag.checkManufacturerToGetOversea(list_manufacturer,param); // over_sea

                              product_list[i].oversea = manufacturer_result ? manufacturer_result : "タイムアウト";

                              let owl_result = thisTag.checkOwlToGetSoukoZaikoSu(list_owl,param);
                              product_list[i].souko_zaiko_su = owl_result > 0 ? owl_result.souko_zaiko_su : '';
                              product_list[i].souko_zaiko_su_text = owl_result.souko_zaiko_su ? (owl_result.souko_zaiko_su > 2 ? '3以上' : owl_result.souko_zaiko_su) : '取寄品';
                              product_list[i].souko_zaiko_su_updated = owl_result.updated;

                              let over_sea_text = thisTag.checkOverSea(owl_result.souko_zaiko_su, manufacturer_result);
                              product_list[i].over_sea_text = over_sea_text;
                              if(owl_result.souko_zaiko_su_updated){
                                list_owl_updated.push(new Date(owl_result.souko_zaiko_su_updated));
                              }
                          });
                          // thisTag.countSoukoZaikoUpdatedNewest(list_owl_updated);
                          thisTag.results = product_list;
                          
                          thisTag.update(thisTag.results);
                          thisTag.popupFormOverSea();
                      } 
                      // $(".loading_F017").hide();
                      // if(data.message == 'error'){
                      //   thisTag.checkOverSea = 'タイムアウト';
                      //   thisTag.update(thisTag.checkOverSea);
                      // }
                  },
                  error: function (xhr, stt, err) {
                      // $(".loading_F017").hide();
                      $.each(thisTag.results, function(i, e){
                        thisTag.results[i].over_sea_text = 'タイムアウト';
                        thisTag.results[i].souko_zaiko_su_text = 'タイムアウト';
                        thisTag.results[i].souko_zaiko_su_updated = '';
                      })
                      thisTag.update(thisTag.results);
                  }
              });
          }
          this.countSoukoZaikoUpdatedNewest = function(list_date){
              var max_date_updated = moment(new Date(Math.max.apply(null,list_date)), 'YYYY-MM-DD').format('YYYY-MM-DD');
              thisTag.max_date_updated = max_date_updated;
              thisTag.update(thisTag.max_date_updated);
          }
    </script>
</search-result-punchout>

<favorites-punchout>
    <link rel="stylesheet" href="css/favorites.css">
    <div class="main">
        <div class="content">
            <div class="page-title">
                <h2>お気に入り</h2>
            </div>
            <div class="favorites-box">
                <div class="box-head">
                    <div class="head-top">
                        <p class="head-top-left" id="total_item">登録件数　2件</p>
                        <div class="head-top-right">
                            <p id="total_page">2ページ中1ページ</p>
                            <!--<ul class="pagination">-->
                            <!--<li><a href="#"><i class="fa fa-angle-double-left" aria-hidden="true"></i></a></li>-->
                            <!--<li><a href="#"><i class="fa fa-angle-double-right" aria-hidden="true"></i></a></li>-->
                            <!--</ul>-->
                        </div>
                    </div>
                    <div class="head-bottom">
                        並べ替え:
                        <select onchange = { onChange }>
                            <option value="1" selected="{(order == 1) ? 'selected': ''}">登録の新しい順：降順</option>
                            <option value="2" selected="{(order == 2) ? 'selected': ''}">登録の古い順：昇順</option>
                        </select>
                    </div>
                </div>
                <div class="item-box">
                    <favorite-result-punchout></favorite-result-punchout>
                </div>
                <div class="box-foot">
                    <div class="foot-top">
                        <div class="foot-top-left">
                            <button type="button" onclick={ selectAll }>全選択</button>
                            <button type="reset" class="reset-btn" onclick={ unSelectAll }><i class="fa fa-refresh" aria-hidden="true"></i>クリア</button>
                        </div>
                        <div class="foot-top-right">
                            チェックしたアイテムを
                            <button type="button" class="color-btn red-btn" id="add-all" style="display: { arColumn(list_button, 'navigation_id', 'B002').length ? 'inline' : 'none' }" onclick={ addToCartAll }><i class="fa fa-shopping-cart" aria-hidden="true"></i>{ arColumn(list_button, 'navigation_id', 'B002').length ? arColumn(list_button, 'navigation_id', 'B002')[0]['display_contents'] : '' }</button>
                            <!--<button type="button" class="color-btn green-btn" onclick={ addToDeliveryAll }>見積依頼する</button>-->
                            <a href="javascript:void(0)" class="delete-link" style="display: { list_button.includes('B001') ? 'inline' : 'none' }" onclick={ removeFavoriteAll }><i class="fa fa-times" aria-hidden="true"></i>お気に入りから削除</a>
                        </div>
                    </div>
                    <div id="paging" class="text-center">
                        <ul class="pagination" id="pagination"></ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        var user_info = JSON.parse(getItem('EcUserInfo'));
        var thisTag = this;
        this.list_button = user_info.list_navigation.B;
        // console.log(this.list_button);
        var x = arColumn(this.list_button, 'navigation_id', 'B002')[0]['display_contents'];
        // var x = '';
        total_cart_favorites = opts.total;
        this.basic_is_active = opts.basic_is_active;
        this.price_rounding_check = opts.price_rounding_check;
        this.order = opts.order;
        this.conditions = [
            {condition: '完全一致'},
            {condition: 'から始まる'},
            {condition: 'を含む'},
        ];
        toggle(e) {
            this.basic_is_active = !this.basic_is_active;
            this.antibody_is_active = !this.antibody_is_active;
        }
        //var total = opts.total;
        var accessTokenCognito = getItem('accessTokenCognito');
        var status = 1;
        $(function () {
            $('#total_item').text('登録件数　' + opts.total + '件');
            $('#total_page').text(Math.ceil(opts.total/LIMIT_ON_PAGE) + 'ページ中1ページ' + 1);
            riot.mount('favorite-result-punchout', { result: opts.result['list_cart'], list_dealer: opts.list_dealer, products_dealer_customers_list: opts.result['products_dealer_customers_list'],price_rounding_check : thisTag.price_rounding_check });
            var $pagination = $('#pagination');
            $pagination.twbsPagination({
                totalPages: Math.ceil(opts.total/LIMIT_ON_PAGE),
                visiblePages: 5,
                initiateStartPageClick: false,
                onPageClick: function (event, page) {
                    console.log(thisTag.order);
                    var url = URL_API + '/api/punchout/cart/wishlist';
                    var query = [];
                    query.push('token=' + accessTokenCognito);
                    query.push('favorite_status=' + status);
                    query.push('page=' + page);
                    query.push('order_order_date=' + thisTag.order);
                    url += '?' + query.join('&');
                    $.ajax({
                        url: url,
                        type: 'GET',
                        success: function (data, text) {
                            if(data.status == 100){
                                riot.mount('app','maintain',{ messege:data.messege });
                                return false;
                            }
                            total_cart_favorites = data.total;
                            $('#total_item').text('登録件数　' + total_cart_favorites + '件');
                            $('#total_page').text(Math.ceil(total_cart_favorites/LIMIT_ON_PAGE) + 'ページ中1ページ' + 1);
                            riot.mount('favorite-result-punchout', { result: data.cart_list, list_dealer: data.list_dealer});
                        },
                        error: function (xrl, stt, error) {
                            alert('エラー');
                        }
                    });
                }
            });

            $( ".order-input" ).spinner({
                stop: function( event, ui ) {
                    var quantity = event.target.id;
                    var suryo = $('#'+quantity).val();
                    // console.log(suryo);
                    if(suryo != ''){
                        if(suryo <= 0){
                            alert('0以上の正数を入力してください。');
                            $('#' + quantity).val('1');
                        }
                    }
                }
            });
        });
        onChange = function (e) {
            var value = e.target.value;
            console.log(value);
            if (value == 0) {
                return true;
            }
            var arOrder = {
                1: 'desc',
                2: 'asc'
            };
            thisTag.order = arOrder[value];

            // var url = URL_API + '/api/cart/list';
            // var accessTokenCognito = getItem('accessTokenCognito');
            var query = [];

            // ===================

            var accessTokenCognito = getItem('accessTokenCognito');
            var favorite_status = 1;
            var url = URL_API + '/api/punchout/cart/wishlist?token=' + accessTokenCognito + '&favorite_status=' + favorite_status + '&order_order_date=' + thisTag.order + '&limit=' + LIMIT_ON_PAGE;
            var total = 0;
            var result = [];
            var order = '';

            $.ajax({
                'url': url,
                'type': 'GET',
                success: function (data) {
                    if(data.status == 100){
                        riot.mount('app','maintain',{ messege:data.messege });
                        return false;
                    }
                    result['list_cart'] = data.cart_list;
                    total = data.total;
                    order = data.order;
                    thisTag.order = order;
                    riot.mount('favorite-result-punchout', { result: result['list_cart'], list_dealer: data.list_dealer, products_dealer_customers_list: result['products_dealer_customers_list'] });
                },
                error: function (xhr, stt, err) {
                    alert('エラー');
                }
            });

            // ===================
            // query.push('order_order_date=' + arOrder[value]);
            // query.push('token=' + accessTokenCognito);
            // query.push('favorite_status=' + 1);
            // query.push('limit=' + LIMIT_ON_PAGE);
            // url += '?' + query.join('&');
            // var url2 = URL_API + '/api/products_dealer_customers/list?token=' + accessTokenCognito;
            // var url3 = '';
            // var selling_prices_list = '';
            // var products_dealer_customers_list = '';
            // var flag = false;
            // var count = 0;
            // var result = [];
            // $.ajax({
            //     'url': url,
            //     'type': 'GET',
            //     success: function (data) {
            //         flag = true;
            //         result['list_cart'] = data.cart_list;
            //         total_cart_favorites = data.total;
            //         $('#total_item').text('登録件数　' + data.total + '件');
            //         $('#total_page').text(Math.ceil(data.total/LIMIT_ON_PAGE) + 'ページ中1ページ' + 1);
            //     },
            //     error: function (xhr, stt, err) {
            //         alert('エラー');
            //     }
            // });
            // $.ajax({
            //     url: url2,
            //     type: 'GET',
            //     timeout: 20000,
            //     success: function (data) {
            //         products_dealer_customers_list = data.products_dealer_customers_list;
            //         result['products_dealer_customers_list'] = products_dealer_customers_list;
            //         $.each(result['products_dealer_customers_list'], function (i, e) {
            //             url3 = URL_API + '/api/selling_prices/list?token=' + accessTokenCognito + '&dealer_co_cd=' + e['dealer_co_cd'];
            //             // console.log(url3);
            //             $.ajax({
            //                 'url': url3,
            //                 'type': 'GET',
            //                 success: function (data) {
            //                     selling_prices_list = data.selling_prices_list;
            //                     result['products_dealer_customers_list'][i]['selling_tanka'] = typeof selling_prices_list['selling_tanka'] == 'string' ? selling_prices_list['selling_tanka'] : '';
            //                     count ++;
            //                     // console.log(result['products_dealer_customers_list'] + "==1==");
            //                     $.each(result['products_dealer_customers_list'],function(i, e){
            //                         console.log(e);
            //                     });
            //                     if (flag && count == products_dealer_customers_list.length) {
            //                         riot.mount('favorite-result', { result: result['list_cart'], products_dealer_customers_list: result['products_dealer_customers_list']});
            //                         // console.log(result['products_dealer_customers_list'] + "==1==");
            //                         var $pagination = $('#pagination');
            //                         $pagination.twbsPagination('destroy');
            //                         $pagination.twbsPagination({
            //                             totalPages: Math.ceil(data.total/LIMIT_ON_PAGE),
            //                             visiblePages: 5,
            //                             initiateStartPageClick: false,
            //                             onPageClick: function (event, page) {
            //                                 var url11 = URL_API + '/api/cart/list';
            //                                 var query = [];
            //                                 query.push('token=' + accessTokenCognito);
            //                                 query.push('status=' + status);
            //                                 query.push('limit=' + LIMIT_ON_PAGE);
            //                                 query.push('page=' + page);
            //                                 query.push('order_order_date=' + arOrder[value]);
            //                                 url2 += '?' + query.join('&');
            //                                 var flag2 = false;
            //                                 var result2 = [];
            //                                 var count2 = 0;
            //                                 $.ajax({
            //                                     type: 'GET',
            //                                     url: url11,
            //                                     timeout: 20000,
            //                                     success: function (data, text) {
            //                                         flag2 = true;
            //                                         result2['list_cart'] = data.cart_list;
            //                                         total_cart_favorites = data.total;
            //                                         $('#total_item').text('登録件数　' + total_cart_favorites + '件');
            //                                         $('#total_page').text(Math.ceil(total_cart_favorites/LIMIT_ON_PAGE) + 'ページ中1ページ' + 1);

            //                                     }
            //                                 });
            //                                 $.ajax({
            //                                     url: url2,
            //                                     type: 'GET',
            //                                     timeout: 20000,
            //                                     success: function (data) {
            //                                         products_dealer_customers_list = data.products_dealer_customers_list;
            //                                         result2['products_dealer_customers_list'] = products_dealer_customers_list;
            //                                         $.each(result['products_dealer_customers_list'], function (i, e) {
            //                                             url3 = URL_API + '/api/selling_prices/list?token=' + accessTokenCognito + '&dealer_co_cd=' + e['dealer_co_cd'];
            //                                             $.ajax({
            //                                                 'url': url3,
            //                                                 'type': 'GET',
            //                                                 success: function (data) {
            //                                                     selling_prices_list = data.selling_prices_list;
            //                                                     result['products_dealer_customers_list'][i]['selling_tanka'] = typeof selling_prices_list['selling_tanka'] == 'string' ? selling_prices_list['selling_tanka'] : '';
            //                                                     count ++;
            //                                                     if (flag2 && count2 == products_dealer_customers_list.length) {
            //                                                         riot.mount('favorite-result', { result: result2['list_cart'], products_dealer_customers_list: result2['products_dealer_customers_list'] });
            //                                                         // console.log(result2['products_dealer_customers_list'] + "==2==");
            //                                                     }
            //                                                 },
            //                                                 error: function (xhr, stt, err) {
            //                                                     alert('エラー');
            //                                                 }
            //                                             });
            //                                         });
            //                                     },
            //                                     error: function (xhr, stt, err) {
            //                                         alert('エラー');
            //                                     }
            //                                 });
            //                             }
            //                         });
            //                     }
            //                 },
            //                 error: function (xhr, stt, err) {
            //                     alert('エラー');
            //                 }
            //             });
            //         });
            //     },
            //     error: function (xhr, stt, err) {
            //         alert('エラー');
            //     }
            // });
        }
        addToCartAll = function (e) {
            var data = [];
            var del = 0;
            var item_sku_exist = true;
            var error = [];
            var agent = getItem('agent_id');
            $('input[type=checkbox]').each(function () {

                if (this.checked) {
                    var index = $(this).attr('index');
                    if($("#check_deleted_" + index).val() == 1){
                        del = 1;
                    } else {
                        del = 0;
                    }
                    if($("#check_item_sku_exist_" + index).val() == 'false'){
                        item_sku_exist = false;
                    }
                    data.push({
                        //cart_seq: $(this).val(),
                        dealer_co_cd: $('#dealer_co_cd_'+index).val(),
                        dealer_dep_cd: $('#dealer_co_cd_'+index).find('option:selected').attr('data-dealer-dep'),
                        dealer_co_name: $('#dealer_co_cd_'+index+' option:selected').text(),
                        //teika_tanka: $('#teika_tanka_'+index).val(),
                        //tanka: $('#selling_tanka_'+index).val(),
                        suryo: $('#suryo_'+index).val(),
                        status: 0,
                        supp_co_name: $('#supp_co_name_'+index).val(),
                        supp_co_cd: $('#supp_co_cd_'+index).val(),
                        maker_name: $('#maker_name_'+index).val(),
                        item_name: $('#item_name_'+index).val(),
                        item_sku: $('#item_sku_'+index).val(),
                        capacity: $('#capacity_'+index).val(),
                        kikaku: $('#kikaku_'+index).val(),
                        supp_sku: $('#supp_sku_'+index).val(),
                        agent_users_id: agent
                    });
                }
            });
            if(del == 1){
                error.push("商品の販売が中止されました。\n");
            }
            if (data.length == 0) {
                error.push('選択する商品がありません。\n');
            }
            if(!item_sku_exist){
                error.push("存在しない商品が含まれています。\n");
            }
            if(error.length > 0){
                var err = error.join(" ");
                alert(err);
                return false;
            }

            $.ajax({
                url: URL_API + '/api/punchout/cart/create?token=' + accessTokenCognito + '&is_ariba=' + getItem('is_ec_ariba'),
                type: 'POST',
                timeout: 20000,
                data: {
                    data: data
                },
                success: function (res) {
                    if(res.status == 100){
                        riot.mount('app','maintain',{ messege:res.messege });
                        return false;
                    }
//                    $('input[type=checkbox]').each(function () {
//                        if (this.checked) {
//                            $('#favorites-item-' + $(this).attr('index')).remove();
//                            total_cart_favorites--;
//                        }
//                    });
//                    $('#total_item').text('登録件数　' + total_cart_favorites + '件');
                    if (res.message && res.errors) {
                        alert("処理が実行できませんでした。時間をおいて再度お試しください。同様のメッセージが再度出る場合はお手数ですがシステム提供者にご連絡ください。");
                    } else {
                        alert('カートに追加しました。\nカート画面から発注処理を行ってください。');
                    }
                },
                error: function (xhr, stt, error) {
                    alert('エラー');
                }
            });
        }
        removeFavoriteAll = function () {
            var data = [];
            var agent = getItem('agent_id');
            $('input[type=checkbox]').each(function () {
                if (this.checked) {
                    data.push({
                        'cart_seq': $(this).val(),
                        'agent_users_id': agent,
                        'favorite_status': 0
                    });
                }
            });
            if (data.length == 0) {
                alert('選択する商品がありません');
                return false;
            }
            $.ajax({
                url: URL_API + '/api/punchout/cart/create?token=' + accessTokenCognito,
                type: 'POST',
                timeout: 20000,
                data: {
                    data: data
                },
                success: function (res) {
                    if(res.status == 100){
                        riot.mount('app','maintain',{ messege:res.messege });
                        return false;
                    }
                    riot.route.exec();
                    // $('input[type=checkbox]').each(function () {
                    //     if (this.checked) {
                    //         $('#favorites-item-' + $(this).attr('index')).remove();
                    //         total_cart_favorites--;
                    //     }
                    // });
                    // $('#total_item').text('登録件数　' + total_cart_favorites + '件');
                },
                error: function (xhr, stt, error) {
                    alert('エラー');
                }
            });
        }
        addToDeliveryAll = function() {
            var data = [];
            var agent = getItem('agent_id');
            $('input[type=checkbox]').each(function () {
                if (this.checked) {
                    data.push({
                        'cart_seq': $(this).val(),
                        'agent_users_id': agent,
                        'status': 2
                    });
                }
            });
            if (data.length == 0) {
                alert('選択する商品がありません');
                return false;
            }
            $.ajax({
                url: URL_API + '/api/punchout/cart/create?token=' + accessTokenCognito,
                type: 'POST',
                timeout: 20000,
                data: {
                    data: data
                },
                success: function (res) {
                    if(res.status == 100){
                        riot.mount('app','maintain',{ messege:res.messege });
                        return false;
                    }
                    $('input[type=checkbox]').each(function () {
                        if (this.checked) {
                            $('#favorites-item-' + $(this).attr('index')).remove();
                            total_cart_favorites--;
                        }
                    });
                    $('#total_item').text('登録件数　' + total_cart_favorites + '件');
                },
                error: function (xhr, stt, error) {
                    alert('エラー');
                }
            });
        }
        selectAll = function () {
            $('.favorites-box input[type=checkbox]:not(:disabled)').each(function () {
                $(this).prop('checked', true);
            });
        }
        unSelectAll = function () {
            $('.favorites-box input[type=checkbox]').each(function () {
                $(this).prop('checked', false);
            });
        }

    </script>
</favorites-punchout>

<order-cart-punchout>
    <link rel="stylesheet" href="./css/order-cart.css">
    <div class="main">
        <div class="content">
            <div class="page-title">
                <h2>注文用カート</h2>
            </div>
            <h3 class="data-empty">カートに商品はありません</h3>
            <div class="order-list">
                <div class="order-item-box">
                    <table class="order-item">
                        <tbody each = { element, index in list_cart } id="{ 'item_' + index }" class="result-cart">
                        <tr>
                            <td class="left">
                                <dl>
                                    <dt>販売元メーカー</dt>
                                    <dd>{ element.sales_origin_maker_name }</dd>
                                </dl>
                                <dl>
                                    <dt>製造元メーカー</dt>
                                    <dd>{ element.maker_name }</dd>
                                </dl>
                                <dl>
                                    <dt>品番</dt>
                                    <dd><a href={ (element.is_deleted == 1 || !element.item_sku_exist) ? '' : ('#search/basic_details-punchout/' + element.item_sku) } target="" style="{ (element.is_deleted == 1 || !element.item_sku_exist) ? 'color:black;text-decoration:none;cursor:auto;' : '' }">{ element.supp_sku }</a></dd>
                                </dl>
                                <dl>
                                    <dt>品名</dt>
                                    <dd>{ element.item_name }</dd>
                                </dl>
                                <dl>
                                    <dt>容量・規格</dt>
                                    <dd>{ element.capacity + ' ' + element.kikaku }</dd>
                                </dl>
                                <dl>
                                    <dt>販売店</dt>
                                    <dd>{ element.dealer_co_name } { element.dealer_dep_name }</dd>
                                </dl>
                            </td>
                            <td>
                                <dl>
                                    <dt>定価</dt>
                                    <dd>{  !isNaN(parseInt(element.list_price)) ? (element.list_price == 0  ? 'お見積り' : parseInt(element.list_price).toLocaleString('en') + '円' ) : 'お見積り' }
                                    </dd>
                                    <input type="hidden" id="{ 'teika_tanka_' + index}" value="{ element.list_price }">
                                </dl>
                                <dl>
                                    <dt>納入価格</dt>
                                    <dd>{ !isNaN(parseInt(element.selling_tanka)) ? (parseInt(element.selling_tanka).toLocaleString('en') + '円' ) : 'お見積り' }</dd>
                                    <dd><b style="color:red;display:{(element.is_deleted == 1 ) ? 'block' : 'none'}">販売中止</b></dd>
                                </dl>
                            </td>
                            <td style="position: relative;">
                                <dl>
                                    <dt>数量</dt>
                                    <dd>
                                        <input type="number" id="{ 'suryo_' + index }" tabindex="{index}" class="order-input spinner cart-suryo cart-seq-{element.cart_seq}" name="{ index }" value="{ element.suryo }" min="1" maxLength="10" oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);">
                                        <span class="msg-item-sku-exist" style="position: absolute;width: 200px;top:90px;">{(element.inquiry == 1) ? '' : ((element.is_deleted == 1 || !element.item_sku_exist) ? 'この商品はカタログから削除されています' : '')}</span>
                                        <input type="hidden" id="{ 'tanka_' + index }" class="cart-tanka" value="{element.selling_tanka}">
                                        <input type="hidden" id="check_deleted_{index}" value="{element.is_deleted}">
                                        <input type="hidden" id="cart_seq_{index}" value="{element.cart_seq}">
                                    </dd>
                                </dl>
                            </td>
                            <td>
                                <dl>
                                    <dt>納入金額</dt>
                                    <dd id="{ 'total_price_' + index }">{ !isNaN(parseFloat(element.selling_tanka)) ? (parseInt(element.selling_tanka * element.suryo).toLocaleString('en') + '円'): 'お見積り' }</dd>
                                </dl>
                                <dl>
                                    <dt>消費税({ element.tax_div == '2' ? '8' : '10'}%)</dt>
                                    <dd id="{ 'total_rate_price_' + index }">{ parseInt((element.selling_tanka * element.suryo) * (element.tax_div == '2' ? 0.08 : 0.1)).toLocaleString('en') }円</dd>
                                    <input type="hidden" id="tax_product_{index}" value="{ parseInt((element.selling_tanka * element.suryo) * (element.tax_div == '2' ? 0.08 : 0.1)) }">
                                    <input type="hidden" id="tax_rate_{index}" value="{ element.tax_div == '2' ? '8' : '10'}">
                                </dl>
                            </td>
                            <td class="center"><button class="reset-btn" id="{ index }" onclick ={ deleteCart } value="{ index }"><i class="fa fa-times" aria-hidden="true"></i>削除</button></td>
                        </tr>
                        </tbody>
                        <tfoot>
                        <tr>
                            <td colspan="4">
                                <dl>
                                    <dt>小計</dt>
                                    <dd id="total"></dd>
                                </dl>
                                <dl>
                                    <dt>消費税計</dt>
                                    <dd id="tax"></dd>
                                </dl>
                                <dl class="total">
                                    <dt>合計</dt>
                                    <dd id="total_all"></dd>
                                </dl>
                                <dl>
                                    <dd style="text-align: left;font-size: 11px;"><b style="color:red;">{msg}</b></dd>
                                </dl>
                            </td>
                            <td></td>
                        </tr>
                        </tfoot>
                    </table>
                    <div class="btn-wrapper" style="min-height: 59px">
                        <!-- <button type="button" class="color-btn green-btn" style="display: { arColumn(list_button, 'navigation_id', 'B002').length ? 'inline' : 'none' }" onclick={ noteAll }>カート内容を保存</button> -->
                        <button id="checkout" type="button" class="color-btn red-btn" style="display: { arColumn(list_button, 'navigation_id', 'B002').length ? 'inline' : 'none' }" onclick={ punchOut2 }>チェックアウト</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-wrapper">
        <!--<modal-send-order-message></modal-send-order-message>-->
        <div class="o_modal_body" style="display: none">
            <div class="o_modal_main">
                <h3 class="modal-title">Send Order Message</h3>
                <form id="send-order-message" name="SendXml" method="POST" >
                    <input type="hidden" id="cxml-base64" name="cxml-base64" value="">
                    <input type="submit" value="POOM 送信">
                </form>
            </div>
        </div>
    </div>
    <script>
        var user_info = JSON.parse(getItem('EcUserInfo'));
        this.list_button = user_info.list_navigation.B;
        this.list_cart = opts.result;
        this.msg = '';
        var list_cart_update = this.list_cart;
        var list_cart_id = [];
        var thisTag = this;
        //console.log(list_cart_update);
        $(function(){

            $( ".cart-suryo" ).spinner({
                stop: function( event, ui ) {
                    var index = event.target.attributes.tabindex.value;
                    var suryo = $('#suryo_'+index).val();

                    if(suryo <= 0){
                        alert('0以上の正数を入力してください。');
                        $('#suryo_' + index).val('1');
                    }
                    suryoChange(event);
                },

            });

            if(ec31_po_cart_list.length > 0){
                $.each(thisTag.list_cart,function(index,element){
                    jQuery.grep(ec31_po_cart_list, function( n, i ) {
                        if(n.cart_seq == element.cart_seq){
                            thisTag.list_cart[index]['suryo'] = n.suryo;
                        }
                    });
                });
                thisTag.update(thisTag.list_cart);
                thisTag.updateTotal();
            }
        });

        this.on('mount', function () {
            if (!list_cart_update.length) {
                $('.order-list').hide();
            } else {
                $('.data-empty').hide();
            }
            thisTag.checkPriceToVisibleMsg();
            this.updateTotal();
        });
        this.checkPriceToVisibleMsg = function(e){
            $.each(thisTag.list_cart, function(i, e){
                if(parseInt(e.selling_tanka) === parseInt(e.list_price)){
                    thisTag.msg = '※納入価格に「お見積り」が含まれる場合、定価をベースに算出しています。';
                }
            });
            thisTag.update(thisTag.msg);
        }
        this.updateTotal = function (e) {
            var list_cart = this.list_cart;
            var total = 0;
            var total_tax = 0;
            for(var i = 0; i < list_cart.length; i++) {
                let tax = list_cart[i].tax_div == '2' ? 0.08 : 0.1;
                if (!isNaN($('#suryo_' + i).val()) && !isNaN($('#tanka_' + i).val())) {
                    let total_product = $('#suryo_' + i).val() * $('#tanka_' + i).val();
                    total_tax += total_product * tax;
                    total += total_product;
                }
            }
            var total_convert = parseInt(total).toLocaleString('en');
            var tax_convert = parseInt(total_tax).toLocaleString('en');
            var total_all_convert = parseInt(total + total_tax).toLocaleString('en');
            $('#total').text(total_convert + '円');
            $('#tax').text(tax_convert + '円');
            $('#total_all').text(total_all_convert + '円');
        }
        this.deleteCart = function (e) {
            var index = e.target.value;
            var list_cart = this.list_cart;
            var agent = getItem('agent_id');
            var accessTokenCognito = getItem('accessTokenCognito');
            var url = URL_API + '/api/punchout/cart/create?token=' + accessTokenCognito;
            var data = [];
            //console.log(list_cart[index]);
            data.push({
                cart_seq: list_cart[index].cart_seq,
                agent_users_id: agent,
                status: 99
            });
            $.ajax({
                url: url,
                type: 'POST',
                timeout: 20000,
                data: {
                    data: data
                },
                success: function (data) {
                    if(data.status == 100){
                        riot.mount('app','maintain',{ messege:data.messege });
                        return false;
                    }
                    riot.route.exec();
                    // list_cart_update.splice(index, 1);
                    // alert('カートから削除しました。');
                    // $('#item_' + index).remove();
                    // // update total
                    // var total = 0;
                    // $('table.order-item').find('tbody.result-cart').each(function () {
                    //     var tanka = $(this).find('input[type=hidden]').val();
                    //     if (!isNaN($(this).find('input[type=hidden]').val()) && !isNaN($(this).find('input[type=number].cart-suryo').val())) {
                    //         total += $(this).find('input[type=hidden]').val() * $(this).find('input[type=number].cart-suryo').val();
                    //     }
                    // });
                    // var total_convert = parseFloat(total).toLocaleString('en');
                    // var tax = Math.floor(total * 0.08);
                    // var tax_convert = parseFloat(tax).toLocaleString('en');
                    // var total_all_convert = parseFloat(total + tax).toLocaleString('en');
                    // $('#total').text(total_convert + '円');
                    // $('#tax').text(tax_convert + '円');
                    // $('#total_all').text(total_all_convert + '円');
                },
                error: function (xhr, stt, error) {
                    alert('エラー');
                }
            });
        }
        this.noteAll = function () {
            var accessTokenCognito = getItem('accessTokenCognito');
            var url = URL_API + '/api/punchout/cart/create?token=' + accessTokenCognito;
            var agent = getItem('agent_id');
            var data = [];
            $.each(list_cart_update, function (index, element) {
                data.push({
                    cart_seq: element.cart_seq,
                    dealer_co_cd: element.dealer_co_cd,
                    suryo: $('#suryo_'+index).val(),
                    agent_users_id: agent,
                    comment_usr: $('#comment_usr_'+index).val(),
                    status: 0
                });
            });
            $.ajax({
                url: url,
                type: 'POST',
                timeout: 20000,
                data: {
                    data: data
                },
                success: function (res) {
                    if(res.status == 100){
                        riot.mount('app','maintain',{ messege:res.messege });
                        return false;
                    }
//                    for(var i = 0; i < list_cart_update.length; i++) {
//                        $('#item_' + i).remove();
//                    }
//                    list_cart_update = [];
                    $('.red-btn').attr('disabled', false);
                    alert('カート内容を保存しました。');
                },
                error: function (e) {
                    alert('エラー');
                }
            });
        }
        this.redirectOrderCart2 = function () {
            if (list_cart_update.length > 0) {
                var total = 0;
                var suryo_error = 0;
                for(var i = 0; i < list_cart_update.length; i++) {
                    if($('#suryo_' + i).val() <= 0){
                        suryo_error++;
                    }
                    list_cart_update[i].suryo = $('#suryo_' + i).val();
                    list_cart_update[i].comment_usr = $('#comment_usr_' + list_cart_update[i].cart_seq).val();
                    total += $('#suryo_' + i).val() * list_cart_update[i].selling_tanka;
                }
                if(suryo_error > 0){
                    alert("0以上の正数を入力してください。\n");
                    return false;
                }
                var tax = Math.floor(total * 0.08 * 0);
                riot.mount('app', 'order-cart-2', { result: list_cart_update, total:  total, tax: tax});
            } else {
                alert('選択する商品がありません');
            }
        }
        function filterSuryo(arr,cart_seq,suryo){

            var suryo_change = false;
            if(ec31_po_cart_list.length > 0){

                jQuery.grep(arr, function( n, i ) {
                    // console.log(n.cart_seq+"==="+i);
                    if(n.cart_seq == cart_seq){
                        suryo_change = true;
                        ec31_po_cart_list[i].suryo = suryo;
                    }
                });
                if(!suryo_change){
                    ec31_po_cart_list.push({cart_seq:cart_seq,suryo:suryo});
                }
            } else {
                ec31_po_cart_list.push({cart_seq:cart_seq,suryo:suryo});
            }
            suryo_change = false;
        }
        function suryoChange(e) {
            var index = e.target.attributes.tabindex.value;
            var suryo = $('#suryo_' + index).val();
            var cart_seq = $('#cart_seq_' + index).val();
            var suryo_change = false;
            var arr_index = '';
            var tanka = parseInt($('#tanka_'+index).val());
            tanka = !isNaN(tanka) ? tanka : 0;
            var total_tax = 0;
            filterSuryo(ec31_po_cart_list,cart_seq,suryo);

            var total_price =  !isNaN(parseFloat($('#tanka_'+index).val())) ? ($('#tanka_'+index).val() * suryo +'円') : 'お見積り';
            $('#total_price_' + index).text(total_price);
            var list_cart = thisTag.list_cart;
            var total_rate_price = ($('#tanka_'+index).val() * suryo) * (list_cart[index].tax_div == '2' ? 0.08 : 0.1);

            $('#total_rate_price_'+index).text(parseInt(total_rate_price).toLocaleString('en')+'円');
            var total = 0;
            for(var i = 0; i < list_cart.length; i++) {
                let tax = list_cart[i].tax_div == '2' ? 0.08 : 0.1;
                if (!isNaN($('#suryo_' + i).val()) && !isNaN($('#tanka_' + i).val())) {
                    let total_product = $('#suryo_' + i).val() * $('#tanka_' + i).val();
                    total_tax += total_product * tax;
                    total += total_product;
                }
            }

            var total_convert = parseInt(total).toLocaleString('en');
            var tax_convert = parseInt(total_tax).toLocaleString('en');
            var total_all_convert = parseInt(total + total_tax).toLocaleString('en');
            $('#total').text(total_convert + '円');
            $('#tax').text(tax_convert + '円');
            $('#total_all').text(total_all_convert + '円');
        }
        this.punchOut = function (e) {
            var check_deleted = 0;
            var url = URL_API + '/punchout/order_message';
            var list_cart_seq = [];
            var accessTokenCognito = getItem('accessTokenCognito');
            $.each(list_cart_update, function (index, element) {
                list_cart_seq.push({
                    cart_id: element.cart_seq
                });
            });
            var urlEC10Po = "#search/simple-po";
            $.ajax({
                url: url,
                data: {
                    list_cart_id: list_cart_seq,
                    token: accessTokenCognito
                },
                type: 'GET',
                success: function (res) {
                    if(res.status == 100){
                        riot.mount('app','maintain',{ messege:res.messege });
                        return false;
                    }
                    if (confirm('OrderMessageを送信しました')) {
                        $(location).attr("href", urlEC10Po);
                    }
                },
                error: function () {
                    alert('エラー');
                }
            });
        }
        this.punchOut2 = function (e) {
            $('#checkout').prop('disabled', true);
            var suryo_error = 0;
            var dealer_error = 0;
            var dealer_co_cd = [];
            var dealer_dep_cd = [];
            var name = user_info.name;
            var id = user_info.id;
            var check_deleted = 0;
            var check_tanka = 0;
            var error = [];
            var url = URL_API + '/punchout/order_message_punchout';
            var list_cart_seq = [];
            var agent = getItem('agent_id');
            var accessTokenCognito = getItem('accessTokenCognito');
            var item_sku_exist = true;
            var tax = 0;
            var dataOutMitsumori = 0;
            $.each(list_cart_update, function (index, element) {
                var deleted = $("#check_deleted_"+index).val();
                if (element.inquiry != 1) {
                    if(!element.item_sku_exist){
                        item_sku_exist = false;
                    }
                    if(deleted == 1){
                        check_deleted = 1;
                    }
                }
                
                if($('#suryo_' + index).val() <= 0){
                    suryo_error = 1;
                }
                if ((element.cart_seq_mitsumori_related == null || element.cart_seq_mitsumori_related == '') && (element.selling_tanka == null || element.selling_tanka == '')) {
                    dataOutMitsumori++;
                }
                // if(element.selling_tanka <= 0){
                //     check_tanka = 1;
                // }
                if(name.indexOf('budget') > -1 || id.indexOf('budget') > -1){
                    if (dealer_co_cd.length > 0) {
                        if (dealer_co_cd.indexOf(element.dealer_co_cd) <= -1) {
                            dealer_error = 1;
                        } else {
                            list_cart_seq.push({
                                cart_id: element.cart_seq,
                                agent_users_id: agent,
                                suryo: ($('.cart-seq-'+element.cart_seq).val() != "") ? $('.cart-seq-'+element.cart_seq).val() : "0",
                                tanka: element.selling_tanka
                            });
                        }
                    } else {
                        dealer_co_cd.push(element.dealer_co_cd);
                        list_cart_seq.push({
                            cart_id: element.cart_seq,
                            agent_users_id: agent,
                            suryo: ($('.cart-seq-'+element.cart_seq).val() != "") ? $('.cart-seq-'+element.cart_seq).val() : "0",
                            tanka: element.selling_tanka
                        });
                    }


                } else {
                    list_cart_seq.push({
                        cart_id: element.cart_seq,
                        agent_users_id: agent,
                        suryo: ($('.cart-seq-'+element.cart_seq).val() != "") ? $('.cart-seq-'+element.cart_seq).val() : "0",
                        tanka: element.selling_tanka
                    });
                }
                

            });
            if(!item_sku_exist){
                error.push("カタログから削除された商品が含まれています。\nその商品をカートから削除の上、再度チェックアウトを行ってください。\n");
            }

            if(check_deleted == 1){
                error.push("カート内に販売中止の商品が存在しています。\n");
            }

            if(suryo_error == 1){
                error.push("数量の入力が必須です。\n");
            }
            // if(check_tanka == 1){
            //     error.push("数量の入力が必須です。\n");
            // }

            if (dataOutMitsumori >= 1) {
                error.push("納入価格0円の商品が含まれています。その商品をカートから削除の上、再度処理を行ってください。\n");
            }

            if(dealer_error >= 1){
                alert("最初の1社のみチェックアウトしました。他の販売店分は再度チェックアウト処理してください。");
            }

            if(error.length > 0){
                alert(error.join(""));
                $('#checkout').prop('disabled', false);
                return false;
            }

            var urlEC10Po = "#search/simple-po";
            $.ajax({
                url: url,
                data: {
                    list_cart_id: list_cart_seq,
                    token: accessTokenCognito
                },
                type: 'GET',
                success: function (res) {
                    if(res.status == 100){
                        riot.mount('app','maintain',{ messege:res.messege });
                        return false;
                    }

                    if (res.errors == 'unable_order') {
                        let list_supp_sku = res.list_supp_sku.join("、");
                        alert('品番：' + list_supp_sku + 'は販売不可商品です。');
                        $('#checkout').prop('disabled', false);
                        return false;
                    }

                    if (res.http === '200') {
                        //$('#modal-send-order-message').fadeIn();
                        $('#send-order-message').attr('action', res.url);
                        $('#cxml-base64').val(res.data);

                        if(( name.indexOf('budget') > -1 || id.indexOf('budget') > -1 ) && dealer_error >= 1){
                            var formData = $('#send-order-message').serializeArray();
                            $.ajax({
                                url: res.url,
                                type: 'POST',
                                dataType: 'text/xml',
                                async: true,
                                data: formData,
                                success: function (res) {
                                    console.log(res);
                                },
                                error: function (xhr, stt, err) {
                                    console.log('xhr:');
                                    console.log(xhr);
                                    console.log('status:');
                                    console.log(stt);
                                    console.log('err:');
                                    console.log(err);
                                }
                            });
                            $('#img-loader').hide();
                            riot.route.exec();
                            $('#checkout').prop('disabled', false);
                        } else {
                            $('#send-order-message').submit();
                        }
//                        var urlAriba = res.url;
//                        var data = res.data;
//                        console.log('url to send Ariba: '+urlAriba);
//                        console.log('data to send Ariba: ');
//                        console.log(data);
//                        $.ajax({
//                            url: urlAriba,
//                            type: 'POST',
//                            dataType: 'text/xml',
//                            data: data,
//                            success: function (res) {
//                                alert('成功しました。');
//                                console.log(res);
//                                if (confirm('OrderMessageを送信しました')) {
//                                    $(location).attr("href", urlEC10Po);
//                                }
//                            },
//                            error: function (xhr, stt, err) {
//                                alert('エラー');
//                                console.log('xhr:');
//                                console.log(xhr);
//                                console.log('status:');
//                                console.log(stt);
//                                console.log('err:');
//                                console.log(err);
//                            }
//                        });
                    } else {
                        console.log(res);
                        alert('エラー');
                        $('#checkout').prop('disabled', false);
                    }
                },
                error: function () {
                    alert('エラー');
                    $('#checkout').prop('disabled', false);
                }
            });
        }
        $(function () {
            var spinner = $( ".spinner" ).spinner();
        })

    </script>
    <!--<footer id="footer">footer</footer>-->
</order-cart-punchout>

<order-history-po-punchout>

    <link rel="stylesheet" href="css/order-history.css">
    <div class="main">
        <div class="content">
            <div class="page-title">
                <h2>チェックアウト履歴</h2>
            </div>
            <div class="table-wrapper">
                <div class="table-head">
                    <div class="select-box">
                        <select id="sort_cart">
                            <option value="desc" selected="{ sort == 'desc' ? 'selected' : '' }">チェックアウトの新しい順</option>
                            <option value="asc" selected="{ sort == 'asc' ? 'selected' : '' }">チェックアウトの古い順</option>
                        </select>
                    </div>
                </div>
                <table class="blue-table">
                    <thead>
                    <tr>
                        <th>
                            <div>管理番号</div>
                            <div>見積管理番号</div>
                        </th>
                        <th>
                            <div>チェックアウト日</div>
                            <div>最終更新日</div>
                        </th>
                        <th>製品情報</th>
                        <th>販売店</th>
                        <th>注文数量</th>
                        <th>
                            <div>納入価格</div>
                            <div>納入金額</div>
                        </th>
                        <th></th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr each = {element, index in list_cart} id = { 'item-' + index }>
                    <td>
                        <div>{element.cart_seq}</div>
                        <div>{element.cart_seq_mitsumori_related}</div>
                    </td>
                    <td>
                        <div>{element.order_date}</div>
                        <div>{element.updatedate}</div>
                    </td>
                    <td class="left">
                        <ul>
                            <li>
                                <dl>
                                    <dt>品番</dt>
                                    <dd><a href={ (element.is_deleted == 1 || !element.item_sku_exist) ? '' : ('#search/basic_details-punchout/' + element.item_sku) } target="" style="{ (element.is_deleted == 1 || !element.item_sku_exist) ? 'color:black;text-decoration:none;cursor:auto;' : '' }">{ element.supp_sku }{element.inquiry != 1 && (element.is_deleted == 1 || !element.item_sku_exist) ? '(この商品はカタログから削除されています)' : ''}</a></dd>
                                </dl>
                            </li>
                            <li>
                                <dl>
                                    <dt>品名</dt>
                                    <dd>{ element.item_name }</dd>
                                </dl>
                            </li>
                            <li>
                                <dl>
                                    <dt>容量・規格</dt>
                                    <dd>{ element.capacity} {(element.capacity != '' && element.kikaku != '') ? '・' : '' } {element.kikaku }</dd>
                                </dl>
                            </li>
                            <li>
                                <dl>
                                    <dt>製造元</dt>
                                    <dd>{ element.maker_name }</dd>
                                </dl>
                            </li>
                            <li>
                                <dl>
                                    <dt>販売元</dt>
                                    <dd>{ element.sales_origin_maker_name }</dd>
                                </dl>
                            </li>
                            <li>
                                <b style="color:red;display:{(element.is_deleted == 1 ) ? 'block' : 'none'}">販売中止</b>
                            </li>
                        </ul>
                    </td>
                    <td>
                        <div>{ element.dealer_co_name }</div>
                        <div>{ element.dealer_dep_name }</div>
                    </td>
                    <td class="right">{ element.suryo }</td>
                    <td class="right" style="white-space:nowrap">
                        <div>{ !isNaN(parseFloat(element.tanka)) ? parseFloat(element.tanka).toLocaleString('en') : '' }円</div>
                        <div>{ parseFloat(element.suryo * element.tanka).toLocaleString('en') }円</div>
                    </td>
                    <td class="btntd" if={element.is_ariba}>
                        <button class="{compareValueDealer(element.dealer_dep_cd, element.dealer_co_cd) ? 'tooltips' : '' } color-btn red-btn" data-tooltips="{compareValueDealer(element.dealer_dep_cd, element.dealer_co_cd) ? '他の販売店の商品が既にカートに入っています。他の販売店の商品をチェックアウト後カートに入れることが可能です。' : ''}" if={element.is_deleted != 1 && element.item_sku_exist} style="display: { arColumn(list_button, 'navigation_id', 'B002').length ? 'inline' : 'none' }" onclick={ ( element.selling_tanka != 0 && element.selling_tanka != '' && element.scm_bio) ?  addToCart : '' } value="{ index }" attrCart="status_0" disabled={((element.selling_tanka == 0 || element.selling_tanka == '' || !element.scm_bio ) && element.inquiry != 1) || compareValueDealer(element.dealer_dep_cd, element.dealer_co_cd) || element.ariba_cart_btn_show != 1 ? 'disabled' : '' }><i class="fa fa-shopping-cart" aria-hidden="true" value="{ index }" attrCart="status_0" ></i>カートへ</button>
                        <span class="msg-item-sku-exist">{(element.inquiry == 1) ? '' : ((element.is_deleted == 1 || !element.item_sku_exist) ? 'この商品はカタログから削除されています' : '')}</span>
                        <input type="hidden" id="status_{index}" value="{element.status}">
                        <input type="hidden" id="customer_co_cd_{index}" value="{element.customer_co_cd}">

                        <input type="hidden" id="customer_dep_cd_{index}" value="{element.customer_dep_cd}">

                        <input type="hidden" id="ec_users_id_{index}" value="{element.ec_users_id}">
                    </td>

                    <td class="btntd" if={!element.is_ariba}>
                        <button class="{compareValueDealer(element.dealer_dep_cd, element.dealer_co_cd) ? 'tooltips' : '' } color-btn red-btn" data-tooltips="{compareValueDealer(element.dealer_dep_cd, element.dealer_co_cd) ? '他の販売店の商品が既にカートに入っています。他の販売店の商品をチェックアウト後カートに入れることが可能です。' : ''}" if={element.is_deleted != 1 && element.item_sku_exist} style="display: { arColumn(list_button, 'navigation_id', 'B002').length ? 'inline' : 'none' }" onclick={ ( element.selling_tanka != 0 && element.selling_tanka != '' && element.scm_bio) ?  addToCart : '' } value="{ index }" attrCart="status_0" disabled={((element.selling_tanka == 0 || element.selling_tanka == '' || !element.scm_bio ) && element.inquiry != 1) || compareValueDealer(element.dealer_dep_cd, element.dealer_co_cd) ? 'disabled' : '' }><i class="fa fa-shopping-cart" aria-hidden="true" value="{ index }" attrCart="status_0" ></i>カートへ</button>
                        <span class="msg-item-sku-exist">{(element.inquiry == 1) ? '' : ((element.is_deleted == 1 || !element.item_sku_exist) ? 'この商品はカタログから削除されています' : '')}</span>
                        <input type="hidden" id="status_{index}" value="{element.status}">
                        <input type="hidden" id="customer_co_cd_{index}" value="{element.customer_co_cd}">

                        <input type="hidden" id="customer_dep_cd_{index}" value="{element.customer_dep_cd}">

                        <input type="hidden" id="ec_users_id_{index}" value="{element.ec_users_id}">
                    </td>
                    </tr>
                    </tbody>
                </table>
                <div id="paging" class="text-center">
                    <ul class="pagination" id="pagination_ec51_po"></ul>
                </div>
            </div>
        </div>
    </div>
    <script>
        var user_info = JSON.parse(getItem('EcUserInfo'));
        this.list_cart = opts.result;
        this.list_button = user_info.list_navigation.B;
        this.list_dealer = opts.list_dealer;
        this.total = opts.total;
        this.sort = opts.sort;
        this.currentPage = 1;
        var thisTag = this;
        var page = 1;
        var totalPages = Math.ceil(this.total/LIMIT_ON_PAGE);

        var visiblePages = 1;
        if(totalPages != 0){
            visiblePages =  5;
        }
        $(function(){
            var $pagination = $('#pagination_ec51_po');
            $pagination.twbsPagination('destroy');
            $pagination.twbsPagination({
                totalPages: totalPages,
                visiblePages: visiblePages,
                startPage: thisTag.currentPage,
                initiateStartPageClick: false,
                onPageClick: function (event, page) {
                    thisTag.searchCarts(page);
                }
            });
            $("#sort_cart").on("change",function(e){
                var page = thisTag.currentPage;
                thisTag.searchCarts(page);
            });
        });
        this.compareValueDealer = function(dep_cd, co_cd){
            if(this.list_dealer == null){
                return false;
            }
            if(dep_cd != this.list_dealer.dealer_dep_cd || co_cd != this.list_dealer.dealer_co_cd) {
                return true;
            }
            return false;
        }
        this.searchCarts = function(page) {
            var accessTokenCognito = getItem('accessTokenCognito') !== null ? getItem('accessTokenCognito') : '';
            var status = '21';
            var screen = 'ec51-po';
            var sort = $("#sort_cart").val();
            var url = URL_API + '/api/punchout/cart/list?token=' + accessTokenCognito + '&status=' + status + '&order_order_date=' + sort + '&page=' + page + '&limit=' + LIMIT_ON_PAGE + '&screen=' + screen;
            $.ajax({
                url: url,
                type: 'GET',
                timeout: 60000,
                success: function (data) {
                    if(data.status == 100){
                        riot.mount('app','maintain',{ messege:data.messege });
                        return false;
                    }
                    thisTag.list_cart = data.cart_list;
                    thisTag.update(thisTag.list_cart);
                },
                error: function (xhr, stt, err) {
                    alert('エラー');
                }
            });
        }
        this.addToCart = function (e) {
            var index = e.target.value;
            var attrCart = $(e.target).attr('attrcart');
            var agent = localStorage.getItem('agent_id');
            var accessTokenCognito = localStorage.getItem('accessTokenCognito');
            var url = URL_API + '/api/punchout/cart/create?token=' + accessTokenCognito;
            var data = [];

            var raw_current_date = new Date();
            var current_date = raw_current_date.getFullYear() + "/" + (((raw_current_date.getMonth() + 1) < 10) ? "0":"") + (raw_current_date.getMonth() + 1) + "/" + ((raw_current_date.getDate() < 10) ? "0":"") + raw_current_date.getDate() + " " + ((raw_current_date.getHours() < 10) ? "0":"") + raw_current_date.getHours() + ":" + ((raw_current_date.getMinutes() < 10) ? "0":"") + raw_current_date.getMinutes() + ":" + ((raw_current_date.getSeconds() < 10) ? "0":"") + raw_current_date.getSeconds();

            // var selling_tanka_int = thisTag.list_cart[index].selling_tanka ? thisTag.list_cart[index].selling_tanka : '';
            switch(attrCart) {
                case 'status_0':
                    data.push({
                        supp_sku: thisTag.list_cart[index].supp_sku,
                        item_sku: thisTag.list_cart[index].item_sku,
                        item_name: thisTag.list_cart[index].item_name,
                        capacity: thisTag.list_cart[index].capacity,
                        kikaku: thisTag.list_cart[index].kikaku,
                        maker_name: thisTag.list_cart[index].maker_name,
                        supp_co_cd: thisTag.list_cart[index].supp_co_cd,
                        supp_co_name: thisTag.list_cart[index].supp_co_name,
                        customer_co_cd: thisTag.list_cart[index].customer_co_cd,
                        dealer_co_cd: thisTag.list_cart[index].dealer_co_cd,
                        dealer_dep_cd: thisTag.list_cart[index].dealer_dep_cd,
                        // dealer_co_name: thisTag.list_cart[index].dealer_co_name,
                        // tanka: thisTag.list_cart[index].tanka,
                        agent_users_id: agent,
                        // teika_tanka: thisTag.list_cart[index].list_price,
                        suryo: 1,
                        status: 0,
                    });
                    break;
                default:
            }

            $.ajax({
                url: url,
                type: 'POST',
                data: {
                    data: data,
                    screen: 'ec51'
                },
                success: function (data) {
                    if(data.status == 100){
                        riot.mount('app','maintain',{ messege:data.messege });
                        return false;
                    }
                    var page = 1;
                    thisTag.searchCarts(page);
                    switch(attrCart) {
                        case 'status_0':
                            alert('カートに追加しました。\nカート画面から発注処理を行ってください。');
                            break;
                        default:
                    }
                    riot.route.exec();
                },
                error: function (xhr, stt, error) {
                    alert('エラー');
                }
            });
        }
    </script>

</order-history-po-punchout>

<favorite-result-punchout>
    <div class="favorites-item" each={ element, index in list_cart } id= "{ 'favorites-item-' + index }">
        <div class="item-left">
            <input type="checkbox" name="{ 'list_cart[' + index + ']' }" value="{ element.cart_seq }" index="{ index }" disabled="{(element.is_deleted == 1 || !element.item_sku_exist || isNaN(parseInt(element.selling_tanka)) || (element.selling_tanka == 0) (element.checkCampaign && element.checkCampaignRetailPrice)) ? 'disabled' : ''}">
        </div>
        <div class="item-mid">
            <ul class="item-mid-top">
                <li>
                    <dl>
                        <dt>販売元メーカー</dt>
                        <dd>{ element.sales_origin_maker_name }</dd>
                        <input type="hidden" id="{'supp_co_name_'+index}" value="{element.supp_co_name}">
                        <input type="hidden" id="{'supp_co_cd_'+index}" value="{element.supp_co_cd}">
                    </dl>
                </li>
                <li>
                    <dl>
                        <dt>製造元メーカー</dt>
                        <dd>{ element.maker_name }</dd>
                        <input type="hidden" id="{'maker_name_'+index}" value="{element.maker_name}">
                    </dl>
                </li>
                <li>
                    <dl>
                        <dt>品番</dt>
                        <dd><a href={ (element.is_deleted == 1 || !element.item_sku_exist) ? '' : ('#search/basic_details-punchout/' + encodeURIComponent(element.item_sku)) } target="" style="{ (element.is_deleted == 1 || !element.item_sku_exist) ? 'color:black;text-decoration:none;cursor: auto;' : '' }">{ element.supp_sku }</a></dd>
                        <input type="hidden" id="{'supp_sku_'+index}" value="{element.supp_sku}">
                    </dl>
                </li>
                <li>
                    <dl>
                        <dt>品名</dt>
                        <dd>{ element.item_name }</dd>
                        <input type="hidden" id="{'item_name_'+index}" value="{element.item_name}">
                        <input type="hidden" id="{'item_sku_'+index}" value="{element.item_sku}">
                    </dl>
                </li>
                <li>
                    <dl>
                        <dt>容量・規格</dt>
                        <dd>{ element.capacity + ' ' + element.kikaku }</dd>
                        <input type="hidden" id="{'capacity_'+index}" value="{element.capacity}">
                        <input type="hidden" id="{'kikaku_'+index}" value="{element.kikaku}">
                    </dl>
                </li>
            </ul>
            <ul class="item-mid-bottom">
                <li>
                    <dl>
                        <dt>販売店</dt>
                        <dd>
                            <!-- <select class="list-dealer" id={'dealer_co_cd_'+index} onchange={dealerChange} name={ index }>
                                <option each={element2, index2 in products_dealer_customers_list} selected= {element.dealer_co_name == element2.dealer_co_name} value={element2.dealer_co_cd}>{ element2.dealer_co_name }</option>
                            </select> -->
                            <select class="list-dealer" id={'dealer_co_cd_'+index} onchange={dealerChange} name={ index } style="display: {(!element.products_dealer_customers_list || element.products_dealer_customers_list.length == 1 || element.products_dealer_customers_list.length == 0) ? 'none' : 'block'}">
                                <option each={element2, index2 in element.products_dealer_customers_list} value={element2.dealer_co_cd} data-dealer-dep="{element2.dealer_dep_cd}">{ element2.dealer_co_name } { element2.dealer_dep_name }</option>
                            </select>
                            {(element.products_dealer_customers_list.length == 1) ? element.products_dealer_customers_list[0].dealer_co_name : ''}
                            <input type="hidden" id="{'price_group_'+index}" value="{element.price_group}">
                        </dd>
                    </dl>
                </li>
            </ul>
            <ul class="item-mid-bottom">
                <li>
                    <dl>
                        <dt id="list_price_text_{index}" style="color: red" if="{campaign_retail_price_end_date(element.campaign_retail_price,element.campaign_start_date,element.campaign_end_date,element.campaign_published_date,element.campaign_close_date).length > 0}">キャンペーン価格</dt>
                        <dt id="list_price_text_{index}" if="{!campaign_retail_price_end_date(element.campaign_retail_price,element.campaign_start_date,element.campaign_end_date,element.campaign_published_date,element.campaign_close_date).length > 0}">定価</dt>

                            
                        <dd id="list_price_value_{index}" style="color: red" if={campaign_retail_price_end_date(element.campaign_retail_price,element.campaign_start_date,element.campaign_end_date,element.campaign_published_date,element.campaign_close_date).length > 0}>{ !isNaN(parseInt(element.campaign_retail_price)) && element.campaign_retail_price != 0 ? (parseInt(element.campaign_retail_price).toLocaleString('en') + '円' ) : 'お見積り' }</dd>
                        <dd id="list_price_value_{index}" if={!campaign_retail_price_end_date(element.campaign_retail_price,element.campaign_start_date,element.campaign_end_date,element.campaign_published_date,element.campaign_close_date).length > 0}>{ !isNaN(parseInt(element.list_price)) ? (element.list_price == 0 ? 'お見積り' : parseInt(element.list_price).toLocaleString('en') + '円' ) : '' }</dd>

                        <input type="hidden" id={'teika_tanka_'+index} value="{ element.list_price }">
                    </dl>
                </li>
                <li if={(element.checkCampaign && !element.checkCampaignRetailPrice) || !element.checkCampaign}>
                    <dl>
                        <dt>納入価格</dt>
                        <dd>

                            <span id={'selling_tanka_span_'+index}>{ !isNaN(parseInt(element.selling_tanka)) && element.selling_tanka != 0 ? (parseInt(element.selling_tanka).toLocaleString('en') + '円' ) : 'お見積り' }<span></dd>
                        <input type="hidden" id={'selling_tanka_'+index} value="{ element.selling_tanka }" >
                    </dl>
                </li>
            </ul>
        </div>
        <div class="item-right">
            <div class="item-right-1">
                <div class='alert-item-deleted' style="box-shadow: 1px 1px 1px 1px;font-weight: bold;font-size: 16px;padding: 10px;border: 1px solid;color: red;border-radius: 6px;display:{(element.is_deleted == 1) ? 'block' : 'none'}"><h4>販売中止</h4></div>
                <input type="hidden" id="check_deleted_{index}" value="{element.is_deleted}">
                <input type="hidden" id="check_item_sku_exist_{index}" value="{element.item_sku_exist}">
            </div>
            <div class="item-right-2">
                <ul>
                    <li><p class="date">登録日：{element.createdate}</p></li>

                    <li><a href="#" cart-seq="{ element.cart_seq }" value="{ index }" style="display: { arColumn(list_button, 'navigation_id', 'B001').length ? 'inline' : 'none' }" onclick = { removeFavorite } ><i class="fa fa-times" aria-hidden="true"></i>お気に入りから削除</a></li>

                    <li>
                        <b>数量：</b>

                        <input id={'suryo_'+index} class="order-input spinner" type="number" min="1" value="1" maxlength="10" max="999999999" oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);">


                        <button class="color-btn red-btn {compareValueDealer(element.dealer_dep_cd, element.dealer_co_cd)  ? '' : 'tooltips' }" data-tooltips="{compareValueDealer(element.dealer_dep_cd, element.dealer_co_cd) ? '' : '他の販売店の商品が既にカートに入っています。他の販売店の商品をチェックアウト後カートに入れることが可能です。'}" type="button" if={element.is_deleted != 1 && element.item_sku_exist} cart-seq="{ element.cart_seq }" value="{ index }" style="margin-top:4px;display: { arColumn(list_button, 'navigation_id', 'B002').length ? 'inline' : 'none' }" onclick = { (!isNaN(parseInt(element.selling_tanka)) && (element.selling_tanka != 0) && ((element.checkCampaign && !element.checkCampaignRetailPrice) || !element.checkCampaign)) && compareValueDealer(element.dealer_dep_cd, element.dealer_co_cd) ? addToCart : '' } disabled="{(!isNaN(parseInt(element.selling_tanka)) && (element.selling_tanka != 0) && ((element.checkCampaign && !element.checkCampaignRetailPrice) || !element.checkCampaign)) && compareValueDealer(element.dealer_dep_cd, element.dealer_co_cd) ? '' : 'disabled'}">{ arColumn(list_button, 'navigation_id', 'B002').length ? arColumn(list_button, 'navigation_id', 'B002')[0]['display_contents'] : '' }</button>
                        <span class="msg-item-sku-exist">{element.is_deleted == 1 || !element.item_sku_exist ? 'この商品はカタログから削除されています' : ''}</span>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    <script>
        var user_info = JSON.parse(getItem('EcUserInfo'));
        var thisTag = this;
        this.list_button = user_info.list_navigation.B;
        this.price_rounding_check = opts.price_rounding_check;
        this.list_cart = opts.result;
        this.list_dealer = opts.list_dealer;
        this.products_dealer_customers_list = '';
        var list_dealer_name = [];
        var list_dealer_selling = [];
        $.each(opts.result, function (i,e){
            thisTag.products_dealer_customers_list = e['products_dealer_customers_list'];
             opts.result[i]['checkCampaign'] = campaign_retail_price_end_date(e['campaign_retail_price'],e['campaign_start_date'],e['campaign_end_date'],e['campaign_published_date'],e['campaign_close_date']).length > 0;
            opts.result[i]['checkCampaignRetailPrice'] = isNaN(parseInt(e['campaign_retail_price'])) || parseInt(e['.campaign_retail_price']) < 1;
            return;
        });

        $.each(thisTag.products_dealer_customers_list, function (i, e) {
            list_dealer_selling.push(e.selling_tanka);
        });
        this.compareValueDealer = function(dep_cd, co_cd){
            if(this.list_dealer == null){
                return true;
            }
            if(dep_cd != this.list_dealer.dealer_dep_cd || co_cd != this.list_dealer.dealer_co_cd) {
                return false;
            }
            return true;
        };
        var accessCognito = getItem('accessTokenCognito');
        roundingPrice = function (number) {
            var lastone = number.toString().split('').pop();
            var lastkey = number.toString().length - 1;
            if(thisTag.price_rounding_check == 5){
                if(lastone < 5){
                    var newNumber = number.toString().substring(0,lastkey) + '0';
                } else if(lastone > 5){
                    var newNumber = number.toString().substring(0,lastkey) + '5';
                } else {
                    var newNumber = number;
                }

            } else {
                var newNumber = number;
            }

            return Math.round(newNumber);
        }
        addToCart = function (e) {
            var index = e.target.value;
            var deleted = $("#check_deleted_" + index).val();
            var agent = getItem('agent_id');
            if(deleted == 1){
                alert("商品の販売が中止されました。");
                return false;
            }

            var data = [];

            var thisCart = this.list_cart[index];
            var aribaFlg = 0; var dealerCoCd = ''; var dealerDepCd = '';
            if (typeof(thisCart['is_ariba']) != "undefined") {
                if (thisCart['is_ariba'] == '1') {
                    aribaFlg = 1;
                }
            }

            data.push({
                //cart_seq: this.list_cart[index].cart_seq,
                dealer_co_cd: aribaFlg ? thisCart['dealer_co_cd'] : $('#dealer_co_cd_'+index).val(),
                dealer_dep_cd: aribaFlg ? thisCart['dealer_dep_cd'] : $('#dealer_co_cd_'+index).find('option:selected').attr('data-dealer-dep'),
                dealer_co_name: $('#dealer_co_cd_'+index+' option:selected').text(),
                //teika_tanka: $('#teika_tanka_'+index).val(),
                //tanka: $('#selling_tanka_'+index).val(),
                suryo: $('#suryo_'+index).val(),
                status: 0,
                // supp_co_name: $('#supp_co_name_'+index).val(),
                supp_co_cd: $('#supp_co_cd_'+index).val(),
                maker_name: $('#maker_name_'+index).val(),
                maker_sku: $('#maker_sku_'+index).val(),
                item_name: $('#item_name_'+index).val(),
                item_sku: $('#item_sku_'+index).val(),
                capacity: $('#capacity_'+index).val(),
                kikaku: $('#kikaku_'+index).val(),
                supp_sku: $('#supp_sku_'+index).val(),
                agent_users_id: agent,
            });
            $.ajax({
                url: URL_API + '/api/punchout/cart/create?token=' + accessCognito + '&is_ariba=' + getItem('is_ec_ariba'),
                type: 'POST',
                data: {
                    data: data
                },
                success: function (data) {
                    if(data.status == 100){
                        riot.mount('app','maintain',{ messege:data.messege });
                        return false;
                    }
//                    $('#favorites-item-' + index).remove();
//                    total_cart_favorites--;
//                    $('#total_item').text('登録件数　' + total_cart_favorites + '件');
                    if (data.message && data.errors) {
                        var msg = [];
                        for(var i in res.errors){
                            var errors = res.errors[i];
                            for( var k in errors){
                                for(var h in errors[k]){
                                    if($.inArray(errors[k][h], msg ) == -1){
                                        msg.push(errors[k][h]);
                                    }
                                }
                            }
                        }
                        alert(msg.join("\n"));
                    } else {
                        alert('カートに追加しました。\nカート画面から発注処理を行ってください。');
                    }
                    riot.route.exec();
                },
                error: function (xhr, stt, error) {
                    alert('error');
                }
            });
        }
        removeFavorite = function (e) {
            var index = e.target.value;
            var cart_seq = this.list_cart[index].cart_seq;
            var agent = getItem('agent_id');
            var data = [];
            data.push({
                cart_seq: cart_seq,
                agent_users_id: agent,
                favorite_status: 0
            });

            $.ajax({
                url: URL_API + '/api/punchout/cart/create?token=' + accessCognito,
                type: 'POST',
                data: {
                    data: data
                },
                success: function (data) {
                    if(data.status == 100){
                        riot.mount('app','maintain',{ messege:data.messege });
                        return false;
                    }
                    alert('お気に入りリストから削除しました');
                    riot.route.exec();
                    // $('#favorites-item-' + index).remove();
                    // $('#favorites-item-' + index).remove();
                    // total_cart_favorites--;
                    // $('#total_item').text('登録件数　' + total_cart_favorites + '件');
                },
                error: function (xhr, stt, error) {
                    alert('error');
                }
            });
        }
        dealerChange = function (e) {
            var index = e.target.name;
            var id = e.target.id;
            var value = e.target.value;
            var dealer_dep_cd = e.target.selectedOptions[0].getAttribute('data-dealer-dep');
            var text = $('#'+id+' option:selected').text();
            var findIndex = list_dealer_name.indexOf(text);
            if (findIndex != -1) {
                $('#selling_tanka_'+index).text(list_dealer_selling[findIndex]);
            }
            let check_sku_exist = thisTag.list_cart[index].item_sku_exist;
            let check_is_deleted = thisTag.list_cart[index].is_deleted;
            if (!check_sku_exist || check_is_deleted == 1) return false;
            var accessTokenCognito = getItem('accessTokenCognito');
            var dealer_co_cd = value;
            var supp_co_cd = $('#supp_co_cd_'+index).val();
            var maker_name = $('#maker_name_'+index).val();
            var item_sku = $('#item_sku_'+index).val();
            var price_group = $('#price_group_'+index).val();
            var url = URL_API + '/api/prices_for_dealer';
            var query = [];
            query.push('token=' + accessTokenCognito);
            query.push('dealer_co_cd=' + dealer_co_cd);
            query.push('supp_co_cd=' + supp_co_cd);
            query.push('maker_name=' + maker_name);
            query.push('item_sku=' + item_sku);
            query.push('price_group=' + price_group);
            url += '?' + query.join('&');
            $.ajax({
                url: url,
                type: 'GET',
                timeout: 60000,
                success: function (data) {
                    if(data.status == 100){
                        riot.mount('app','maintain',{ messege:data.messege });
                        return false;
                    }
                    var teika_tanka = parseInt($("#teika_tanka_" + index).val());
                    var dealers = data.dealer_list;
                    let checkCampaign = campaign_retail_price_end_date(thisTag.list_cart[index].campaign_retail_price,thisTag.list_cart[index].campaign_start_date,thisTag.list_cart[index].campaign_end_date,thisTag.list_cart[index].campaign_published_date,thisTag.list_cart[index].campaign_close_date).length > 0;
                    if (checkCampaign) {
                        $('#list_price_text_' + index).text('キャンペーン価格');
                        $('#list_price_text_' + index).css('color', 'red');
                        let campaign_price = (!isNaN(data.campaign_price) && (data.campaign_price != 0)) ? (parseInt(data.campaign_price).toLocaleString('en') + '円') : 'お見積り';
                        $('#list_price_value_' + index).text(campaign_price);
                    } else {
                        $('#list_price_text_' + index).text('定価');
                        $('#list_price_text_' + index).css('color', 'black');
                        let list_price = (!isNaN(teika_tanka) && (teika_tanka != 0)) ? (parseInt(teika_tanka).toLocaleString('en') + '円') : 'お見積り';
                        $('#list_price_value_' + index).text(list_price);
                    }
                    var selling_tanka = dealers.selling_tanka;
                    var selling_tanka_span = $("#selling_tanka_span_" + index);
                    result = !isNaN(parseInt(dealers.selling_tanka)) || (dealers.selling_tanka != 0) ? Math.round(dealers.selling_tanka).toLocaleString('en') + '円' : 'お見積り'
                    $("#selling_tanka_" + index).val(selling_tanka);
                    thisTag.list_cart[index].selling_tanka = selling_tanka;
                    thisTag.list_cart[index].dealer_co_cd = value;
                    thisTag.list_cart[index].dealer_dep_cd = dealer_dep_cd;
                    thisTag.update(thisTag.list_cart[index]);
                    selling_tanka_span.html(result);
                },
                error: function (xhr, stt, err) {
                    alert('エラー');
                }
            });
        }
        $(function () {
            var spinner = $( ".spinner" ).spinner();
        })
    </script>

</favorite-result-punchout>

<ec23-po>
    <link rel="stylesheet" href="css/EC23-PO.css" type="text/css" />
    <link rel="stylesheet" href="css/EC23.css?v=1" type="text/css" />
    <div class="main">
        <div class="content">
            <div class="page-title">
                <h2>見積フォルダ</h2>
            </div>
            <!-- <div class="search-wrapper">
                <select id="types">
                    <option value="0">ステータスで絞り込む</option>
                    <option value="1">未依頼</option>
                    <option value="2">回答待ち</option>
                    <option value="3">回答済み</option>
                </select>var check_detail = arColumn(list_field, 'navigation_id', "S065").length;
            </div> -->
            <div class="table-head" style="display: { arColumn(list_field, 'navigation_id', 'SP23').length ?  '' : 'none'  }">
                <div class="table-head-left">
                    <select id="types">
                        <option value="0">ステータスで絞り込む</option>
                        <option value="1">未依頼</option>
                        <option value="2">回答待ち</option>
                        <option value="3">回答済み</option>
                        <option value="5">見積不可</option>
                        <option value="9">削除済み</option>
                    </select>
                  <!-- <button class="search-btn">検索</button> -->           
                </div>
                <div class="table-head-right">
                  <button class="color-btn red-btn" onclick="{addCartAll}"><i class="fa fa-shopping-cart"></i> 一括カート入れ</button>
                  <button class="color-btn gray-btn" onclick="{deleteItemCartAll}"><i class="fa fa-times"></i> 一括削除</button>
                  <button class="color-btn green-btn submit-checked" onclick="{estimateForUnsolicited}"> 一括見積依頼</button>
                </div>
              </div>
            <div class="table-wrapper">
                <table class="blue-table">
                    <thead>
                    <tr>
                        <th><div>管理番号</div>
                            <div>最終更新日</div>
                        </th>
                        <th style="width:30%">製品情報</th>
                        <th>販売店</th>
                        <th>見積依頼者</th>
                        <th style="width:45px">数量</th>
                        <th style="width:70px">
                            <div>納入価格</div>
                            <div>納入金額</div>
                        </th>
                        <th style="width:70px">
                            <div>定価</div>
                            <div>合計</div>
                        </th>
                        <th>
                            <div>販売店への<br/>コメント</div>
                            <div>ファイル添付</div>
                        </th>
                        <th style="width:82px">
                            <div>依頼日</div>
                            <div>回答日</div>
                        </th>
                        <th>
                            <div>ステータス</div>
                            <div>見積期限</div>
                            <div>注文履歴</div>
                        </th>
                        <th style="width:70px"></th>
                        <th style="width:20px">一括<br>処理</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr each="{item,index in cart_list}">
                        <td><div>{item.cart_seq}</div>
                            <div>{item.updatedate}</div>
                        </td>
                        <td class="left">
                            <dl>
                                <dt>品番</dt>
                                <dd><a href="{ (item.is_deleted == 1 || !item.item_sku_exist) ? '' : ('#search/basic_details-punchout/' + encodeURIComponent(item.item_sku)) }" style="{ (item.is_deleted == 1 || !item.item_sku_exist) ? 'color:black;text-decoration:none;cursor: auto;' : '' }">{item.supp_sku}</a></dd>
                            </dl>
                            <dl>
                                <dt>品名</dt>
                                <dd>{item.item_name}</dd>
                            </dl>
                            <dl>
                                <dt>容量・規格</dt>
                                <dd>{item.capacity}{item.kikaku}</dd>
                            </dl>
                            <dl>
                                <dt>製造元</dt>
                                <dd>{item.maker_name}</dd>
                            </dl>
                            <dl>
                                <dt>販売元</dt>
                                <dd>{item.sales_origin_maker_name}</dd>
                            </dl>
                            <dl>
                                <dd><b class="discontinued" style="color:red;display:{(item.is_deleted == 1 ) ? 'block' : 'none'}">販売中止</b></dd>
                            </dl>
                        </td>
                        <td>{item.dealer_co_name} { item.dealer_dep_name }</td>
                        <td>{item.customer_user_name}</td>
                        <td>
                            <input type="text" class="suryo spinner" id="suryo_{index}" name="suryo" value="{item.suryo ? item.suryo : 1}" index={index}></td>
                        <td>
                            <div if={item.mitsumori_status == 1 || item.mitsumori_status == 2}>{ !isNaN(parseInt(item.tanka)) && item.tanka && item.tanka != 0 ? parseInt(item.tanka).toLocaleString('en') + '円' : (item.mitsumori_status == 2 ? '見積依頼中' : '') }</div>
                            <div if={item.mitsumori_status == 1 || item.mitsumori_status == 2}>{ !isNaN(parseInt(item.tanka * item.suryo)) && item.tanka && item.tanka != 0 ? parseInt(item.tanka * (item.suryo  ? item.suryo : 1)).toLocaleString('en') + '円' : (item.mitsumori_status == 2 ? '見積依頼中' : '') }</div>

                            <div if={item.mitsumori_status == 3 || item.mitsumori_status == 9}>{ !isNaN(parseInt(item.tanka)) && item.tanka != 0 ? parseInt(item.tanka).toLocaleString('en') + '円' : '' }</div>
                            <div if={item.mitsumori_status == 3 || item.mitsumori_status == 9}>{ !isNaN(parseInt(item.tanka * item.suryo)) && item.tanka != 0 ? parseInt(item.tanka * (item.suryo ? item.suryo : 1)).toLocaleString('en') + '円' : '' }</div>
                        </td>
                        <td>
                            <div if={item.mitsumori_status == 1 || item.mitsumori_status == 2}>{ !isNaN(parseInt(item.teika_tanka)) && item.teika_tanka && item.teika_tanka != 0 ? parseInt(item.teika_tanka).toLocaleString('en') + '円' : (item.mitsumori_status == 2 ? '見積依頼中' : '') }</div>
                            <div if={item.mitsumori_status == 1 || item.mitsumori_status == 2}>{ (!isNaN(parseInt(item.teika_tanka * item.suryo)) && (item.teika_tanka * item.suryo) != 0) ? parseInt(item.teika_tanka * (item.suryo ? item.suryo : 1)).toLocaleString('en') + '円' : '見積依頼中' }</div>

                            <div if={item.mitsumori_status == 3 || item.mitsumori_status == 9}>{ !isNaN(parseInt(item.teika_tanka)) && item.teika_tanka != 0 ? parseInt(item.teika_tanka).toLocaleString('en') + '円' : '' }</div>
                            <div if={item.mitsumori_status == 3 || item.mitsumori_status == 9}>{ (!isNaN(parseInt(item.teika_tanka * item.suryo)) && (item.teika_tanka * item.suryo) != 0) ? parseInt(item.teika_tanka * (item.suryo ? item.suryo : 1)).toLocaleString('en') + '円' : '' }
                            </div>
                        </td>
                        <td>
                            <div>
                                <span id="comment_usr_color_{item.cart_seq}">(<span id="comment_usr_count_{item.cart_seq}">{ item.comment_usr ? item.comment_usr.length : 0 }</span>/200)</span>
                                <textarea id="comment_usr_{item.cart_seq}" class="comment_usr" name="comment_usr" onchange="{updateCart}">{item.comment_usr}</textarea>
                            </div>
                            <div>
                                <div style="text-align: center;!important" if={item.is_deleted != 1 &&  item.item_sku_exist && item.mitsumori_status == 1}>
                                  <i class="fa fa-paperclip add_file file_cart" id="add_file_{index}" index="{index}"></i>
                                  <i class="fa fa-times delete-file-icon" id="delete-file-icon_{index}" onclick="{deleteFile}" index="{index}" style="display: none"></i>
                                  <input class="file_upload" id="file_upload_{index}" index={index} type="file" name="file" style="display: none;">
                              </div>
                              <div style="text-align: center;!important" if={item.mitsumori_status != 1 && item.attachment}>
                                  <i class="fa fa-file file_cart" onclick="{downloadFile}" fileName="{item.attachment}" title="{item.attachment}"></i>
                              </div>
                            </div>
                          </td>
                        <td>
                            <div if={item.mitsumori_status != 1 }>{item.mitsumori_request_date}</div>
                            <div>{item.mitsumori_reply_date}</div>
                        </td>
                        <td>
                            <div style="text-align: center;">
                                <p>
                                    <virtual each={status in mitsumoriStatus} if={status.value == item.mitsumori_status} >
                                    {status.label}
                                    </virtual>
                                </p>
                                <a class="commentBtn" onclick="{commentModalOpen}" index={index} style="display:{(item.mitsumori_status != 3 || ( item.comment_cst1 == '' || item.comment_cst1 == null ) ) ? 'none':'block'}">回答コメント<i class="fa fa-commenting-o"></i></a>
                                <div style="text-align: center;!important" if={item.attachment1}>
                                    <i class="fa fa-file file_cart" onclick="{downloadFile}" fileName="{item.attachment1}" title="{item.attachment1}"></i>
                                </div>
                            </div>
                            <div style="text-align: center;" if={item.mitsumori_deadline}>
                                見積期限
                                {item.mitsumori_deadline}
                            </div>
                        </td>
                        <td class="btnTd" if={item.is_ariba}>
                            <button if={!compareDate(item.mitsumori_deadline)} class="color-btn red-btn {compareValueDealer(item.dealer_dep_cd, item.dealer_co_cd) ? 'tooltips' : '' }" data-tooltip = "{compareValueDealer(item.dealer_dep_cd, item.dealer_co_cd) ? '他の販売店の商品が既にカートに入っています。他の販売店の商品をチェックアウト後カートに入れることが可能です。' : ''}" onclick="{compareValueDealer(item.dealer_dep_cd, item.dealer_co_cd) && !item.scm_bio ?  '' : addCart }" index="{index}" style="display:{(item.inquiry == 1 && item.mitsumori_status == 3) ? 'block' : ((item.mitsumori_status != 3 || !item.item_sku_exist || item.is_deleted == 1)  ? 'none' : 'block') }" disabled={compareValueDealer(item.dealer_dep_cd, item.dealer_co_cd) || item.ariba_cart_btn_show != 1 ? 'disabled' : '' } ><i class="fa fa-shopping-cart" index="{index}"></i>カートへ</button>
                            <button if={compareDate(item.mitsumori_deadline)} class="color-btn red-btn {compareDate(item.mitsumori_deadline) ? 'tooltips' : ''}" data-tooltip = {compareDate(item.mitsumori_deadline) ? '見積期限が過ぎています' : ''} index="{index}" style="display:{(item.inquiry == 1 && item.mitsumori_status == 3) ? 'block' : ((item.mitsumori_status != 3 || !item.item_sku_exist || item.is_deleted == 1)  ? 'none' : 'block') }" disabled={compareDate(item.mitsumori_deadline) || !item.scm_bio ? 'disabled' : ''}><i class="fa fa-shopping-cart" index="{index}"></i>カート</button>
                            <button if={item.mitsumori_status == 1} class="color-btn green-btn" onclick={estimateForSingleUnsolicited} index={index}>見積依頼</button>
                            <button class="color-btn gray-btn" onclick="{deleteItemCart}"><i class="fa fa-times"></i>削除</button>
                            <span class="msg-item-sku-exist">{(item.inquiry == 1) ? '' : ((item.is_deleted == 1 || !item.item_sku_exist) ? 'この商品はカタログから削除されています' : '')}</span>
                            <input type="hidden" id="check_checked_{index}" value="{item.is_deleted}">
                        </td>
                        <td class="btnTd" if={!item.is_ariba}>
                            <button if={!compareDate(item.mitsumori_deadline)} class="color-btn red-btn {compareValueDealer(item.dealer_dep_cd, item.dealer_co_cd) ? 'tooltips' : '' }" data-tooltip = "{compareValueDealer(item.dealer_dep_cd, item.dealer_co_cd) ? '他の販売店の商品が既にカートに入っています。他の販売店の商品をチェックアウト後カートに入れることが可能です。' : ''}" onclick="{compareValueDealer(item.dealer_dep_cd, item.dealer_co_cd) && !item.scm_bio ?  '' : addCart }" index="{index}" style="display:{(item.inquiry == 1 && item.mitsumori_status == 3) ? 'block' : ((item.mitsumori_status != 3 || !item.item_sku_exist || item.is_deleted == 1)  ? 'none' : 'block') }" disabled={compareValueDealer(item.dealer_dep_cd, item.dealer_co_cd) ? 'disabled' : '' } ><i class="fa fa-shopping-cart" index="{index}"></i>カートへ</button>
                            <button if={compareDate(item.mitsumori_deadline)} class="color-btn red-btn {compareDate(item.mitsumori_deadline) ? 'tooltips' : ''}" data-tooltip = {compareDate(item.mitsumori_deadline) ? '見積期限が過ぎています' : ''} index="{index}" style="display:{(item.inquiry == 1 && item.mitsumori_status == 3) ? 'block' : ((item.mitsumori_status != 3 || !item.item_sku_exist || item.is_deleted == 1)  ? 'none' : 'block') }" disabled={compareDate(item.mitsumori_deadline) || !item.scm_bio ? 'disabled' : ''}><i class="fa fa-shopping-cart" index="{index}"></i>カート</button>
                            <button if={item.mitsumori_status == 1} class="color-btn green-btn" onclick={estimateForSingleUnsolicited} index={index}>見積依頼</button>
                            <button class="color-btn gray-btn" onclick="{deleteItemCart}"><i class="fa fa-times"></i>削除</button>
                            <span class="msg-item-sku-exist">{(item.inquiry == 1) ? '' : ((item.is_deleted == 1 || !item.item_sku_exist) ? 'この商品はカタログから削除されています' : '')}</span>
                            <input type="hidden" id="check_checked_{index}" value="{item.is_deleted}">
                        </td>
                        <td style="position: relative;">
                            <input if={!item.is_ariba} type="checkbox" class="checked-action-{index}" disabled={compareDate(item.mitsumori_deadline) ? 'disabled' : ''}>
                            <input if={item.is_ariba} type="checkbox" class="checked-action-{index}" disabled={compareDate(item.mitsumori_deadline) || item.ariba_cart_btn_show != 1 ? 'disabled' : ''}>
                            <div>
                            </div>
                          </td>
                    </tr>


                    </tbody>
                </table>
                <div id="paging" class="text-center">
                    <ul class="pagination" id="pagination_carts"></ul>
                </div>
                <!-- <div class="btn-wrapper">
                    <p>ボタン押下で未依頼分の見積依頼をします。</p>
                    <button class="color-btn green-btn" onclick="{estimateForUnsolicited }">見積を依頼する</button>
                </div> -->
            </div>
        </div>
    </div>
    <div class="modal-wrapper">
        <div class="o_modal" id="comment-modal">
            <div class="o_modal_box">
                <div class="o_modal_head">
                    <a id="comment-modal-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="comment-box">
                            <p><description id="description_{comment_index}"></description></p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        /* global $ */
        var user_info = JSON.parse(localStorage.getItem('EcUserInfo'));
        this.list_field = user_info.list_navigation.S;
        this.cart_list = opts.cart_list;
        this.mitsumoriStatus = [
          {value: '1', label: '未依頼'}, 
          {value: '2', label: '回答待ち'}, 
          {value: '3', label: '回答済み'},
          {value: '5', label: '見積不可'},
          {value: '9', label: '削除済み'}
        ];
        this.currentPage = 1;
        this.sort_field = 'updatedate';
        this.sort_value = 'desc';
        this.comment_cst1 = '';
        this.comment_index = '';
        var checkUploaded = false;
        thisTag = this;

        $(function(){
            thisTag.getCartList(thisTag.currentPage);

            // $('.search-btn').click(function(){
            //     thisTag.getCartList(thisTag.currentPage);
            // });
            $('.btn-wrapper').hide();
            $('#comment-modal-close').on('click',function(){
                $('#comment-modal').fadeOut();
            });
            // $('.search-btn').trigger('click');
            $("#types").on('change', function(e){
                var page = 1;
                thisTag.getCartList(page);
            });
            $(document).on('keyup', '.comment_usr', function() {
                var id = $(this).attr('id');
                var idExtract = id.split('_');
                var index = idExtract[idExtract.length - 1];
                var thisVal = $(this).val();
                // set the counter
                $('#comment_usr_count_'+index).text(thisVal.length);
                if( thisVal.length >= 200 ) {
                    $('#comment_usr_color_'+index).css('color', 'red');
                } else {
                    $('#comment_usr_color_'+index).css('color', '');
                }
            });
            $.each(thisTag.cart_list,function(i,e){
                riot.tag('description', '', function(opts) {
                    this.root.innerHTML = opts.r;
                });
                riot.mount('#description_' + i, {
                    r: e.comment_cst1
                })
                thisTag.update();
            });
        })
        this.compareDate = function(date) {
            var d = new Date();
            var thisDate = d.getFullYear() + '/' + convertDateTime(d.getMonth() + 1) + '/' + convertDateTime(d.getDate());
            var today = new Date(thisDate);
            if(date == '') {
                return false;
            }
            var dateCompare = new Date(date);
            if(dateCompare.getTime() >= today.getTime()) {
                return false;
            }
            return true;
        }
        function convertDateTime(dateTime){
            if(dateTime.toString().length<2){
                dateTime = '0' + dateTime.toString();
            }
            return dateTime
        }

        this.getCartList = function(page){
            countTotalCart();
            thisTag.currentPage = page;
            // var inTypes = [];
            // $( "input[name='types[]']" ).each(function(){
            //     if($(this).prop( "checked" )){
            //         inTypes.push($(this).val());
            //     }
            // });
            var inTypes = $("#types").val();
            var query = [];
            var screen = 'ec23';
            var accessTokenCognito = localStorage.getItem('accessTokenCognito');
            query.push('token=' + accessTokenCognito);
            if(inTypes != 0){
                query.push('mitsumori_status='+inTypes);
            } else if(inTypes == 0){
                inTypes = [1,2,3,5];
                query.push('mitsumori_status='+inTypes);
            }
            query.push('sort_field=' + thisTag.sort_field);
            query.push('sort_value=' + thisTag.sort_value);
            query.push('screen=' + screen);
            query.push('page=' + page);
            query.push('limit=' + LIMIT_ON_PAGE);
            var url = URL_API + '/api/punchout/cart/list';

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

            $.ajax({
                url: url,
                type: 'GET',
                timeout: 60000,
                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'){

                        thisTag.cart_list = res.cart_list;
                        thisTag.list_dealer = res.list_dealer;
                        thisTag.cart_list = thisTag.cart_list.filter(function(item) {
                            if(item.comment_usr){
                                item.comment_usr = item.comment_usr.replace(/<br>/g, "\n");
                            }
                            return item;

                        });
                        thisTag.compareValueDealer = function(dep_cd, co_cd){
                            if(thisTag.list_dealer == null) {
                                return false;
                            }
                            if(dep_cd != thisTag.list_dealer.dealer_dep_cd || co_cd != thisTag.list_dealer.dealer_co_cd) {
                                return true;
                            }
                            return false;
                        };
                        thisTag.checkConditionDisplay = function(mitsumori_status, item_sku_exist,is_deleted){
                            if(mitsumori_status != 3 || !item_sku_exist || is_deleted == 1)
                                return true;
                            return false;
                        };
                        if(res.cart_list.length>0 ){
                            $('.btn-wrapper').show();
                        }else{
                            $('.btn-wrapper').hide();
                        }
                        var totalPages = Math.ceil(res.total/LIMIT_ON_PAGE);
                        thisTag.total_page = totalPages;
                        var visiblePages = 1;
                        if(totalPages != 0){
                            visiblePages =  5;
                        }
                        var $pagination = $('#pagination_carts');
                        $pagination.twbsPagination('destroy');
                        $pagination.twbsPagination({
                            totalPages: totalPages,
                            visiblePages: visiblePages,
                            startPage: thisTag.currentPage,
                            initiateStartPageClick: false,
                            onPageClick: function (event, page) {

                                thisTag.getCartList(page);
                            }
                        });

                        thisTag.update(thisTag.cart_list);
                        selectFile();
                        var spinner = $( ".spinner" ).spinner();
                        $( ".suryo" ).spinner({
                            stop: function( event, ui ) {
                                var index = event.target.attributes.index.value;
                                var target = $(event.target);
                                var thisTr = $(event.target).parents('tr');
                                var suryo = thisTr.find("input[name='suryo']").val();

                                if(suryo.length > 10){
                                    alert('数量を10文字以内に入力してください。');
                                    suryo = thisTr.find("input[name='suryo']").val(1)
                                    return false;
                                }

                                var patt = /^(0)?(\.\d+)?$/;
                                var patt2 = /^([1-9]+)([0-9]*)$/;
                                if(!patt2.test(suryo)){
                                    alert('数量を正数のみで入力してください。');
                                    thisTr.find("input[name='suryo']").val(1);
                                    suryo = 1;
                                }
                                thisTag.cart_list[index].suryo = suryo;
                                thisTag.update(thisTag.cart_list);
                                $.each(thisTag.cart_list,function(i,e){
                                    riot.tag('description', '', function(opts) {
                                        this.root.innerHTML = opts.r;
                                    });
                                    riot.mount('#description_' + i, {
                                        r: e.comment_cst1
                                    })
                                    thisTag.update();
                                });
                            }
                        });
                        $.each(thisTag.cart_list,function(i,e){
                            riot.tag('description', '', function(opts) {
                                this.root.innerHTML = opts.r;
                            });
                            riot.mount('#description_' + i, {
                                r: e.comment_cst1
                            })
                            thisTag.update();
                        });
                    }
                },
                error: function (xhr, stt, err) {
                    alert('error');
                }
            });

        }
        /*  ↓↓↓ NEW ↓↓↓  */
        this.commentModalOpen = function(e){
            $('#comment-modal').fadeIn();
            var comment = e.item.item.comment_cst1;
            thisTag.comment_index = e.item.index;
            thisTag.comment_cst1 = comment;
            thisTag.update(thisTag.comment_cst1);
            thisTag.update(thisTag.comment_index);
            $.each(thisTag.cart_list,function(i,e){
                riot.tag('description', '', function(opts) {
                    this.root.innerHTML = opts.r;
                });
                riot.mount('#description_' + i, {
                    r: e.comment_cst1
                })
                thisTag.update();
            });
        }
        this.addCart = function(e){
            var target = $(e.target);
            var thisTr = $(e.target).parents('tr');
            var index = $(target).attr("index");
            var agent = localStorage.getItem('agent_id');
            var deleted = $("#check_checked_"+index).val();
            if(deleted == 1){
                alert("商品の販売が中止されました。");
                return false;
            }

            var suryo = thisTr.find(".suryo").val();
            if(suryo == ''){
                alert("数量は必須項目です。");
                thisTr.find(".suryo").val(1);
                return false;
            }
            var item = e.item.item;
            var query = [];
            var accessTokenCognito = localStorage.getItem('accessTokenCognito');
            query.push('token=' + accessTokenCognito);
            var url = URL_API + '/api/punchout/cart/create';

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

            var data = [];
            data.push({
                cart_seq_mitsumori_related: item.cart_seq,
                dealer_co_cd: item.dealer_co_cd,
                dealer_dep_cd: item.dealer_dep_cd,
                dealer_co_name: item.dealer_co_name,
                dealer_dep_name: item.dealer_dep_name,
                customer_co_cd:item.customer_co_cd,
                customer_dep_cd:item.customer_dep_cd,
                supp_co_cd: item.supp_co_cd,
                supp_co_name: item.supp_co_name,
                maker_name:item.maker_name,
                supp_sku: item.supp_sku,
                item_sku: item.item_sku,
                item_name: item.item_name,
                capacity: item.capacity,
                kikaku: item.kikaku,
                suryo: item.suryo,
                tanka: item.tanka,
                teika_tanka: item.list_price,
                agent_users_id: agent,
                inquiry: item.inquiry,
                // comment_cst1:'見積管理番号：' + item.cart_seq,
                // mitsumori_request_date: mitsumori_request_date
                status: 0
            });

            $.ajax({
                url: url,
                type: 'POST',
                timeout: 60000,
                data: {
                    data: data
                },
                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('カートに追加しました。\nカート画面から発注処理を行ってください。');
                        var page = 1;
                        thisTag.getCartList(page);
                    }else if(res.message == 'errors'){
                        alert("処理が実行できませんでした。時間をおいて再度お試しください。同様のメッセージが再度出る場合はお手数ですがシステム提供者にご連絡ください。");
                    }
                },
                error: function (xhr, stt, err) {
                    alert('error');
                }
            });
        }

        this.deleteItemCart = function(e){
            var target = $(e.target);
            var thisTr = $(e.target).parents('tr');
            var agent = localStorage.getItem('agent_id');
            var item = e.item;
            var query = [];
            var accessTokenCognito = localStorage.getItem('accessTokenCognito');
            query.push('token=' + accessTokenCognito);
            var url = URL_API + '/api/punchout/cart/delete';

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

            var data = [];
            data.push({
                cart_seq: item.item.cart_seq,
                agent_users_id: agent,
                mitsumori_status: 9,
                old_attachment: item.item.attachment
            });

            $.ajax({
                url: url,
                type: 'POST',
                timeout: 60000,
                data: {
                    data: data
                },
                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('削除しました。');
                        var page = 1;
                        thisTag.getCartList(page);
                    }
                },
                error: function (xhr, stt, err) {
                    alert('error');
                }
            });
        }
        this.updateSuryoCart = function(e){
            var target = $(e.target);
            var thisTr = $(e.target).parents('tr');
            var suryo = thisTr.find("input[name='suryo']").val();

            if(suryo.length > 10){
                alert('数量を10文字以内に入力してください。');
                suryo = thisTr.find("input[name='suryo']").val(1)
                return false;
            }
            var patt = /^(0)?(\.\d+)?$/;
            var patt2 = /^([1-9]+)([0-9]*)$/;
            if(!patt2.test(suryo)){
                alert('数量を正数のみで入力してください。');
                thisTr.find("input[name='suryo']").val(1);
                suryo = 1;
            }
            var itemUpdate = e.item;
            itemUpdate.item.suryo = suryo;
            this.cart_list = this.cart_list.filter(function(item) {
                if(this.item.cart_seq == item.cart_seq){
                    return this;
                }else{
                    return item;
                }

            }, itemUpdate);
        }
        this.updateCart = function(e){
            var target = $(e.target);
            var thisTr = $(e.target).parents('tr');
            var comment_usr = thisTr.find("textarea[name='comment_usr']").val();
            var itemUpdate = e.item;
            itemUpdate.item.comment_usr = comment_usr;
            this.cart_list = this.cart_list.filter(function(item) {
                if(this.item.cart_seq == item.cart_seq){
                    return this;
                }else{
                    return item;
                }

            }, itemUpdate);

        }
        this.estimateForUnsolicited = function(e){
            var checkSuryo = true;
            var item_sku_exist = true;
            var is_deleted = false;
            var pattern = /^[0-9]*$/;
            var error = [];
            var query = [];
            var comment_usr_max_error = 0;
            var agent = localStorage.getItem('agent_id');
            var accessTokenCognito = localStorage.getItem('accessTokenCognito');
            query.push('token=' + accessTokenCognito);
            var url = URL_API + '/api/punchout/cart/create';

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

            var data = [];
            var formData = new FormData();
            var d = new Date();
            var mitsumori_request_date = d.getFullYear() + '-' + convertDateTime(d.getMonth()+1) + '-' + convertDateTime(d.getDate()) + ' ' + convertDateTime(d.getHours()) + ':' +convertDateTime(d.getMinutes()) + ':' + convertDateTime(d.getSeconds());

            for (var i = 0; i < thisTag.cart_list.length; i++) {
                if ($('#file_upload_' + i).val() != '' && $('#file_upload_' + i).val() !== undefined) {
                  file_upload = $("#file_upload_" + i)[0].files[0];
                  formData.append('file_upload_' + thisTag.cart_list[i].cart_seq, file_upload);
                }
            }
            $.each(thisTag.cart_list, function( index, item ) {
                
                if($(".checked-action-"+index).prop("checked") == true){
                    if(item.inquiry != 1) {
                        if(item.is_deleted == 1){
                            is_deleted = true;
                        }
                        if(!item.item_sku_exist){
                            item_sku_exist = false;
                        }
                    }
                    if(item.mitsumori_status == '1'){
                        if(item.comment_usr){
                            item.comment_usr = item.comment_usr.replace(/\n/g, "<br>");
                        }
                        data.push({
                            cart_seq: item.cart_seq,
                            dealer_co_cd: item.dealer_co_cd,
                            dealer_dep_cd: item.dealer_dep_cd,
                            suryo: item.suryo,
                            comment_usr: item.comment_usr,
                            mitsumori_status: 2,
                            agent_users_id: agent,
                            mitsumori_request_date: mitsumori_request_date,
                            screen: 'ec23-po',
                            table: item.table
                        });
                    }
                    if($('#comment_usr_' + item.cart_seq).val().length >= 200){
                        comment_usr_max_error++;
                    }
                }
            });
            formData.append('cart_info', JSON.stringify(data));
            $('.suryo').each(function(i,e){
                if(e.value == '' || !pattern.test(e.value)){
                    checkSuryo = false;
                }
            });
            if(checkSuryo == false){
                error.push("数量は必須項目です。\n");
            }
            if(!item_sku_exist || is_deleted){
                error.push("カタログから削除された商品が含まれています。\nその商品を見積フォルダから削除の上、再度見積依頼をお願いします。\n");
            }
            if(comment_usr_max_error){
                error.push("販売店へのコメントを200文字以内で入れてください。\n");
            }
            if(error.length > 0){
                alert(error.join(""));
                return false;
            }
            if(data.length>0){
                $.ajax({
                    url: url,
                    type: 'POST',
                    timeout: 60000,
                    dataType: 'JSON',
                    data: formData,
                    mimeType: "multipart/form-data",
                    contentType: false,
                    cache : false,
                    processData: false,
                    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('見積依頼をしました。\n販売店からの見積回答をお待ちください。');
                            var page = 1;
                            thisTag.getCartList(page);
                        }else if(res.message == 'errors'){
                            thisTag.cart_list = thisTag.cart_list.filter(function(item) {
                                if(item.comment_usr){
                                    item.comment_usr = item.comment_usr.replace(/<br>/g, "\n");
                                }
                                return item;

                            });
                            thisTag.update();

                            // var msg = [];
                            // for(var i in res.errors){
                            //     var errors = res.errors[i];
                            //     for( var k in errors){
                            //         for(var h in errors[k]){
                            //             if($.inArray(errors[k][h], msg ) == -1){
                            //                 msg.push(errors[k][h]);
                            //             }
                            //         }
                            //     }
                            // }

                            // alert(msg.join("\n"));
                            alert("処理が実行できませんでした。時間をおいて再度お試しください。同様のメッセージが再度出る場合はお手数ですがシステム提供者にご連絡ください。");
                        }
                    },
                    error: function (xhr, stt, err) {
                        alert('error');
                    }
                });
            }else{
                alert('未依頼分の見積依頼がありません');
            }

        }
        this.deleteFile = function (e) {
          var index = $(e.target).attr('index');
          if (index) {
            $('#file_upload_' + index).val('');
            $('#delete-file-icon_' + index).hide();
            noFile(index);
          }
        }
        /*this code added by asif*/
        this.addCartAll = function(e){
        var checkSuryo = true;
        var item_sku_exist = true;
        var item_mitsu_status_wrong = true;
        var is_deleted = false;
        var pattern = /^[0-9]*$/;
        var error = [];
        var query = [];
        var agent = localStorage.getItem('agent_id');
        var accessTokenCognito = localStorage.getItem('accessTokenCognito');
            query.push('token=' + accessTokenCognito);
        var url = URL_API + '/api/punchout/cart/create';
        
        url += '?' + query.join('&');
        
        var data = [];
        $.each(thisTag.cart_list, function( index, item ) {

            var checked = $(".checked-action-" + index).is(":checked");

            if (checked) {
                if(item.inquiry != 1) {
                    if(item.is_deleted == 1){
                        is_deleted = true;
                    }
                    if(!item.item_sku_exist){
                        item_sku_exist = false;
                    }
                }
                if(IWAI_SITE) {
                    var suryo = $("#suryo_" + index).val();
                    if(suryo == '' || !pattern.test(suryo)){
                        checkSuryo = false;
                        $("#suryo_" + index).val(1);
                    }
                }

                if(item.mitsumori_status == 3) {
                    data.push({
                        cart_seq_mitsumori_related: item.cart_seq,
                        dealer_co_cd: item.dealer_co_cd,
                        dealer_co_name: item.dealer_co_name,
                        dealer_dep_cd: item.dealer_dep_cd,
                        customer_co_cd:item.customer_co_cd,
                        customer_dep_cd:item.customer_dep_cd,
                        supp_co_cd: item.supp_co_cd,
                        supp_co_name: item.supp_co_name,
                        maker_name:item.maker_name,
                        supp_sku: item.supp_sku,
                        item_sku: item.item_sku,
                        item_name: item.item_name,
                        capacity: item.capacity,
                        kikaku: item.kikaku,
                        suryo: item.suryo,
                        tanka: item.tanka,
                        teika_tanka: item.list_price,
                        agent_users_id: agent,
                        inquiry: item.inquiry,
                        // comment_cst1:'見積管理番号：' + item.cart_seq,
                        status: 0
                    });
                } else {
                    item_mitsu_status_wrong = false;
                }
            }
        });
        if(!item_mitsu_status_wrong) {
            error.push("カートに入れられる商品はステータス：「回答済み」のみとなります\n");
        }
        
        if(IWAI_SITE) {
          if(checkSuryo == false){
              error.push("数量は必須項目です。\n");
          }
        }

        if(!item_sku_exist || is_deleted){
            error.push("カタログから削除された商品が含まれています。\nその商品を見積フォルダから削除の上、再度見積依頼をお願いします。\n");
        }

        if(error.length > 0){
            alert(error.join(""));
            return false;
        }

        if(data.length>0){
           $.ajax({
                url: url,
                type: 'POST',
                timeout: 60000,
                data: {
                    data: data
                },
                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('カートに追加しました。\nカート画面から発注処理を行ってください。');
                        var page = 1;
                        thisTag.getCartList(page);
                    } else if(res.message == 'errors'){
                        
                    }
                },
                error: function (xhr, stt, err) {
                    alert('error');
                }
            });
       } else {
           alert('処理対象を選択してください。');
       }
       
    }
    this.deleteItemCartAll = function(e){
        
        if(!confirm("選択した商品を削除しますか")) {
          return false;
        }
        
        var query = [];
        var agent = localStorage.getItem('agent_id');
        var accessTokenCognito = localStorage.getItem('accessTokenCognito');
            query.push('token=' + accessTokenCognito);
        var url = URL_API + '/api/cart/delete';
        
        url += '?' + query.join('&');
        
        var data = [];
        $.each(thisTag.cart_list, function( index, item ) {

          var checked = $(".checked-action-" + index).is(":checked");

          if(checked) {
            data.push({
                cart_seq: item.cart_seq,
                agent_users_id: agent,
                old_attachment: item.attachment
            });
          }
              
        });

        if(data.length > 0){
           $.ajax({
                url: url,
                type: 'POST',
                timeout: 60000,
                data: {
                    data: data
                },
                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('削除しました。');
                        var page = 1;
                        thisTag.getCartList(page);
                    } else if(res.message == 'errors'){
                        
                    }
                },
                error: function (xhr, stt, err) {
                    alert('error');
                }
            });
       }else{
           alert('処理対象を選択してください。');
       }
    }
    this.estimateForSingleUnsolicited = function(e){

        var checkSuryo = true;
        var item_sku_exist = true;
        var is_deleted = false;
        var pattern = /^[0-9]*$/;
        var checkMitsumoriStatus = true;
        var error = [];
        var submitChecked = $(e.target).hasClass("submit-checked");
        var query = [];
        var agent = localStorage.getItem('agent_id');
        var accessTokenCognito = localStorage.getItem('accessTokenCognito');
            query.push('token=' + accessTokenCognito);
        var url = URL_API + '/api/punchout/cart/create';
        var i = $(e.target).attr('index');
        var item = thisTag.cart_list[i];
        url += '?' + query.join('&');
        var data = [];
        var formData = new FormData();
        var d = new Date();
        var comment_usr_max_error = 0;
        var mitsumori_request_date = d.getFullYear() + '-' + convertDateTime(d.getMonth()+1) + '-' + convertDateTime(d.getDate()) + ' ' + convertDateTime(d.getHours()) + ':' +convertDateTime(d.getMinutes()) + ':' + convertDateTime(d.getSeconds());
        if ($('#file_upload_' + i).val() != '' && $('#file_upload_' + i).val() !== undefined) {
          file_upload = $("#file_upload_" + i)[0].files[0];
          formData.append('file_upload_' + thisTag.cart_list[i].cart_seq, file_upload);
        }
        
        if (item.is_deleted == 1) {
          is_deleted = true;
        }
        if (!item.item_sku_exist) {
          item_sku_exist = false;
        }
        var suryo = $("#suryo_" + i).val();
        if (suryo == '' || !pattern.test(suryo)) {
          checkSuryo = false;
          $("#suryo_" + i).val(1);
        }
        if (item.mitsumori_status == '1' || item.mitsumori_status == '5') {
            var dr = $(e.target).attr('dt');
            if((dr=='1' && dr!="undefined") && (item.comment_usr=="" || item.comment_usr=='null' || item.comment_usr==null)){
              alert("販売店へのコメントは入力必須です。");
              return false;
            }
            if(item.comment_usr){
                item.comment_usr = item.comment_usr.replace(/\n/g, "<br>");
            }
            if($('#comment_usr_' + item.cart_seq).val().length >= 200){
              comment_usr_max_error++;
            }
            data.push({
                cart_seq: item.cart_seq,
                dealer_co_cd: item.dealer_co_cd,
                dealer_dep_cd: item.dealer_dep_cd,
                suryo: item.suryo,
                comment_usr: item.comment_usr,
                mitsumori_status: 2,
                agent_users_id: agent,
                mitsumori_request_date: mitsumori_request_date,
                screen: 'ec23-po',
                table: item.table
            });
            formData.append('cart_info', JSON.stringify(data));
        } else {
          checkMitsumoriStatus = false;
        }
        formData.append('cart_info', JSON.stringify(data));
        if (checkMitsumoriStatus == false) {
            error.push("未依頼の処理対象を選択してください\n");
        }
        if (checkSuryo == false) {
            error.push("数量は必須項目です。\n");
        }
        if (!item_sku_exist || is_deleted) {
            error.push("カタログから削除された商品が含まれています。\nその商品を見積フォルダから削除の上、再度見積依頼をお願いします。\n");
        }
        if(comment_usr_max_error){
            error.push("販売店へのコメントを200文字以内で入れてください。");
        }
        if (error.length > 0) {
            alert(error.join(""));
            return false;
        }

        if (data.length>0) {
           $.ajax({
            url: url,
            type: 'POST',
            timeout: 60000,
            dataType: 'JSON',
            data: formData,
            mimeType: "multipart/form-data",
            contentType: false,
            cache : false,
            processData: false,
            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('見積依頼をしました。\n販売店からの見積回答をお待ちください。');
                var page = 1;
                thisTag.getCartList(page);
              }else if(res.message == 'errors'){
                thisTag.cart_list = thisTag.cart_list.filter(function(item) {
                  if(item.comment_usr){
                    item.comment_usr = item.comment_usr.replace(/<br>/g, "\n");
                  }
                  return item;
                });
                thisTag.update();
                alert("処理が実行できませんでした。時間をおいて再度お試しください。同様のメッセージが再度出る場合はお手数ですがシステム提供者にご連絡ください。");
              }
            },
            error: function (xhr, stt, err) {
              alert('error');
            }
        });
      } else {
        alert('処理対象を選択してください。');
      }
    }
    </script>

</ec23-po>

<campaign-data>
    <link rel="stylesheet" href="css/EC61.css">
    <div class="main">
        <div class="content">
            <div class="page-title">
                <h2>キャンペーン情報</h2>
            </div>
            <div class="form-wrapper" id="e61_search">
                <table>
                    <tr>
                        <th style="width:65px">メーカー</th>
                        <td><div class="div-wraper-autocompleter"><input type="text" id="companies_supplier"></div>
                            <input type="hidden" class="companies_manufacture_code"></td>
                        <td class="checkTd">
                            <div><label><input type="checkbox" checked="checked" class="currently_in_progress">現在実施中のもの</label></div>
                            <div>
                                <input type="checkbox" class="inputActive">
                                <input type="text" class="camp_start_date dateInput" disabled>～<input type="text" class="camp_end_date dateInput" disabled>の間に実施中のもの
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="7" class="btnTd">
                            <button type="button" class="submit" id="searchCampainProduct"><i class="fa fa-search"></i>この条件で絞り込む</button>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="sort">
                <label>並べ替え：</label>
                <select id="sortCreateDate">
                    <option each="{sortType in sortTypes}" value="{sortType.value}" selected="{sortType.value == sort_value}">{sortType.label}</option>
                </select>
            </div>
            <div class="result-wrapper">
                <div class="campaign-wrap" each="{campainProduct in campainProducts}">
                    <div class="campaign-top">
                        <h1 class="campaign-title">
                            <a href="{campainProduct.url}" target="_blank" style="display:{campainProduct.url ? 'block' : 'none'}">{campainProduct.camp_name}</a>
                            <span style="display:{campainProduct.url ? 'none' : 'block'}">{campainProduct.camp_name}</span>
                            <!-- <span>{campainProduct.camp_name}</span> -->
                        </h1>
                        <dl>
                            <dt>登録日</dt>
                            <dd>{campainProduct.createdate.substr(0, 10)}</dd>
                        </dl>
                    </div>
                    <div class="campaign-main">
                        <dl>
                            <dt>期間</dt>
                            <dd>{campainProduct.camp_start_date.substr(0, 10)}～{campainProduct.camp_end_date.substr(0, 10)}（ご注文分）</dd>
                        </dl>
                        <dl>
                            <dt>メーカー</dt>
                            <dd>{campainProduct.comp_name}</dd>
                        </dl>
                        <dl if="{campainProduct.member_type != 0 }">
                          <dd>{campainProduct.dealer_co_name}</dd>
                        </dl>
                        <p><img src="{campainProduct.image_url}" style="max-width: 500px; max-height: 300px;" if={campainProduct.image_url}></p>
                        <p class="campaign-detail">
                            {campainProduct.description}
                        </p>
                    </div>
                </div>

            </div>
            <div id="paging" class="text-center">
                <ul class="pagination" id="pagination_campain_product"></ul>
            </div>
        </div>
    </div>
    <script>
        this.supplierList = opts.supplierList;
        this.publicStatuses = opts.publicStatuses;
        this.campainProducts = [];
        this.currentPage = 1;
        this.sortTypes = [{label:'登録日の新しい順', value: 'DESC'},{label:'登録日の古い順', value: 'ASC'}]
        this.sort_field = 'createdate';
        this.sort_value = 'DESC';
        thisTag = this;
        $(function(){

            /*↓↓↓new add↓↓↓*/
            $('.inputActive').on('click',function(){
                if($(this).is(':checked')){
                    $('.dateInput').prop('disabled',false);
                }else{
                    $('.dateInput').prop('disabled',true);
                    $('.dateInput').val('');
                }
            });
            /*↑↑↑new add↑↑↑*/

            $('#companies_supplier').autocompleter({ limit:10, source: opts.supplierList,
                callback: function(value, index){
                    $('#e61_search .companies_manufacture_code').val(opts.supplierList[index].comp_code);
                }
            });

            $('#e61_search .camp_start_date').datetimepicker({
                format: 'Y-m-d',
                onShow:function( ct ){
                    this.setOptions({
                        maxDate:$('#e61_search .camp_end_date').val()?$('#e61_search .camp_end_date').val():false
                    })
                },

                timepicker:false
            });
            $('#e61_search .camp_end_date').datetimepicker({
                format: 'Y-m-d',
                onShow:function( ct ){
                    this.setOptions({
                        minDate:$('#e61_search .camp_start_date').val()?$('#e61_search .camp_start_date').val():false
                    })
                },

                timepicker:false
            });
            $('#e61_search .reset-btn').click(function(){
                $('#e61_search .companies_manufacture_code').val('');
                $('#e61_search #companies_supplier').val('');
                $('#e61_search .camp_start_date').val('');
                $('#e61_search .camp_end_date').val('');
                $('#e61_search .currently_in_progress').prop('checked', true);
            });
            $('#sortCreateDate').change(function(){
                thisTag.sort_value = thisTag.sort_value == 'DESC'? 'ASC': 'DESC';
                var page = thisTag.currentPage;
                searchCampainProduct(page);
            })
            $('#searchCampainProduct').click(function(){
                var page = 1;
                searchCampainProduct(page);
            });
            $('#searchCampainProduct').trigger('click');
        })
        function searchCampainProduct(page){
            thisTag.currentPage = page;
            var supplier_name = $('#e61_search #companies_supplier').val();
            var supplier_code = $('#e61_search .companies_manufacture_code').val();
            var currently_in_progress = '';

            var camp_start_date =  $('#e61_search .camp_start_date').val();
            var camp_end_date =  $('#e61_search .camp_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/campaign/get';

//        var url = 'http://ec-webapi.local/api/campaign/get';

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

            for(var k in opts.supplierList ){
                var supplier = opts.supplierList[k];
                if(supplier.comp_code == supplier_code){
                    if(supplier.value != supplier_name){
                        supplier_code = '';
                    }
                }
            }

            var data = {};
            var public_statuses = ['0'];
            var inputActive = 0;
            if($('#e61_search .inputActive').prop( "checked" )){
                inputActive = 1;
            }
            if($('#e61_search .currently_in_progress').prop( "checked" )){
                currently_in_progress = 1;
                data = {
                    comp_name: supplier_name,
                    comp_code: supplier_code,
                    camp_currently_in_progress: (currently_in_progress == '')? null: currently_in_progress,
                    is_hidden: public_statuses,
                    inputActive: inputActive,
                    camp_start_date: camp_start_date,
                    camp_end_date: camp_end_date,
                    screen: 'ec61'
                };
            }else{
                data = {
                    comp_name: supplier_name,
                    comp_code: supplier_code,
                    is_hidden: public_statuses,
                    inputActive: inputActive,
                    camp_start_date: camp_start_date,
                    camp_end_date: camp_end_date,
                    screen: 'ec61'
                };
            }

            $.ajax({
                url: url,
                type: 'GET',
                timeout: 60000,
                data: {
                    campaign_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.campainProducts = data.campaign_info;
                        var totalPages = Math.ceil(data.total/LIMIT_ON_PAGE);
                        var visiblePages = 1;
                        if(totalPages != 0){
                            visiblePages =  5;
                        }
                        var $pagination = $('#pagination_campain_product');
                        $pagination.twbsPagination('destroy');
                        $pagination.twbsPagination({
                            totalPages: totalPages,
                            visiblePages: visiblePages,
                            startPage: thisTag.currentPage,
                            initiateStartPageClick: false,
                            onPageClick: function (event, page) {

                                searchCampainProduct(page);
                            }
                        });

                        thisTag.update();
                        $('.campaign-detail').each(function(index, value){
                            $(this).html($(this).text());
                        }) ;

                    }
                },
                error: function (xhr, stt, err) {
                    alert('error');
                }
            });


        }
    </script>
</campaign-data>

<search-po-punchout-iwai>
    <link rel="stylesheet" href="css/search-top.css">
    <link rel="stylesheet" href="css/animate.css">
    <style type="text/css">
        .x-multi_select-search {
            border: none;
            padding: 5px;
            margin-left: 10px;
            background: none;
            font-weight: bold;
            color: #0b3f72;
        }
        .x-multi_select-search:hover, .x-multi_select-search:focus {
            border: none;
            background: none;
        }
        sup {
            font-size: 70% !important;
        }
    </style>
    <div class="main">
      <div class="content">
        <notice-box></notice-box>
        <form onsubmit={ submit }>
            <div class="form-wrapper">
                <div class="page-title">
                    <h2>商品検索</h2>
                </div>
                <div class="form-item">
                    <table>
                        <tr>
                            <td class="mobile_ec10" style="width: 150px ">キーワード</td>
                            <td colspan="2">
                                <input type="text" name="keyword" id="keyword" placeholder="品番・品名・容量・CAS RN®">
                                <input type="hidden" name="cas_code" id="cas_code">
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td class="form-text">
                                ※複数の語を空白で区切ると絞込み検索(AND)ができます
                            </td> 
                        </tr>
                    </table>
                </div>
            </div>
            <div class="form-wrapper">
                <div class="page-title">
                    <h2>詳細検索</h2>
                </div>
                <div class="form-item">
                        <table>
                            <tr class="only_s004">
                                <td class="mobile_ec10" style="width: 150px">品番</td>
                                <td>
                                    <input type="text" name="supplier_code" id="supplier_code" placeholder="品番を入力"
                                        autocomplete="off">
                                </td>
                                <td>
                                    <select id="no_type">
                                        <option value="1">完全一致</option>
                                        <option value="2">から始まる</option>
                                        <option value="3">で終わる</option>
                                        <option value="4" selected>を含む</option>
                                    </select>
                                </td>
                            </tr>
                            <tr class="only_s004">
                                <td>品名</td>
                                <td>
                                    <input type="text" name="name" id="name" placeholder="品名を入力" autocomplete="off">
                                </td>
                                <td>
                                    <select id="name_type">
                                        <option value="1">完全一致</option>
                                        <option value="2">から始まる</option>
                                        <option value="3">で終わる</option>
                                        <option value="4" selected>を含む</option>
                                    </select>
                                </td>
                            </tr>
                            <tr class="only_s004">
                                <td>製造元/ブランド</td>
                                <td>
                                    <div class="div-wraper-autocompleter">
                                        <input type="text" name="maker_name" id="maker_name" placeholder="メーカー名を入力（サジェスト）">
                                    </div>
                                    <div class="multi_select select_maker"></div>
                                </td>
                                <td style="position: relative;">
                                    <button type="button" class="show_maker search-btn link_maker">掲載メーカー</button>
                                </td>
                            </tr>
                            <tr class="only_s004">
                                <td>CAS RN<sup>&reg;</sup></td>
                                <td>
                                    <input type="text" name="search_cas_code" id="search_cas_code" placeholder="CAS RN®を入力">
                                </td>
                                <td style="position: relative;">
                                    <a style="color: inherit;" target="_blank" href="https://www.iwai-chem.co.jp/dealer/">
                                        <button type="button" class="link_maker search-btn">取扱メーカー</button>
                                    </a>
                                </td>
                            </tr>
                            <tr id="search-campaign">
                                <td></td>
                                <td>
                                    <div>
                                        <label for="search_campaign" style="display: inline;">キャンペーン中の商品のみ検索</label>
                                        <input type="checkbox" name="search_campaign" id="search_campaign"
                                            style="display: inline; width: auto;">
                                    </div>
                                </td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>表示件数</td>
                                <td>
                                    <select id="limit" style="width:60px">
                                        <option selected="{limit_po_on_page == 20 ? 'selected':''}">20</option>
                                        <option selected="{limit_po_on_page == 50 ? 'selected':''}">50</option>
                                    </select>
                                    件
                                </td>
                            </tr>
                            <tr>
                                <td class="searchBtnTd">
                                    <button class="reset-btn" type="reset"><i class="fa fa-refresh"
                                            aria-hidden="true"></i>条件クリア</button>
                                </td>
                                <td align="right" colspan="2">
                                    <div style="display: flex; justify-content:space-between">
                                        <div>
                                            <button style="color: red; display: none" type="button" id="ec27-Open">カタログ外商品のお見積りはこちら</button>
                                        </div>
                                        <div style="text-align: right">
                                            <button class="search-btn" type="submit">検索</button>
                                            <button class="search-btn search-btn-all" type="button">画面クリア</button>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </table>
                </div>
            </div>
        </form>
        <div><span class="size_small" style="margin:0px 0px;font-size:14px;float: right;" if={max_date_updated}>在庫更新日 : {max_date_updated}</span></div>
        <search-result-punchout></search-result-punchout>
        <!-- <search-result if={WIDTH_DEVICE >= 768}></search-result> -->
        <!-- <search-result-mobile if={WIDTH_DEVICE < 768}></search-result-mobile> -->
        <maker-popup></maker-popup>
        <ec27></ec27>
        <div id="paging" class="text-center">
            <ul class="pagination" id="pagination"></ul>
        </div>
      </div>
    </div>
    <script>
        ec10_current_search = 'search-po';
        this.limit_on_page = ec10_limit_on_page;
        this.basic_is_active = opts.basic_is_active;
        this.suggest_list = opts.suggest_list;
        this.list_combine = opts.list_combine;
        this.max_date_updated = '';
        this.conditions = [
            {condition: '完全一致'},
            {condition: 'から始まる'},
            {condition: 'を含む'},
        ];
        var user_info = JSON.parse(localStorage.getItem('EcUserInfo'));
        this.total = 1;
        var thisTag = this;
        this.list_show = user_info.list_navigation.S;
        this.list_show_F = user_info.list_navigation.F;
        this.list_show_B = user_info.list_navigation.B;
        this.max_updated_souko = '';
        toggle(e) {
            this.basic_is_active = !this.basic_is_active;
            this.antibody_is_active = !this.antibody_is_active;
        }

        var accessTokenCognito = localStorage.getItem('accessTokenCognito');
        this.on('mount', function () {
            var suggest_list = JSON.parse(localStorage.getItem('suggest_list'));
            var check_detail = arColumn(this.list_show, 'navigation_id', 'S004');
            if (check_detail.length > 0) {
                if (check_detail[0].display_status == 'N') {
                    $(".only_s004").remove();
                    // $("#panel_2").remove();
                    // $("#more-option").remove();
                }
            } 
            var check_detail = arColumn(this.list_show_F, 'navigation_id', 'F013');
            if (check_detail.length > 0) {
                if (check_detail[0].display_status == 'N') {
                    $("#search-campaign").remove();
                }
            } else {
                $("#search-campaign").remove();
            }
            var check_detail = arColumn(this.list_show_B, 'navigation_id', 'B013');
            if (check_detail.length > 0) {
                $('#ec27-Open').text(arColumn(this.list_show_B, 'navigation_id', 'B013')[0]['display_contents']);
                if (check_detail[0].display_status == 'N') {
                    $("#ec27-Open").remove();
                }
                if(!check_detail[0].display_status){
                    $("#ec27-Open").remove();
                }
            } else {
                $("#ec27-Open").remove();
            }

            $(document).on('click', '.x-multi_select-search', function() {
                $(this).parent().remove();
            });
            ec10_keyword = '';
            $('#keyword').val(ec10_keyword);
        
            if (ec10_keyword != '') {
                if (ec10_cas_code) {
                    $('.content form')[0].reset();
                    submit(this);
                    ec10_cas_code = '';
                    return;
                }
                if(check_login){
                    submit();
                } else {
                    var result_search = JSON.parse(localStorage.getItem('result_search')) ? JSON.parse(localStorage.getItem('result_search')) : [];
                    if (result_search.length > 0) {
                        thisTag.searchBack();
                    }
                }
            } else if (ec10_cas_code) {
                    $('.content form')[0].reset();
                    $('#search_cas_code').val(ec10_cas_code);
                submit(this);
                ec10_cas_code = '';
            } else {
                if(ec12_back_po == 'search-po'){
                    var result_search = JSON.parse(localStorage.getItem('result_search')) ? JSON.parse(localStorage.getItem('result_search')) : [];
                    if (result_search.length > 0) {
                        thisTag.searchBack();
                    }
                }
            }
        })
        this.backToTop = function(){
            $('body,html').animate({
                scrollTop: 0
            }, 0);
        }
        this.buttonViewMore = function(e){
            $(".view-more-mobile").click(function(){
              var parent_item = $(this).parents('.items-label').parent('.items');
              var items = parent_item.children(".items-content");
              if(!items.hasClass("open-content")){
                $(this).text('縮小');
                items.addClass("open-content");
              } else {
                $(this).text('拡大');
                items.removeClass("open-content");
              }
            });
        }
        this.getMaxUpdatedSouko = function(){
            var accessTokenCognito = localStorage.getItem('accessTokenCognito');
            var status = 0;
            var url = URL_API + '/api/owl/get_souko_zaiko_su_max_updated?token=' + accessTokenCognito;
            $.ajax({
                url: url,
                type: 'GET',
                timeout: 60000,
                async:false,
                success: function (data) {
                    if(data.status == 100){
                        riot.mount('app','maintain',{ messege:data.messege });
                        return false;
                    }
                    if(data.status == 'not_authorize'){
                        var url = "#";
                        $(location).attr("href", url );
                        return false;
                    }

                    thisTag.max_date_updated = moment(data.max_updated).format('YYYY-MM-DD HH:MM') + ' 現在';
                    thisTag.update(thisTag.max_date_updated);
                },
                error: function (xhr, stt, err) {
                    alert('error');
                }
            });
        }
        this.searchBack = function(){
            $('#ec27-Open').show();
            var result_search = JSON.parse(localStorage.getItem('result_search'));
            var last_search = result_search[result_search.length-1];
            var panel = last_search.panel;
            var result_search_page = last_search.page;
            var back_keyword = last_search.keyword;
            var back_search_supplier_code = last_search.search_supplier_code;
            var back_search_name_jp = last_search.search_name_jp;
            var back_search_maker_name = last_search.search_maker_name;
            var back_search_cas_code = last_search.search_cas_code;
            var back_no_type = last_search.no_type;
            var back_name_type = last_search.name_type;
            var back_search_campaign = last_search.search_campaign;
            var suggest_list = last_search.suggest_list;
                $('#supplier_code').val(back_search_supplier_code);
                $('#name').val(back_search_name_jp);
                if (back_search_maker_name.length > 0) {
                    var html = '';
                    for (var i = 0; i < back_search_maker_name.length; i++) {
                        var item = back_search_maker_name[i];
                        html += '<p>'+item+'<button class="x-multi_select-search">取り消す</button></p>';
                    }
                    $('.multi_select').append(html);
                }
                $('#search_cas_code').val(back_search_cas_code);
                $('#no_type').val(back_no_type);
                $('#name_type').val(back_name_type);
                $('#keyword').val(back_keyword);
            $(document).on('click', '#maker_name', function(event) {
                $('#maker_name').autocomplete({
                    minLength: 0,
                    open: function( event, ui ) {
                        return event.target.value;
                    },
                    source: function( request, response  ) {
                      var convertMatcher3 = '';
                      if (request.term.length > 0) {
                        convertMatcher3 = new RegExp("^" + $.ui.autocomplete.escapeRegex( mb_convert_kana(request.term, 'RNSKHC')), 'i');
                      }
                      var convertMatcher = request.term.replace(/[\uff01-\uff5e]/g,function(ch) { return String.fromCharCode(ch.charCodeAt(0) - 0xfee0); });
                      convertMatcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( convertMatcher ), "i" );
                      var convertMatcher2 = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term.toFullWidth() ), "i" );
                      var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term ), "i" );
                      response( $.grep( JSON.parse(JSON.stringify(suggest_list)), function( item ){
                          return  convertMatcher2.test(item) || convertMatcher3.test(item) || convertMatcher.test(item) || matcher.test( item );
                      }) );
                    },
                    select: function( event, ui ) {
                        $('.multi_select').append('<p>'+ui.item.value+'<button class="x-multi_select-search">取り消す</button></p>');
                        $('#maker_name').val('');
                        return false;
                    },
                    response : function(event, ui) {
                        if (ui.content.length === 0) {
                            // $('#maker_name').val('');
                        }
                    }
                })
                .click(function() {
                    $(this).autocomplete('search', '')
                })
                .focus(function() {
                    $(this).autocomplete('search', '')
                });
            });
            var old_campaign = '';
            if (back_search_campaign) {
                $('#search_campaign').prop('checked', true);
                old_campaign = 1;
            }
            if(ec12_back_po == 'search-po' && login_back == true){
                result_search.pop();
            }
            localStorage.setItem('result_search', JSON.stringify(result_search));

            if(last_search.total){
                $(".notice-wrapper").hide();
            }
            
            // if(WIDTH_DEVICE < 768){
            //     riot.mount('search-result-mobile', {results: last_search.product_list,total:last_search.total,total_all:last_search.total_all, tag: 'search/simple-po'});
            // } else {
                riot.mount('search-result-punchout', {results: last_search.product_list,total:last_search.total,total_all:last_search.total_all, tag: 'search/simple-po'});
            // }
            thisTag.buttonViewMore();
            thisTag.getMaxUpdatedSouko();
            thisTag.backToTop();
            var $pagination = $('#pagination');
            var totalPages = Math.ceil(last_search.total/$('#limit').val());
            $pagination.twbsPagination('destroy');
            $pagination.twbsPagination({
                totalPages: totalPages,
                visiblePages: 5,
                startPage: result_search_page,
                initiateStartPageClick: false,
                onPageClick: function (event, page) {
                    var url = URL_API + '/v1/get_product_ec102';
                    var keyword = $('#keyword').val();
                    var search_supplier_code = $('#supplier_code').val();
                    var search_name_jp = $('#name').val();
                    var search_maker_name = $('#maker_name').val();
                    var search_cas_code = $('#search_cas_code').val();
                    var no_type = $('#no_type').val();
                    var name_type = $('#name_type').val();
                    var lstSuggest = new Array();
                    var checkKeyword = trimSpaces(keyword).split(/[ 　]/);
                    if (checkKeyword.length >= 6) {
                        alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                        return;
                    }
                    if (search_supplier_code != null) {
                        var checkKeyword = trimSpaces(search_supplier_code).split(/[ 　]/);
                        if (checkKeyword.length >= 6) {
                            alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                            return;
                        }
                    }
                    if (search_name_jp != null) {
                        var checkKeyword = trimSpaces(search_name_jp).split(/[ 　]/);
                        if (checkKeyword.length >= 6) {
                            alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                            return;
                        }
                    }
                    $('.multi_select').find('p').each(function(index, el) {
                        var lstText = $(this).text();
                        lstText = lstText.replace('取り消す','');
                        lstSuggest.push(lstText);
                    });
                    if (search_maker_name != null && search_maker_name != '') {
                        lstSuggest.push(search_maker_name);
                    }
                    var query = [];
                    query.push('token=' + accessTokenCognito);
                    query.push('page=' + page);
                    query.push('from=iwai');
                    query.push('limit=' + $('#limit').val());
                    if (keyword) {
                        if (back_keyword != keyword) {
                            keyword = back_keyword;
                            $('#keyword').val(keyword);
                        }
                        query.push('keywords=' + encodeURIComponent(keyword));
                    } else {
                        if (back_keyword) {
                            $('#keyword').val(back_keyword);
                            query.push('keywords=' + encodeURIComponent(back_keyword));
                        }
                    }
                    // if (panel == 'panel_2') {
                        if (search_supplier_code) {
                            if (back_search_supplier_code != search_supplier_code) {
                                search_supplier_code = back_search_supplier_code;
                                $('#supplier_code').val(search_supplier_code);
                            }
                            query.push('search_supplier_code=' + encodeURIComponent(search_supplier_code));
                        } else {
                            if (back_search_supplier_code) {
                                $('#supplier_code').val(back_search_supplier_code);
                                query.push('search_supplier_code=' + encodeURIComponent(back_search_supplier_code));
                            }
                        }
                        if (search_name_jp) {
                            if (back_search_name_jp != search_name_jp) {
                                search_name_jp = back_search_name_jp;
                                $('#name').val(search_name_jp);
                            }
                            query.push('search_name_jp=' + encodeURIComponent(search_name_jp));
                        } else {
                            if (back_search_name_jp) {
                                $('#name').val(back_search_name_jp);
                                query.push('search_name_jp=' + encodeURIComponent(back_search_name_jp));
                            }
                        }
                        if (lstSuggest.length > 0) {
                            if (JSON.stringify(back_search_maker_name) != JSON.stringify(lstSuggest)) {
                                lstSuggest = back_search_maker_name;
                                var html = '';
                                for (var i = 0; i < lstSuggest.length; i++) {
                                    var item = lstSuggest[i];
                                    html += '<p>'+item+'<button class="x-multi_select-search">取り消す</button></p>';
                                }
                                $('.multi_select').append(html);
                            }
                            query.push('search_maker_name=' + encodeURIComponent(JSON.stringify((lstSuggest))));
                        } else {
                            if (back_search_maker_name.length > 0) {
                                var html = '';
                                for (var i = 0; i < back_search_maker_name.length; i++) {
                                    var item = back_search_maker_name[i];
                                    html += '<p>'+item+'<button class="x-multi_select-search">取り消す</button></p>';
                                }
                                $('.multi_select').append(html);
                                query.push('search_maker_name=' + encodeURIComponent(JSON.stringify((back_search_maker_name))));
                            }
                        }
                        if (search_cas_code) {
                            if (back_search_cas_code != search_cas_code) {
                                search_cas_code = back_search_cas_code;
                                $('#search_cas_code').val(search_cas_code);
                            }
                            query.push('search_cas_code=' + encodeURIComponent(search_cas_code));
                        } else {
                            if (back_search_cas_code) {
                                $('#search_cas_code').val(back_search_cas_code);
                                query.push('search_cas_code=' + encodeURIComponent(back_search_cas_code));
                            }
                        }
                        if (search_supplier_code && no_type) {
                            if (back_no_type != no_type) {
                                no_type = back_no_type;
                                $('#no_type').val(no_type);
                            }
                            query.push('no_type=' + encodeURIComponent(no_type));
                        }
                        if (search_name_jp && name_type) {
                            if (back_name_type != name_type) {
                                name_type = back_name_type;
                                $('#name_type').val(name_type);
                            }
                            query.push('name_type=' + encodeURIComponent(name_type));
                        }
                    // }
                    if (old_campaign == 1) {
                        $('#search_campaign').prop('checked', true);
                    }
                    if ($('#search_campaign').is(':checked')) {
                        query.push('search_campaign=true');
                    }
                    if (ec10_cas_code) {
                        query.push('cas_value=' + ec10_cas_code);
                    }
                    url += '?' + query.join('&');
                    $.ajax({
                        url: url,
                        type: 'GET',
                        success: function (data) {
                            if(data.status == 100){
                                riot.mount('app','maintain',{ messege:data.messege });
                                return false;
                            }
                            if(data.http == 400){
                                alert(data.message);
                                return false;
                            }
                            thisTag.total = data.total;
                            if(thisTag.total){
                                $(".notice-wrapper").hide();
                            }
                            ec10_total_page_po = data.total;
                            var total = data.total;
                            var total_all = data.total_all;
                            var results = data.product_list;
                            var suggest_list = data.suggest_list;
                            var newArray = [];
                            data.page = page;
                            data.keyword = keyword;
                            data.search_supplier_code = search_supplier_code;
                            data.search_name_jp = search_name_jp;
                            data.search_maker_name = lstSuggest;
                            data.search_cas_code = search_cas_code;
                            data.no_type = no_type;
                            data.name_type = name_type;
                            data.search_campaign = false;
                            if ($('#search_campaign').is(':checked')) {
                                data.search_campaign = true;
                            }
                            newArray = JSON.parse(localStorage.getItem('result_search')) ? JSON.parse(localStorage.getItem('result_search')) : [];
                            if (Array.isArray(newArray)) {
                                newArray.push(data);
                            } else {
                                newArray = [];
                            }
                            // newArray.push(data);
                            localStorage.setItem('result_search', JSON.stringify(newArray));
                            $('#maker_name').autocomplete({
                                minLength: 0,
                                open: function( event, ui ) {
                                    return event.target.value;
                                },
                                source: function( request, response  ) {
                                  var convertMatcher3 = '';
                                  if (request.term.length > 0) {
                                    convertMatcher3 = new RegExp("^" + $.ui.autocomplete.escapeRegex( mb_convert_kana(request.term, 'RNSKHC')), 'i');
                                  }
                                  var convertMatcher = request.term.replace(/[\uff01-\uff5e]/g,function(ch) { return String.fromCharCode(ch.charCodeAt(0) - 0xfee0); });
                                  convertMatcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( convertMatcher ), "i" );
                                  var convertMatcher2 = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term.toFullWidth() ), "i" );
                                  var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term ), "i" );
                                  response( $.grep( JSON.parse(JSON.stringify(suggest_list)), function( item ){
                                      return  convertMatcher2.test(item) || convertMatcher3.test(item) || convertMatcher.test(item) || matcher.test( item );
                                  }) );
                                },
                                select: function( event, ui ) {
                                    $('.multi_select').append('<p>'+ui.item.value+'<button class="x-multi_select-search">取り消す</button></p>');
                                    $('#maker_name').val('');
                                    return false;
                                },
                                response : function(event, ui) {
                                    if (ui.content.length === 0) {
                                        // $('#maker_name').val('');
                                    }
                                }
                            })
                            .click(function() {
                                $(this).autocomplete('search', '')
                            })
                            .focus(function() {
                                $(this).autocomplete('search', '')
                            });
                            localStorage.removeItem('suggest_list');
                            // localStorage.setItem('result_search', JSON.stringify(data));
                            // localStorage.setItem('result_search_page', page);
                            // if(WIDTH_DEVICE < 768){
                            //     riot.mount('search-result-mobile', {results: results, total: total, total_all: total_all, tag: 'search/simple-po'});
                            // } else {
                                riot.mount('search-result-punchout', {results: results, total: total, total_all: total_all, tag: 'search/simple-po'});
                            // }
                            thisTag.buttonViewMore();
                            thisTag.backToTop();
                        },
                        error: function (xhr, stt, error) {
                            alert('error');
                        }
                    });
                }
            });
        }
        submit = function (e) {
            // alert(); return;
            $('#ec27-Open').show();
            if(ec10_current_search == 'search-po'){
                ec12_back_po = 'search-po';
            }
            var checkKeyword = '';
            var checkSupplierCode = '';
            var checkNameJp = '';
            var checkCasNo = '';
            // var dis_keyword = false;
            // dis_keyword = $('#keyword').prop('disabled');
            var keyword = $('#keyword').val();
            var search_supplier_code = $('#supplier_code').val();
            var search_name_jp = $('#name').val();
            var search_maker_name = $('#maker_name').val();
            var search_cas_code = $('#search_cas_code').val();
            var no_type = $('#no_type').val();
            var name_type = $('#name_type').val();
            var checkKeyword = trimSpaces(keyword).split(/[ 　]/);
            if (checkKeyword.length >= 6) {
                alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                return;
            }
            if (search_supplier_code != null) {
                var checkSupplierCode = trimSpaces(search_supplier_code).split(/[ 　]/);
                if (checkSupplierCode.length >= 6) {
                    alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                    return;
                }
            }
            if (search_name_jp != null) {
                var checkNameJp = trimSpaces(search_name_jp).split(/[ 　]/);
                if (checkNameJp.length >= 6) {
                    alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                    return;
                }
            }
            if (search_cas_code != null) {
                var checkCasNo = trimSpaces(search_cas_code).split(/[ 　]/);
            }
            if (keyword != null && keyword != '') {
                var test = keyword.replace(/[\！\＂\＃\＄\％\＆\＇\（\）\＊\＋\，\－\．\／\：\；\＜\＝\＞\？\＠\［\＼\］\＾\＿\｀\｛\｜\｝\～\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@\[\]\^\_\`\{\|\}\~\-\(\)\/\&\=\[\]\\\>\<\{\}\、\。\，\・\：\；\／\＼\‘\’\“\”\（\）\〔\〕\［\］\｛\｝\〈\〉\《\》\「\」\『\』\【\】\＞\＜\!\！\－\＆\＝\@\#\＠\＃\?\？\_\|\~\～\"\'\,]/g, '');
                if(test == '') {
                    alert('記号のみでの検索はできません。');
                    return;
                }
            }
            if (search_supplier_code != null && search_supplier_code != '') {
                var test = search_supplier_code.replace(/[\！\＂\＃\＄\％\＆\＇\（\）\＊\＋\，\－\．\／\：\；\＜\＝\＞\？\＠\［\＼\］\＾\＿\｀\｛\｜\｝\～\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@\[\]\^\_\`\{\|\}\~\-\(\)\/\&\=\[\]\\\>\<\{\}\、\。\，\・\：\；\／\＼\‘\’\“\”\（\）\〔\〕\［\］\｛\｝\〈\〉\《\》\「\」\『\』\【\】\＞\＜\!\！\－\＆\＝\@\#\＠\＃\?\？\_\|\~\～\"\'\,]/g, '');
                if(test == '') {
                    alert('記号のみでの検索はできません。');
                    return;
                }
            }
            if (search_name_jp != null && search_name_jp != '') {
                var test = search_name_jp.replace(/[\！\＂\＃\＄\％\＆\＇\（\）\＊\＋\，\－\．\／\：\；\＜\＝\＞\？\＠\［\＼\］\＾\＿\｀\｛\｜\｝\～\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@\[\]\^\_\`\{\|\}\~\-\(\)\/\&\=\[\]\\\>\<\{\}\、\。\，\・\：\；\／\＼\‘\’\“\”\（\）\〔\〕\［\］\｛\｝\〈\〉\《\》\「\」\『\』\【\】\＞\＜\!\！\－\＆\＝\@\#\＠\＃\?\？\_\|\~\～\"\'\,]/g, '');
                if(test == '') {
                    alert('記号のみでの検索はできません。');
                    return;
                }
            }
            if (search_maker_name != null && search_maker_name != '') {
                var test = search_maker_name.replace(/[\！\＂\＃\＄\％\＆\＇\（\）\＊\＋\，\－\．\／\：\；\＜\＝\＞\？\＠\［\＼\］\＾\＿\｀\｛\｜\｝\～\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@\[\]\^\_\`\{\|\}\~\-\(\)\/\&\=\[\]\\\>\<\{\}\、\。\，\・\：\；\／\＼\‘\’\“\”\（\）\〔\〕\［\］\｛\｝\〈\〉\《\》\「\」\『\』\【\】\＞\＜\!\！\－\＆\＝\@\#\＠\＃\?\？\_\|\~\～\"\'\,]/g, '');
                if(test == '') {
                    alert('記号のみでの検索はできません。');
                    return;
                }
            }
            if (search_cas_code != null && search_cas_code != '') {
                var test = search_cas_code.replace(/[\！\＂\＃\＄\％\＆\＇\（\）\＊\＋\，\－\．\／\：\；\＜\＝\＞\？\＠\［\＼\］\＾\＿\｀\｛\｜\｝\～\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@\[\]\^\_\`\{\|\}\~\-\(\)\/\&\=\[\]\\\>\<\{\}\、\。\，\・\：\；\／\＼\‘\’\“\”\（\）\〔\〕\［\］\｛\｝\〈\〉\《\》\「\」\『\』\【\】\＞\＜\!\！\－\＆\＝\@\#\＠\＃\?\？\_\|\~\～\"\'\,]/g, '');
                if(test == '') {
                    alert('記号のみでの検索はできません。');
                    return;
                }
            }
            var lstSuggest = new Array();
            $('.multi_select').find('p').each(function(index, el) {
                var lstText = $(this).text();
                lstText = lstText.replace('取り消す','');
                lstSuggest.push(lstText);
            });
            if (search_maker_name != null && search_maker_name != '') {
                lstSuggest.push(search_maker_name);
            }
            var old_keyword = '';
            var old_supplier = '';
            var old_no_type = '';
            var old_name = '';
            var old_name_type = '';
            var old_maker = new Array();
            var old_cas = '';
            var old_campaign = '';
            if (e) {
                old_keyword = $('#keyword').val();
                old_supplier = $('#supplier_code').val();
                old_no_type = $('#no_type').val();
                old_name = $('#name').val();
                old_name_type = $('#name_type').val();
                old_cas = $('#search_cas_code').val();
                if ($('#search_campaign').is(':checked')) {
                    old_campaign = 1;
                }
                $('.multi_select').find('p').each(function(index, el) {
                    var lstText = $(this).text();
                    lstText = lstText.replace('取り消す','');
                    old_maker.push(lstText);
                });
                ec10_cas_code = '';
                thisTag.total = 1;
                ec10_po_current_page = 1;
                ec10_total_page_po = 1;
            }
            if (checkKeyword == '' && checkSupplierCode == '' && checkNameJp == '' && checkCasNo == '' && lstSuggest.length == 0 && !$('#search_campaign').is(':checked')) {
                if (search_maker_name != null ) {
                    $('#maker_name').val('');
                }
                alert('検索条件を一つ以上指定してください。\n（※製造元/ブランドのみでの検索はできません）');
                return;
            }
            if (checkKeyword == '' && checkSupplierCode == '' && checkNameJp == '' && checkCasNo == '' && lstSuggest.length > 0 && !$('#search_campaign').is(':checked')) {
                alert('製造元/ブランドのみでの検索はできません。');
                return;
            }
            // var panel = JSON.parse(localStorage.getItem('data-panel')) ? JSON.parse(localStorage.getItem('data-panel')) : '';
            var $pagination = $('#pagination');
            var totalPages = Math.ceil(ec10_total_page_po/$('#limit').val());
            $pagination.twbsPagination('destroy');
            $pagination.twbsPagination({
                totalPages: totalPages,
                visiblePages: 5,
                startPage: ec10_po_current_page,
                onPageClick: function (event, page) {
                    ec10_limit_on_page = $('#limit').val();
                    ec10_po_current_page = page;
                    var url = URL_API + '/v1/get_product_ec102';
                    var query = [];
                    query.push('token=' + accessTokenCognito);
                    query.push('page=' + page);
                    query.push('from=iwai');
                    query.push('limit=' + $('#limit').val());
                    if (keyword) {
                        if (old_keyword != keyword) {
                            keyword = old_keyword;
                            $('#keyword').val(keyword);
                        }
                    // if (keyword && !dis_keyword) {
                        query.push('keywords=' + encodeURIComponent(keyword));
                    } else {
                        if (old_keyword) {
                            $('#keyword').val(old_keyword);
                            query.push('keywords=' + encodeURIComponent(old_keyword));
                        }
                    }
                    // if (panel == 'panel_2') {
                        if (search_supplier_code) {
                            if (old_supplier != search_supplier_code) {
                                search_supplier_code = old_supplier;
                                $('#supplier_code').val(search_supplier_code);
                            }
                            query.push('search_supplier_code=' + encodeURIComponent(search_supplier_code));
                        } else {
                            if (old_supplier) {
                                $('#supplier_code').val(old_supplier);
                                query.push('search_supplier_code=' + encodeURIComponent(old_supplier));
                            }
                        }
                        if (search_name_jp) {
                            if (old_name != search_name_jp) {
                                search_name_jp = old_name;
                                $('#name').val(search_name_jp);
                            }
                            query.push('search_name_jp=' + encodeURIComponent(search_name_jp));
                        } else {
                            if (old_name) {
                                $('#name').val(old_name);
                                query.push('search_name_jp=' + encodeURIComponent(old_name));
                            }
                        }
                        if (lstSuggest.length > 0) {
                            if (JSON.stringify(old_maker) != JSON.stringify(lstSuggest)) {
                                lstSuggest = old_maker;
                                var html = '';
                                for (var i = 0; i < lstSuggest.length; i++) {
                                    var item = lstSuggest[i];
                                    html += '<p>'+item+'<button class="x-multi_select-search">取り消す</button></p>';
                                }
                                $('.multi_select').append(html);
                            }
                            query.push('search_maker_name=' + encodeURIComponent(JSON.stringify((lstSuggest))));
                        } else {
                            if (old_maker.length > 0) {
                                var html = '';
                                for (var i = 0; i < old_maker.length; i++) {
                                    var item = old_maker[i];
                                    html += '<p>'+item+'<button class="x-multi_select-search">取り消す</button></p>';
                                }
                                $('.multi_select').append(html);
                                query.push('search_maker_name=' + encodeURIComponent(JSON.stringify((old_maker))));
                            }
                        }
                        if (search_cas_code) {
                            if (old_cas != search_cas_code) {
                                search_cas_code = old_cas;
                                $('#search_cas_code').val(search_cas_code);
                            }
                            query.push('search_cas_code=' + encodeURIComponent(search_cas_code));
                        } else {
                            if (old_cas) {
                                $('#search_cas_code').val(old_cas);
                                query.push('search_cas_code=' + encodeURIComponent(old_cas));
                            }
                        }
                        if (search_supplier_code && no_type) {
                            if (old_no_type != no_type) {
                                no_type = old_no_type;
                                $('#no_type').val(no_type);
                            }
                            query.push('no_type=' + encodeURIComponent(no_type));
                        }
                        if (search_name_jp && name_type) {
                            if (old_name_type != name_type) {
                                name_type = old_name_type;
                                $('#name_type').val(name_type);
                            }
                            query.push('name_type=' + encodeURIComponent(name_type));
                        }
                    // }
                    if (ec10_cas_code) {
                        query.push('cas_value=' + ec10_cas_code);
                    }
                    if (old_campaign == 1) {
                        $('#search_campaign').prop('checked', true);
                    }
                    if ($('#search_campaign').is(':checked')) {
                        query.push('search_campaign=true');
                    }
                    console.log(query)
                    // write in storage
                    ec10_keyword = keyword;
                    // end write
                    url += '?' + query.join('&');
                    $.ajax({
                        type: 'GET',
                        url: url,
                        timeout: 60000,
                        success: function (data, text) {
                            if(data.status == 100){
                                riot.mount('app','maintain',{ messege:data.messege });
                                return false;
                            }
                            if(data.http == 400){
                                alert(data.message);
                                return false;
                            }
                            if(thisTag.total){
                                $(".notice-wrapper").hide();
                            }
                            thisTag.total = data.total;
                            if(thisTag.total){
                                $(".notice-wrapper").hide();
                                thisTag.getMaxUpdatedSouko();
                            }
                            var total = data.total;
                            var total_all = data.total_all;
                            var panel = JSON.parse(localStorage.getItem('data-panel')) ? JSON.parse(localStorage.getItem('data-panel')) : '';
                            ec10_total_page_po = total;
                            var results = data.product_list;
                            var suggest_list = data.suggest_list;
                            var newArray = [];
                            data.page = page;
                            data.panel = panel;
                            data.keyword = keyword;
                            data.search_supplier_code = search_supplier_code;
                            data.search_name_jp = search_name_jp;
                            data.search_maker_name = lstSuggest;
                            data.search_cas_code = search_cas_code;
                            data.no_type = no_type;
                            data.name_type = name_type;
                            data.search_campaign = false;
                            if ($('#search_campaign').is(':checked')) {
                                data.search_campaign = true;
                            }
                            newArray = JSON.parse(localStorage.getItem('result_search')) ? JSON.parse(localStorage.getItem('result_search')) : [];
                            if (Array.isArray(newArray)) {
                                newArray.push(data);
                            } else {
                                newArray = [];
                            }
                            // newArray.push(data);
                            localStorage.setItem('result_search', JSON.stringify(newArray));
                            $('#maker_name').autocomplete({
                                minLength: 0,
                                open: function( event, ui ) {
                                    return event.target.value;
                                },
                                source: function( request, response  ) {
                                  var convertMatcher3 = '';
                                  if (request.term.length > 0) {
                                    convertMatcher3 = new RegExp("^" + $.ui.autocomplete.escapeRegex( mb_convert_kana(request.term, 'RNSKHC')), 'i');
                                  }
                                  var convertMatcher = request.term.replace(/[\uff01-\uff5e]/g,function(ch) { return String.fromCharCode(ch.charCodeAt(0) - 0xfee0); });
                                  convertMatcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( convertMatcher ), "i" );
                                  var convertMatcher2 = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term.toFullWidth() ), "i" );
                                  var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term ), "i" );
                                  response( $.grep( JSON.parse(JSON.stringify(suggest_list)), function( item ){
                                      return  convertMatcher2.test(item) || convertMatcher3.test(item) || convertMatcher.test(item) || matcher.test( item );
                                  }) );
                                },
                                select: function( event, ui ) {
                                    $('.multi_select').append('<p>'+ui.item.value+'<button class="x-multi_select-search">取り消す</button></p>');
                                    $('#maker_name').val('');
                                    return false;
                                },
                                response : function(event, ui) {
                                    if (ui.content.length === 0) {
                                        // $('#maker_name').val('');
                                    }
                                }
                            })
                            .click(function() {
                                $(this).autocomplete('search', '')
                            })
                            .focus(function() {
                                $(this).autocomplete('search', '')
                            });
                            localStorage.removeItem('suggest_list');
                            // localStorage.setItem('result_search_page', page);
                            // if(WIDTH_DEVICE < 768){
                            //     riot.mount('search-result-mobile', {results: results, total: total, total_all: total_all, tag: 'search/simple-po'});
                            // } else {
                                riot.mount('search-result-punchout', {results: results, total: total, total_all: total_all, tag: 'search/simple-po'});
                            // }
                            thisTag.buttonViewMore();
                            thisTag.backToTop();
                            var totalPages = Math.ceil(data.total/$('#limit').val());
                            var $pagination = $('#pagination');
                            $pagination.twbsPagination('destroy');
                            $pagination.twbsPagination({
                                totalPages: totalPages,
                                visiblePages: 5,
                                initiateStartPageClick: false,
                                startPage: ec10_po_current_page,
                                onPageClick: function (event, page) {
                                    ec10_po_current_page = page;
                                    // console.log(ec10_po_current_page);
                                    var url = URL_API + '/v1/get_product_ec102';
                                    // var dis_keyword = false;
                                    // dis_keyword = $('#keyword').prop('disabled');
                                    var keyword = $('#keyword').val();
                                    var search_supplier_code = $('#supplier_code').val();
                                    var search_name_jp = $('#name').val();
                                    var search_maker_name = $('#maker_name').val();
                                    var search_cas_code = $('#search_cas_code').val();
                                    var no_type = $('#no_type').val();
                                    var name_type = $('#name_type').val();
                                    var checkKeyword = trimSpaces(keyword).split(/[ 　]/);
                                    if (checkKeyword.length >= 6) {
                                        alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                                        return;
                                    }
                                    if (search_supplier_code != null) {
                                        var checkKeyword = trimSpaces(search_supplier_code).split(/[ 　]/);
                                        if (checkKeyword.length >= 6) {
                                            alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                                            return;
                                        }
                                    }
                                    if (search_name_jp != null) {
                                        var checkKeyword = trimSpaces(search_name_jp).split(/[ 　]/);
                                        if (checkKeyword.length >= 6) {
                                            alert('検索パフォーマンスを維持するため候補値を5つ以下にして検索をお願いします');
                                            return;
                                        }
                                    }
                                    var lstSuggest = new Array();
                                    $('.multi_select').find('p').each(function(index, el) {
                                        var lstText = $(this).text();
                                        lstText = lstText.replace('取り消す','');
                                        lstSuggest.push(lstText);
                                    });
                                    if (search_maker_name != null && search_maker_name != '') {
                                        lstSuggest.push(search_maker_name);
                                    }
                                    var query = [];
                                    query.push('token=' + accessTokenCognito);
                                    query.push('page=' + ec10_po_current_page);
                                    query.push('from=iwai');
                                    query.push('limit=' + $('#limit').val());
                                    if (keyword) {
                                        if (old_keyword != keyword) {
                                            keyword = old_keyword;
                                            $('#keyword').val(keyword);
                                        }
                                    // if (keyword && !dis_keyword) {
                                        query.push('keywords=' + encodeURIComponent(keyword));
                                    } else {
                                        if (old_keyword) {
                                            $('#keyword').val(old_keyword);
                                            query.push('keywords=' + encodeURIComponent(old_keyword));
                                        }
                                    }
                                    // if (panel == 'panel_2') {
                                        if (search_supplier_code) {
                                            if (old_supplier != search_supplier_code) {
                                                search_supplier_code = old_supplier;
                                                $('#supplier_code').val(search_supplier_code);
                                            }
                                            query.push('search_supplier_code=' + encodeURIComponent(search_supplier_code));
                                        } else {
                                            if (old_supplier) {
                                                $('#supplier_code').val(old_supplier);
                                                query.push('search_supplier_code=' + encodeURIComponent(old_supplier));
                                            }
                                        }
                                        if (search_name_jp) {
                                            if (old_name != search_name_jp) {
                                                search_name_jp = old_name;
                                                $('#name').val(search_name_jp);
                                            }
                                            query.push('search_name_jp=' + encodeURIComponent(search_name_jp));
                                        } else {
                                            if (old_name) {
                                                $('#name').val(old_name);
                                                query.push('search_name_jp=' + encodeURIComponent(old_name));
                                            }
                                        }
                                        if (lstSuggest.length > 0) {
                                            if (JSON.stringify(old_maker) != JSON.stringify(lstSuggest)) {
                                                lstSuggest = old_maker;
                                                var html = '';
                                                for (var i = 0; i < lstSuggest.length; i++) {
                                                    var item = lstSuggest[i];
                                                    html += '<p>'+item+'<button class="x-multi_select-search">取り消す</button></p>';
                                                }
                                                $('.multi_select').append(html);
                                            }
                                            query.push('search_maker_name=' + encodeURIComponent(JSON.stringify((lstSuggest))));
                                        } else {
                                            if (old_maker.length > 0) {
                                                var html = '';
                                                for (var i = 0; i < old_maker.length; i++) {
                                                    var item = old_maker[i];
                                                    html += '<p>'+item+'<button class="x-multi_select-search">取り消す</button></p>';
                                                }
                                                $('.multi_select').append(html);
                                                query.push('search_maker_name=' + encodeURIComponent(JSON.stringify((old_maker))));
                                            }
                                        }
                                        if (search_cas_code) {
                                            if (old_cas != search_cas_code) {
                                                search_cas_code = old_cas;
                                                $('#search_cas_code').val(search_cas_code);
                                            }
                                            query.push('search_cas_code=' + encodeURIComponent(search_cas_code));
                                        } else {
                                            if (old_cas) {
                                                $('#search_cas_code').val(old_cas);
                                                query.push('search_cas_code=' + encodeURIComponent(old_cas));
                                            }
                                        }
                                        if (search_supplier_code && no_type) {
                                            if (old_no_type != no_type) {
                                                no_type = old_no_type;
                                                $('#no_type').val(no_type);
                                            }
                                            query.push('no_type=' + encodeURIComponent(no_type));
                                        }
                                        if (search_name_jp && name_type) {
                                            if (old_name_type != name_type) {
                                                name_type = old_name_type;
                                                $('#name_type').val(name_type);
                                            }
                                            query.push('name_type=' + encodeURIComponent(name_type));
                                        }
                                    // }
                                    if (ec10_cas_code) {
                                        query.push('cas_value=' + ec10_cas_code);
                                    }
                                    if (old_campaign == 1) {
                                        $('#search_campaign').prop('checked', true);
                                    }
                                    if ($('#search_campaign').is(':checked')) {
                                        query.push('search_campaign=true');
                                    }

                                    url += '?' + query.join('&');
                                    $.ajax({
                                        url: url,
                                        type: 'GET',
                                        success: function (data) {
                                            if(data.status == 100){
                                                riot.mount('app','maintain',{ messege:data.messege });
                                                return false;
                                            }
                                            if(data.http == 400){
                                                alert(data.message);
                                                return false;
                                            }
                                            thisTag.total = data.total;
                                            ec10_total_page_po = data.total;
                                            var total = data.total;
                                            var total_all = data.total_all;
                                            var panel = JSON.parse(localStorage.getItem('data-panel')) ? JSON.parse(localStorage.getItem('data-panel')) : '';
                                            var results = data.product_list;
                                            var suggest_list = data.suggest_list;
                                            var newArray = [];
                                            data.page = page;
                                            data.panel = panel;
                                            data.keyword = keyword;
                                            data.search_supplier_code = search_supplier_code;
                                            data.search_name_jp = search_name_jp;
                                            data.search_maker_name = lstSuggest ;
                                            data.search_cas_code = search_cas_code;
                                            data.no_type = no_type;
                                            data.name_type = name_type;
                                            data.search_campaign = false;
                                            if ($('#search_campaign').is(':checked')) {
                                                data.search_campaign = true;
                                            }
                                            newArray = JSON.parse(localStorage.getItem('result_search')) ? JSON.parse(localStorage.getItem('result_search')) : [];
                                            if (Array.isArray(newArray)) {
                                                newArray.push(data);
                                            } else {
                                                newArray = [];
                                            }
                                            // newArray.push(data);
                                            localStorage.setItem('result_search', JSON.stringify(newArray));
                                            $('#maker_name').autocomplete({
                                                minLength: 0,
                                                open: function( event, ui ) {
                                                    return event.target.value;
                                                },
                                                source: function( request, response  ) {
                                                  var convertMatcher3 = '';
                                                  if (request.term.length > 0) {
                                                    convertMatcher3 = new RegExp("^" + $.ui.autocomplete.escapeRegex( mb_convert_kana(request.term, 'RNSKHC')), 'i');
                                                  }
                                                  var convertMatcher = request.term.replace(/[\uff01-\uff5e]/g,function(ch) { return String.fromCharCode(ch.charCodeAt(0) - 0xfee0); });
                                                  convertMatcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( convertMatcher ), "i" );
                                                  var convertMatcher2 = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term.toFullWidth() ), "i" );
                                                  var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex ( request.term ), "i" );
                                                  response( $.grep( JSON.parse(JSON.stringify(suggest_list)), function( item ){
                                                      return  convertMatcher2.test(item) || convertMatcher3.test(item) || convertMatcher.test(item) || matcher.test( item );
                                                  }) );
                                                },
                                                select: function( event, ui ) {
                                                    $('.multi_select').append('<p>'+ui.item.value+'<button class="x-multi_select-search">取り消す</button></p>');
                                                    $('#maker_name').val('');
                                                    return false;
                                                },
                                                response : function(event, ui) {
                                                    if (ui.content.length === 0) {
                                                        // $('#maker_name').val('');
                                                    }
                                                }
                                            })
                                            .click(function() {
                                                $(this).autocomplete('search', '')
                                            })
                                            .focus(function() {
                                                $(this).autocomplete('search', '')
                                            });
                                            localStorage.removeItem('suggest_list');
                                            // localStorage.setItem('result_search', JSON.stringify(data));
                                            // localStorage.setItem('result_search_page', page);
                                            // if(WIDTH_DEVICE < 768){
                                            //     riot.mount('search-result-mobile', {results: results, total: total, total_all: total_all, tag: 'search/simple-po'});
                                            // } else {
                                                riot.mount('search-result-punchout', {results: results, total: total, total_all: total_all, tag: 'search/simple-po'});
                                            // }
                                            thisTag.buttonViewMore();
                                            thisTag.backToTop();
                                        },
                                        error: function (xhr, stt, error) {
                                            alert('error');
                                        }
                                    });
                                }
                            });
                        },
                        error: function (xhr, stt, error) {
                            alert('error');
                        }
                    });
                }
            });
        }
        $(function() {
            $('.show_maker').on('click',function(){
                riot.mount('maker-popup',{list_combine : thisTag.list_combine, default_char : ''});
                $('#maker_show').fadeIn();
            });
            $('#ec27-Open').on('click',function(){
                $('#img-loader').hide();
                var accessTokenCognito = localStorage.getItem('accessTokenCognito');
                var dealer = [];
                var url_dealer = URL_API + '/api/get_dealer_customers_ec27?token=' + accessTokenCognito

                $.ajax({
                    url: url_dealer,
                    type: 'GET',
                    timeout: 60000,
                    async:false,
                    success: function (data) {
                        if(data.status == 100){
                            riot.mount('app','maintain',{ messege:data.messege });
                            return false;
                        }
                        if(data.status == 'not_authorize'){
                            var url = "#";
                            $(location).attr("href", url );
                            return false;
                        }
                        // console.log(data);
                        dealer = data.dealer;
                        // console.log(cusUseCode1);
                        // console.log(cusUseCode2);
                    },
                    error: function (xhr, stt, err) {
                        alert('error');
                    }
                });
                riot.mount('ec27',{ dealer: dealer });
                $('#ec27-form').fadeIn();
            });
            $(document).on('click', '.x-multi_select-search', function() {
                $(this).parent().remove();
            });
            $('.reset-btn').on('click', function() {
                $('.multi_select').find('p').remove();
            })
            $('.search-btn-all').on('click', function(event) {
                $('.content form')[0].reset();
                $('.multi_select').find('p').remove();
                $('.result-wrapper').remove();
                $('.notice-wrapper').show();
                $('.notice-box').show();
                $('#maker_name').autocomplete({
                    minLength: 0,
                    source: function( request, response  ) {
                        return '';
                    }
                });
                thisTag.max_date_updated = '';
                thisTag.update(thisTag.max_date_updated);
                var $pagination = $('#pagination');
                $pagination.twbsPagination('destroy');
            });
            var panel = JSON.parse(localStorage.getItem('data-panel')) ? JSON.parse(localStorage.getItem('data-panel')) : 'panel_1';
            localStorage.setItem('data-panel', JSON.stringify(panel));
        });
        String.prototype.toHalfWidth = function() {
            return this.replace(/[Ａ-Ｚａ-ｚ０-９ァ-ン]/g, function(s) {return String.fromCharCode(s.charCodeAt(0) - 0xFEE0)});
        };

        String.prototype.toFullWidth = function() {
            return this.replace(/[A-Za-z0-9\uFF65-\uFF9F]/g, function(s) { return String.fromCharCode(s.charCodeAt(0) + 0xFEE0)});
        };
    </script>
</search-po-punchout-iwai>