package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.apache.jasper.runtime.*;
import java.util.*;
import java.sql.*;
import java.io.File;
import org.apache.log4j.Category;
import jp.co.sint.database.*;
import jp.co.sint.tools.*;
import jp.co.sint.basic.*;
import jp.co.sint.config.*;
import jp.co.sint.beans.front.*;
import jp.co.sint.beans.mallmgr.*;
import jp.co.sint.servlet.front.SICustAccessLog;

public class cmdty_Kart_Button_quick_order_jsp extends HttpJspBase {


  private static java.util.Vector _jspx_includes;

  public java.util.List getIncludes() {
    return _jspx_includes;
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    javax.servlet.jsp.PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;


    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html;charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			"util/error.jsp", true, 8192, true);
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n\r\n");
/**タグのセクション*/
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
/**エラー遷移先の定義のセクション*/
      out.write("\r\n");
      out.write("\r\n");
/**クラスのインポートのセクション*/
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n\r\n");


String webshopSite=SIHTMLUtil.getRootPath(request);
SICmdty cmdty = (SICmdty)session.getAttribute(SIConfig.SISESSION_CATALOG_CARTIN_NAME);
//データベースへのコネンクション(common)
SIDatabaseConnection databaseConnection=new SIDatabaseConnection();
Connection connection=databaseConnection.getConnection();try {

UICmdtyInfoForQuickOrder cmdtyInfoID=(UICmdtyInfoForQuickOrder)session.getAttribute(SIConfig.SISESSION_CMDTY_LIST_NAME);
if (cmdtyInfoID==null)cmdtyInfoID=new UICmdtyInfoForQuickOrder();

String row = cmdtyInfoID.getTaishoRow();
String loginSite="/catalog";
String loginAdd="/"+cmdtyInfoID.getCmdtyCodeTxt()+"/"+cmdtyInfoID.getIndividualCodeTxt();

int compositionOrderCount = cmdtyInfoID.getCompositionOrderCount();

boolean fixedSetSoldOut = false;
if (cmdty.getCmdtyCompositionFlg().equals(SIConfig.CMDTY_COMPOSITION_FIXED_SET)) {
  int fixedAmount = cmdty.getFixedSetAmount(connection);
  if (fixedAmount == 0) {
    fixedSetSoldOut = true;
  }
}

      out.write("\r\n\r\n");
 if("1".equals(cmdtyInfoID.isErrFlg())){
      out.write("\r\n  ");
      out.write("<button type=\"submit\" class=\"btnAddCart opa30\" disabled=\"disabled\">");
      out.write("<span>カートに入れる");
      out.write("</span>");
      out.write("</button>\r\n");
 } else { 
      out.write("\r\n  ");
if(cmdty.isHairCosme(request)){
      out.write("\r\n  ");
      out.write("<p class=\"btn btnContact\">");
      out.write("<a href=\"");
      out.print(SIURLMap.getHttpsUrl(request,"webshop.servlet.front.haircosme"));
      out.write("\"  Target=\"_blank\">");
      out.write("<span class=\"fcRed\">契約者様限定");
      out.write("</span>");
      out.write("<br>お取引申込はこちら");
      out.write("</a>");
      out.write("</p>\r\n  ");
}else if(cmdty.isContractFlg()&&SIHTMLUtil.getUserInfo(request).isNotLogin(request)){
      out.write("\r\n  ");
      out.write("<p class=\"btn btnContact\">");
      out.write("<a href=\"");
      out.print(SIURLMap.getHttpsUrl(request,"webshop.servlet.front.user.login")+"?nid="+loginSite+loginAdd);
      out.write("\"  Target=\"_blank\">");
      out.write("<span class=\"fcRed\">契約者様限定");
      out.write("</span>");
      out.write("<br>ログインはこちら");
      out.write("</a>");
      out.write("</p>\r\n  ");
}else if(cmdty.isContractFlg() && cmdty.isMailContract(connection)){
      out.write("\r\n  ");
      out.write("<p class=\"btn btnContact\">");
      out.write("<a href=\"");
      out.print(SIURLMap.getHttpsUrl(request,"webshop.servlet.front.contract_peachpeau")+"?contractMaker="+cmdty.getMakerCode());
      out.write("\"  Target=\"_blank\">");
      out.write("<span class=\"fcRed\">契約者様限定");
      out.write("</span>");
      out.write("<br>お取引申込はこちら");
      out.write("</a>");
      out.write("</p>\r\n  ");
}else if(cmdty.isContractFlg()){
      out.write("\r\n  ");
      out.write("<p class=\"btn btnContact\">");
      out.write("<a href=\"");
      out.print(SIHTMLUtil.consURL(request,webshopSite+"/guide/license.html",false));
      out.write("\"  Target=\"_blank\">");
      out.write("<span class=\"fcRed\">契約者様限定");
      out.write("</span>");
      out.write("<br>お取引申込はこちら");
      out.write("</a>");
      out.write("</p>\r\n  ");
}else if(cmdty.getInquiryFlg().equals("1")){
      out.write("\r\n  ");
      out.write("<p class=\"btn btnContact\">");
      out.write("<a href=\"tel:0120974554\">お問い合わせください");
      out.write("<br>0120-974-554");
      out.write("</a>");
      out.write("</p>\r\n  ");
 } else if (compositionOrderCount <= 0 && !fixedSetSoldOut) { 
      out.write("\r\n    ");
if(cmdty.getAmountFlg().equals("0")){
      out.write("\r\n    ");
      out.write("<button id=\"bouttonCart\" class=\"btnAddCart\" onClick=\"addCartForQuickOrder(");
      out.print( row );
      out.write("); return false;\">");
      out.write("<span>カートに入れる");
      out.write("</span>");
      out.write("</button>\r\n    ");
}else if(!cmdty.getAmount().equals("0")){
      out.write("\r\n    ");
      out.write("<button id=\"bouttonCart\" class=\"btnAddCart\" onClick=\"addCartForQuickOrder(");
      out.print( row );
      out.write("); return false;\">");
      out.write("<span>カートに入れる");
      out.write("</span>");
      out.write("</button>\r\n    ");
}else if(cmdty.getRsrvEnableFlg().equals("1")&&!cmdty.getRsrvAmount().equals("0")){
      out.write("\r\n    ");
      out.write("<button id=\"bouttonRsrv\" class=\"btnBook btnYl\"  onClick=\"addRsrv(");
      out.print( row );
      out.write("); return false;\">");
      out.write("<span>予約する");
      out.write("</span>");
      out.write("</button>\r\n    ");
}else{
      out.write("\r\n    ");
      out.write("<p class=\"btn soldout\">");
      out.write("<span class=\"fcRed\">SOLD OUT");
      out.write("</span>");
      out.write("</p>\r\n    ");
}
      out.write("\r\n  ");
}else{
      out.write("\r\n  ");
      out.write("<p class=\"btn soldout\">");
      out.write("<span class=\"fcRed\">SOLD OUT");
      out.write("</span>");
      out.write("</p>\r\n  ");
}
      out.write("\r\n");
}
      out.write("\r\n");

}catch(Exception e){
  e.printStackTrace();
  throw new ServletException();
}finally{
  databaseConnection.close();
}

    } catch (Throwable t) {
      out = _jspx_out;
      if (out != null && out.getBufferSize() != 0)
        out.clearBuffer();
      if (pageContext != null) pageContext.handlePageException(t);
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
    }
  }
}
