$(function() { //日付カレンダー $(".datepicker").datepicker({dateFormat: 'yy/mm/dd'}); $(".datetimepicker").datetimepicker(); $(".chosen-select").chosen({ search_contains:true, no_results_text:"一致する内容がありません", allow_single_deselect:true, width:"99.5%" }); //画像削除準備 $(document).on("click", ".img_del", function (){ if($(this).parents("li").length){ $(this).parents("li").remove(); var target = $(this).prevAll("img").attr("src"); var item_image_id; } else { $(this).parents("tr").remove(); var target = $(this).parents("tr").find("img").attr("src"); var item_image_id = $(this).parents("tr").find(".item_image_id").val(); } $("").attr({ type: "hidden", name: "del_img[]", value: target }).appendTo("#form"); if(item_image_id){ $("").attr({ type: "hidden", name: "del_item_image_id[]", value: item_image_id }).appendTo("#form"); } }); //検索条件クリア $(document).on("click", "#clear_search", function (){ var screen_code = $("body").attr("id"); $.ajax({ url: "https://fcc.tokyo/inc/do/clear_search.php", type: "POST", cache: false, data: { screen_code:screen_code }, success: function(data){ location.reload(); return false; }, error: function(xhr, ts, err){ } }); }); //データ削除 $(document).on("click", ".data_del", function (){ var id = $(this).attr("id"); $("#del_id").val(id); var screen = $("body").attr("id"); screen = screen.split("_"); if(screen[1] == "description" && screen[2] == "title" && screen[3] == "pattern" && screen[4] == "list") { var url = "https://fcc.tokyo/inc/do/del_"+screen[0]+"_"+screen[1]+"_"+screen[2]+"_"+screen[3]+".php"; } else if(screen[1] == "description" && screen[2] == "title" && screen[3] == "list") { var url = "https://fcc.tokyo/inc/do/del_"+screen[0]+"_"+screen[1]+"_"+screen[2]+".php"; } else if(screen[1] == "pattern") { var url = "https://fcc.tokyo/inc/do/del_"+screen[0]+"_"+screen[1]+".php"; } else if(screen[0] == "set" && screen[1] == "review") { var url = "https://fcc.tokyo/inc/do/del_"+screen[0]+"_"+screen[1]+".php"; } else if(screen[0] == "tokuisaki" && screen[1] == "make") { var url = "https://fcc.tokyo/inc/do/del_point.php"; } else { var url = "https://fcc.tokyo/inc/do/del_"+screen[0]+".php"; } var type = Number(screen[2]); if(!isNaN(type)){ $("#type").val(type); } else { var type = Number(screen[3]); if(!isNaN(type)){ $("#type").val(type); } } $("#del_form").attr("action", url); return false; }); $(document).on("click", "#del_finish", function (){ $("#del_form").submit(); }); //select絞り込み $(document).on("change", ".parent", function(){ var val1 = $(this).val(); $(".children").each(function(){ var option = $(this).find("option"); option.attr("selected", false); $(option).each(function(){ var val2 = $(this).data("val"); if(val1 != val2 && val2 != 0){ $(this).not(":first-child").hide(); } else { $(this).not(":first-child").show(); } }); if(val1 == ""){ $(this).attr("disabled", "disabled"); } else { $(this).removeAttr("disabled"); } }); }); $(window).on("load", function(){ var val1 = $(".parent").val(); $(".children").each(function(){ var option = $(this).find("option"); $(option).each(function(){ var val2 = $(this).data("val"); if(val1 != val2 && val2 != 0){ $(this).not(":first-child").hide(); } else { $(this).not(":first-child").show(); } }); if(val1 == ""){ $(this).attr("disabled", "disabled"); } else { $(this).removeAttr("disabled"); } }); }); //select絞り込み(サブあり) $(document).on("change", ".parent_sub", function(){ var val1 = []; if($(".parent_sub").val()){ val1.push(Number($(".parent_sub").val())); } if($(".sub").length){ $(".sub").each(function(){ if($(this).val() != ""){ val1.push(Number($(this).val())); } }); } $(".children_sub").each(function(){ var option = $(this).find("option"); option.attr("selected", false); $(option).each(function(){ var val2 = String($(this).data("val")); val2 = val2.split(","); var data = $(this).not(":first-child"); data.hide(); $(val1).each(function(index, value){ if($.inArray(String(value), val2) !== -1){ data.show(); } }); }); if(val1.length == 0){ $(this).attr("disabled", "disabled"); } else { $(this).removeAttr("disabled"); } }); }); $(window).on("load", function(){ var val1 = []; if($(".parent_sub").val()){ val1.push(Number($(".parent_sub").val())); } if($(".sub").length){ $(".sub").each(function(){ if($(this).val() != ""){ val1.push(Number($(this).val())); } }); } $(".children_sub").each(function(){ var option = $(this).find("option"); $(option).each(function(){ var val2 = String($(this).data("val")); val2 = val2.split(","); var data = $(this).not(":first-child"); data.hide(); $(val1).each(function(index, value){ if($.inArray(String(value), val2) !== -1){ data.show(); } }); }); if(val1.length == 0){ $(this).attr("disabled", "disabled"); } else { $(this).removeAttr("disabled"); } }); }); //メインジャンルと重複していないサブジャンルに絞り込み $(document).on("change", "#main_genre", function(){ var val1 = $(this).val(); $(".sub_genre").each(function(){ var option = $(this).find("option"); option.attr("selected", false); $(option).each(function(){ var val2 = $(this).val(); if(val1 != val2 && val2 != 0){ $(this).not(":first-child").show(); } else { $(this).not(":first-child").hide(); } }); }); }); $(window).on("load", function(){ var val1 = $("#main_genre").val(); $(".sub_genre").each(function(){ var option = $(this).find("option"); $(option).each(function(){ var val2 = $(this).val(); if(val1 != val2 && val2 != 0){ $(this).not(":first-child").show(); } else { $(this).not(":first-child").hide(); } }); }); }); $("#item_claer").on("click", function() { $('input[name=item_id]').val(""); }); //文字数カウント $(".count_chara").on("input", function(){ //文字数を取得 var count = $(this).val().length; var id = $(this).attr("id"); //現在の文字数を表示 $("#"+id+"_area").find(".now_count").text(count); }); //リロード時に初期文字列が入っていた時の対策 $(".count_chara").trigger("input"); //印刷ダイアログ実行 $(document).on("click", ".print_exec_btn", function(){ var params = $("#juchu_form").serialize(); $.ajax({ url: "https://fcc.tokyo/inc/do/update_juchu_print.php", type: "POST", cache: false, data: params, success: function(data){ window.print(); return false; }, error: function(xhr, ts, err){ } }); }); //チェックを入れた行のテーブルの背景色を変える $(document).on("change", ".check_color", function(){ $("tr").removeClass("checked"); $(".check_table tbody input:checked").each(function() { $(this).parents("tr").addClass("checked"); }); }); }); $(function() { var Accordion = function(el, multiple) { this.el = el || {}; this.multiple = multiple || false; // Variables privadas var links = this.el.find('.link'); // Evento links.on('click', {el: this.el, multiple: this.multiple}, this.dropdown) } Accordion.prototype.dropdown = function(e) { var $el = e.data.el; $this = $(this), $next = $this.next(); $next.slideToggle(); $this.parent().toggleClass('open'); if (!e.data.multiple) { $el.find('.submenu').not($next).slideUp().parent().removeClass('open'); }; } var accordion = new Accordion($('#accordion'), false); }); //バリデーション設定 (function($) { "use strict"; // Validatorの初期値を変更 $.validator.setDefaults({ ignore: [], onfocusout : false, onkeyup : false, onclick : false, focusInvalid : false, errorElement: "p", // NG項目のclass errorClass : 'has-error', // OK項目のclass validClass : 'has-success', errorLabelContainer: "#modal-message-area", // 入力チェックNGの場合、項目のcontrol-groupにerrorClassを設定 highlight : function(element, errorClass, validClass) { $(element).addClass(errorClass).removeClass(validClass); }, // 入力チェックOKの場合、項目のcontrol-groupにvalidClassを設定 unhighlight : function(element, errorClass, validClass) { $(element).removeClass(errorClass).addClass(validClass); }, showErrors: function(errorMap, errorList) { if(errorList.length > 0){ $("#modal-message-area").html(""); var err = "" $.each(errorMap, function(index, value) { err += '

'+value+'

' }); $("#modal-message-area").html(err); $("#modal-message-open").trigger("click"); $("#form_btn").show(); $("#loader").hide(); }else{ $("#modal-message-area").html(""); $("#form_btn").hide(); $("#loader").show(); } } }); }(jQuery)); //商品名オートコンプリート var autocompleteInit = function() { $(".item_select").autocomplete({ minLength:0, source: function(request, response){ $.ajax({ url: "https://fcc.tokyo/inc/do/item_search.php", type: "POST", cache: false, dataType: "json", data: {q:request.term}, success: function(data){ response(data); }, error: function(xhr, ts, err){ response(['']); } }); }, search: function(e, ui){ $(this).next(".item_id").val(""); }, select: function(e, ui){ if(ui.item.item_id){ $(this).val(""); $(this).val(ui.item.item_id); $(this).next(".item_id").val(ui.item.item_id); } return false; } }); }; //商品詳細オートコンプリート var autocompleteMoreInit = function() { $(".item_more_select").autocomplete({ minLength:0, delay:0, source: function(request, response){ $.ajax({ url: "https://fcc.tokyo/inc/do/item_search.php", type: "POST", cache: false, dataType: "json", data: {q:request.term}, success: function(data){ response(data); }, error: function(xhr, ts, err){ response(['']); } }); }, select: function(e, ui){ if(ui.item.item_id){ $(this).val(""); $(this).val(ui.item.item_id); $(this).parents(".row").find(".jodai_tanka").html(String(ui.item.jodai_tanka).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")); $(this).parents(".row").find(".web_uriage_tanka").html(String(ui.item.web_uriage_tanka).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")); $(this).parents(".row").find(".hyojun_shiire_tanka").html(String(ui.item.hyojun_shiire_tanka).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")); set_update(); } return false; } }); }; //商品詳細オートコンプリート(受注用) var autocompleteRowInit = function() { $(".item_row_select").autocomplete({ minLength:0, source: function(request, response){ $.ajax({ url: "https://fcc.tokyo/inc/do/item_search.php", type: "POST", cache: false, dataType: "json", data: {q:request.term}, success: function(data){ response(data); }, error: function(xhr, ts, err){ response(['']); } }); }, select: function(e, ui){ if(ui.item.item_id){ $(this).val(""); $(this).val(ui.item.item_id); var row = $(this).parents(".row"); row.find(".p-name input").val(ui.item.item_name); row.find(".uriage_area input").val(ui.item.web_uriage_tanka); row.find(".shiire_area input").val(ui.item.hyojun_shiire_tanka); var line = row.find(".line_num").html(); var tokuisaki_id = $("input[name='tokuisaki_id']").val(); var juchu_flag = $("#juchu_flag").val(); $.ajax({ url : "https://fcc.tokyo/inc/do/get_item_order_form.php", type : "post", cache : false, data : { item_id: ui.item.item_id, iro_code: "", line: line, tokuisaki_id: tokuisaki_id, juchu: juchu_flag }, success: function(data){ var data = $.parseJSON(data); row.find(".iro_area").html(data.iro); row.find(".size_area").html(data.size); row.find(".size_area").html(data.size); row.find(".p-tokune").html(""); row.find(".p-tokune").html(data.tokune_icon+data.other_tokune_icon); juchu_status_update(); }, error: function(request){ alert("Error!"); } }); price_update(); } return false; } }); }; //商品詳細オートコンプリート(サンプル用) var autocompleteSampleRowInit = function() { $(".item_row_sample_select").autocomplete({ minLength:0, source: function(request, response){ $.ajax({ url: "https://fcc.tokyo/inc/do/item_search.php", type: "POST", cache: false, dataType: "json", data: {q:request.term}, success: function(data){ response(data); }, error: function(xhr, ts, err){ response(['']); } }); }, select: function(e, ui){ if(ui.item.item_id){ $(this).val(""); $(this).val(ui.item.item_id); var row = $(this).parents(".row"); row.find(".p-name input").val(ui.item.item_name); row.find(".uriage_area input").val(ui.item.web_uriage_tanka); row.find(".shiire_area input").val(ui.item.hyojun_shiire_tanka); var line = row.find(".line_num").html(); $.ajax({ url : "https://fcc.tokyo/inc/do/get_item_sample_form.php", type : "post", cache : false, data : { item_id: ui.item.item_id, iro_code: "", line: line }, success: function(data){ var data = $.parseJSON(data); row.find(".iro_area").html(data.iro); row.find(".size_area").html(data.size); }, error: function(request){ alert("Error!"); } }); price_update(); } return false; } }); }; //商品詳細オートコンプリート(ジャンル) var autocompleteGenreInit = function() { $(".item_genre_select").autocomplete({ minLength:0, delay:0, source: function(request, response){ var genre_id = $("input[name='genre_id']").val(); //var genre_id = $("select[name='genre_id'] option:selected").val(); $.ajax({ url: "../../../inc/do/item_search.php", type: "POST", cache: false, dataType: "json", data: {q:request.term, genre_id:genre_id}, success: function(data){ response(data); }, error: function(xhr, ts, err){ response(['']); } }); }, select: function(e, ui){ if(ui.item.item_id){ $(this).val(""); $(this).val(ui.item.item_id); $(this).parents(".row").find(".jodai_tanka").html(String(ui.item.jodai_tanka).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")); $(this).parents(".row").find(".web_uriage_tanka").html(String(ui.item.web_uriage_tanka).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")); $(this).parents(".row").find(".hyojun_shiire_tanka").html(String(ui.item.hyojun_shiire_tanka).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")); $(this).parents(".row").find(".main_flag").val(ui.item.item_id); set_update(); } return false; } }); }; //得意先情報オートコンプリート var autocompleteTokuisakiInit = function() { $(".tokuisaki_more_select").autocomplete({ minLength:0, source: function(request, response){ $.ajax({ url: "https://fcc.tokyo/inc/do/tokuisaki_search.php", type: "POST", cache: false, dataType: "json", data: {q:request.term}, success: function(data){ response(data); }, error: function(xhr, ts, err){ response(['']); } }); }, search: function(e, ui){ $(this).next("input").val(""); }, select: function(e, ui){ $(this).next("input").val(""); if(ui.item.tokuisaki_name){ $(this).val(""); $(this).val(ui.item.tokuisaki_name); $(this).next("input").val(ui.item.tokuisaki_id).change(); if($("#mailaddress")){ $("#mailaddress").html(ui.item.mailaddress); } if($("select[name='tantosya_id']")){ if(!$("select[name='tantosya_id']").hasClass("non")){ $("select[name='tantosya_id']").val(ui.item.tantosya_id); } } } if($(".row").length){ $(".row").each(function(i){ var row = $(this); var item_id = row.find(".p-code").children("input").val(); var line = row.find(".line_num").html(); var tokuisaki_id = ui.item.tokuisaki_id; var juchu_flag = $("#juchu_flag").val(); $.ajax({ url : "https://fcc.tokyo/inc/do/get_item_order_form.php", type : "post", cache : false, data : { item_id: item_id, iro_code: "", line: line, tokuisaki_id: tokuisaki_id, juchu: juchu_flag }, success: function(data){ var data = $.parseJSON(data); row.find(".p-tokune").html(""); row.find(".p-tokune").html(data.tokune_icon+data.other_tokune_icon); juchu_status_update(); }, error: function(request){ alert("Error!"); } }); price_update(); }); } return false; } }); }; //セット商品名オートコンプリート var autocompleteGroupItemInit = function() { $(".group_item_select").autocomplete({ minLength:0, source: function(request, response){ $.ajax({ url: "https://fcc.tokyo/inc/do/group_item_search.php", type: "POST", cache: false, dataType: "json", data: {q:request.term}, success: function(data){ response(data); }, error: function(xhr, ts, err){ response(['']); } }); }, search: function(e, ui){ $(this).next(".group_item_id").val(""); }, select: function(e, ui){ if(ui.item.group_item_id){ $(this).val(""); $(this).val(ui.item.group_item_name); $(this).next(".group_item_id").val(ui.item.group_item_id); } return false; } }); }; function get_soryo(zeinuki_gokei_kingaku, zipcode = "", genre_id = ""){ return $.ajax({ url: "https://fcc.tokyo/inc/do/get_soryo.php", type: "POST", cache: false, async: false, data: { total:zeinuki_gokei_kingaku, zipcode:zipcode, genre_id:genre_id } }); } function get_daibiki(zeinuki_gokei_kingaku, genre_id){ return $.ajax({ url: "https://fcc.tokyo/inc/do/get_daibiki.php", type: "POST", cache: false, async: false, data: { zeinuki_gokei_kingaku:zeinuki_gokei_kingaku, genre_id:genre_id } }); } function get_atobarai(zeinuki_gokei_kingaku, genre_id){ return $.ajax({ url: "https://fcc.tokyo/inc/do/get_atobarai.php", type: "POST", cache: false, async: false, data: { zeinuki_gokei_kingaku:zeinuki_gokei_kingaku, genre_id:genre_id } }); } //合計金額更新 var price_update = function(name = "") { var genre_id = $('select[name="genre_id"]').val(); var uriage_total = 0; var shiire_total = 0; //送料取得 var soryo = $('input[name="soryo"]').val(); if(soryo){ soryo = parseInt(soryo); } else { soryo = 0; } //使用ポイント取得 var point = $('input[name="point_kingaku"]').val(); if(point){ point = parseInt(point); } else { point = 0; } //使用クーポン取得 var coupon = $('input[name="coupon_kingaku"]').val(); if(coupon){ coupon = parseInt(coupon); } else { coupon = 0; } //割引額取得 var discount_price = $('input[name="discount_price"]').val(); if(discount_price){ discount_price = parseInt(discount_price); } else { discount_price = 0; } //代引手数料取得 var daibiki = $('input[name="daibiki"]').val(); if(daibiki){ daibiki = parseInt(daibiki); } else { daibiki = 0; } //後払手数料取得 var atobarai = $('input[name="atobarai_tesuryo"]').val(); if(atobarai){ atobarai = parseInt(atobarai); } else { atobarai = 0; } //加工費用取得 var kakou_price = $('input[name="kakou_price"]').val(); if(kakou_price){ kakou_price = parseInt(kakou_price); } else { kakou_price = 0; } //税率取得 var tax_display = $('input[name="tax_display"]').val(); var shohizei_ritsu = $('input[name="shohizei_ritsu"]').val(); var zei_kakaku = $('input[name="zei_kakaku"]').val(); parseInt(shohizei_ritsu); parseInt(zei_kakaku); shohizei_ritsu = shohizei_ritsu/100; var total_num = 0; $("#estimate_table tbody.row").each(function(i, elem) { var total = 0; var uriage = 0; var shiire = 0; $(elem).find(".num_table").each(function(k, el) { var num = $(this).find(".item_num").val(); if(!num){ num = 0; } var uriage_tanka = $(this).find(".uriage_tanka").val(); var shiire_tanka = $(this).find(".shiire_tanka").val(); num = parseInt(num); uriage_tanka = parseInt(uriage_tanka); shiire_tanka = parseInt(shiire_tanka); uriage_price = uriage_tanka*num; shiire_price = shiire_tanka*num; total = total + num; total_num = total_num + num; if(Number.isNaN(uriage_price) == false){ uriage = uriage + uriage_price; } if(Number.isNaN(shiire_price) == false){ shiire = shiire + shiire_price; } }); if(Number.isNaN(uriage) == false && Number.isNaN(shiire) == false){ var arari = uriage - shiire; var rieki_ritsu = Math.floor(arari/uriage*100*10)/10; $(this).find(".rieki_ritsu").html(rieki_ritsu); } total = String(total).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); $(this).find(".row_num").html(total); if(Number.isNaN(uriage) == false){ uriage_total += uriage; uriage = String(uriage).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); $(this).find(".uriage_total").html(uriage); } if(Number.isNaN(shiire) == false){ shiire_total += shiire; shiire = String(shiire).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); $(this).find(".shiire_total").html(shiire); } }); $('input[name="zeinuki_gokei_kingaku"]').val(uriage_total); // var zipcode = $('input[name="nonyusaki_postcode"]').val(); // if(name != "soryo" && name != "daibiki"){ // get_soryo(uriage_total, zipcode, genre_id).then(function(data) { // soryo = parseInt(data); // $('input[name="soryo"]').val(soryo); // }); // } var nyukin_joken_id = $("#nyukin_joken_id").val(); if(nyukin_joken_id == 1){ if(name != "soryo" && name != "daibiki"){ get_daibiki(uriage_total, genre_id).then(function(data) { daibiki = parseInt(data); $('input[name="daibiki"]').val(daibiki); }); } atobarai = 0; $('input[name="atobarai_tesuryo"]').val(atobarai); } else if(nyukin_joken_id == 10) { if(name != "soryo" && name != "atobarai_tesuryo"){ get_atobarai(uriage_total, genre_id).then(function(data) { atobarai = parseInt(data); $('input[name="atobarai_tesuryo"]').val(atobarai); }); } daibiki = 0; $('input[name="daibiki"]').val(daibiki); } else { daibiki = 0; $('input[name="daibiki"]').val(daibiki); atobarai = 0; $('input[name="atobarai_tesuryo"]').val(atobarai); } var total = uriage_total + soryo + daibiki + atobarai + kakou_price; var arari = uriage_total - shiire_total; var rieki_ritsu = Math.floor(arari/uriage_total*100*10)/10; total = total-point-coupon-discount_price; var shohizei_kingaku = Math.round(total*shohizei_ritsu); $('input[name="shohizei_kingaku"]').val(shohizei_kingaku); if(Number.isNaN(shohizei_kingaku) == false){ total = String(total+shohizei_kingaku).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); } else{ total = String(total-point-coupon-discount_price).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); } if(total != "NaN"){ $("#total").html(total); } if(total_num != "NaN"){ $("#total_num").html(total_num); } arari = String(arari).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); if(arari != "NaN"){ $("#arari").html(arari); } if(Number.isNaN(rieki_ritsu) == false){ $("#rieki_ritsu").html(rieki_ritsu); } uriage_total = String(uriage_total).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); if(uriage_total != "NaN"){ $("#shokei").html(uriage_total); } shohizei_kingaku = String(shohizei_kingaku).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); if(shohizei_kingaku != "NaN"){ $("#shohizei_kingaku").html(shohizei_kingaku); } }; //セット商品価格更新 var set_update = function() { var jodai = 0; var uriage = 0; var shiire = 0; $("#calc_table tbody.row").each(function(i, elem) { var jodai_tanka = $(this).find(".jodai_tanka").html().split(',').join(''); var web_uriage_tanka = $(this).find(".web_uriage_tanka").html().split(',').join(''); var hyojun_shiire_tanka = $(this).find(".hyojun_shiire_tanka").html().split(',').join(''); jodai_tanka = parseInt(jodai_tanka); web_uriage_tanka = parseInt(web_uriage_tanka); hyojun_shiire_tanka = parseInt(hyojun_shiire_tanka); jodai += jodai_tanka; uriage += web_uriage_tanka; shiire += hyojun_shiire_tanka; }); jodai = String(jodai).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); $("#jodai_total").html(jodai); uriage = String(uriage).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); $("#web_uriage_total").html(uriage); shiire = String(shiire).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); $("#hyojun_shiire_total").html(shiire); }; //商品名オートコンプリート(レビュー用) var autocompleteReviewInit = function() { $(".item_select").autocomplete({ minLength:0, source: function(request, response){ var genre_id = $("input[name='genre_id']").val(); //var genre_id = $("select[name='genre_id'] option:selected").val(); $.ajax({ url: "https://fcc.tokyo/inc/do/item_search.php", type: "POST", cache: false, dataType: "json", data: {q:request.term, genre_id:genre_id}, success: function(data){ response(data); }, error: function(xhr, ts, err){ response(['']); } }); }, search: function(e, ui){ $(this).next(".item_id").val(""); }, select: function(e, ui){ if(ui.item.item_id){ var val1 = ui.item.genre_ids.split(",").filter(Boolean); $(this).val(""); $(this).val(ui.item.item_id); $(this).next(".item_id").val(ui.item.item_id); $(".genre").each(function(){ var option = $(this).find("option"); var data = option.not(":first-child"); data.hide(); $(option).each(function(){ var val2 = $(this).val(); if($.inArray(val2, val1) !== -1){ $(this).show(); } }); if(val1.length == 0){ $(this).attr("disabled", "disabled"); } else { $(this).removeAttr("disabled"); } }); } return false; } }); }; //セット商品名オートコンプリート(レビュー用) var autocompleteGroupItemReviewInit = function() { $(".group_item_select").autocomplete({ minLength:0, source: function(request, response){ var genre_id = $("input[name='genre_id']").val(); //var genre_id = $("select[name='genre_id'] option:selected").val(); $.ajax({ url: "https://fcc.tokyo/inc/do/group_item_search.php", type: "POST", cache: false, dataType: "json", data: {q:request.term, genre_id:genre_id}, success: function(data){ response(data); }, error: function(xhr, ts, err){ response(['']); } }); }, search: function(e, ui){ $(this).next(".group_item_id").val(""); }, select: function(e, ui){ if(ui.item.group_item_id){ var val1 = ui.item.genre_ids.split(",").filter(Boolean); $(this).val(""); $(this).val(ui.item.group_item_name); $(this).next(".group_item_id").val(ui.item.group_item_id); $(".genre").each(function(){ var option = $(this).find("option"); var data = option.not(":first-child"); data.hide(); $(option).each(function(){ var val2 = $(this).val(); if($.inArray(val2, val1) !== -1){ $(this).show(); } }); if(val1.length == 0){ $(this).attr("disabled", "disabled"); } else { $(this).removeAttr("disabled"); } }); } return false; } }); }; //得意先情報オートコンプリート(レビュー用) var autocompleteReviewTokuisakiInit = function() { $(".tokuisaki_more_select").autocomplete({ minLength:0, source: function(request, response){ $.ajax({ url: "https://fcc.tokyo/inc/do/tokuisaki_search.php", type: "POST", cache: false, dataType: "json", data: {q:request.term, members_flag:1}, success: function(data){ response(data); }, error: function(xhr, ts, err){ response(['']); } }); }, search: function(e, ui){ $(this).next("input").val(""); }, select: function(e, ui){ $(this).next("input").val(""); if(ui.item.tokuisaki_name){ $(this).val(""); $(this).val(ui.item.tokuisaki_name); $(this).next("input").val(ui.item.tokuisaki_id).change(); if($("#mailaddress")){ $("#mailaddress").html(ui.item.mailaddress); } if($("select[name='tantosya_id']")){ $("select[name='tantosya_id']").val(ui.item.tantosya_id) } } return false; } }); }; //受注ステイタスが「入荷待ちー分納」「入荷待ちー一括出荷」だった場合、サイズごとにステイタスを表示 var juchu_status_update = function() { var juchu_status_id = $("select[name='juchu_status_id']").val(); $("#estimate_table tbody.row").each(function(i, elem) { $(elem).find(".num_table").each(function(k, el) { var row = $(this).find(".row_status"); if(juchu_status_id == 691 || juchu_status_id == 692){ row.show(); var num = Number($(this).find(".item_num").val()); var data = $(this).find(".row_status option:selected").val(); if(num > 0 && data == ""){ row.val(690); } } else { row.hide(); $(this).find(".row_status option").prop("selected", false); } }); }); } var juchu_status_load = function() { $(window).on("load", function(){ var juchu_status_id = $("select[name='juchu_status_id']").val(); $("#estimate_table tbody.row").each(function(i, elem) { $(elem).find(".num_table").each(function(k, el) { var row = $(this).find(".row_status"); if(juchu_status_id == 691 || juchu_status_id == 692){ row.show(); } else { row.hide(); $(this).find(".row_status option").prop("selected", false); } }); }); }); }