<%@page contentType="text/html; charset=utf-8"%>
<%@page import="org.acts.common.*" %>
<%@page import="org.acts.common.html.*" %>
<%@page import="org.acts.member.*" %>
<%@page import="org.acts.venue.*" %>
<%@include file="../include/check_login.jsp" %>

<%@include file="../include/header.jsp" %>
<%msbean.setCur_menu_node(MenuItem.VENUE__REQUEST_RECORD);%>
<link rel="stylesheet" type="text/css" href="../script/ext/resources/css/ext-all.css">
<script type="text/javascript" src="../script/ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../script/ext/ext-all.js"></script>
<script type="text/javascript">
function readRequest(vr_seq){
	var f=document.stdform;
	f.rr_op_vr_seq.value=vr_seq;
	opSubmit("venue.VenueModuleAction.request_record.readRequest");
}
function updateRequest(vr_seq){
	var f=document.stdform;
	f.rr_op_vr_seq.value=vr_seq;
	opSubmit("venue.VenueModuleAction.request_record.updateRequest");
}
function copyRequest(vr_seq){
	var f=document.stdform;
	f.rr_op_vr_seq.value=vr_seq;
	opSubmit("venue.VenueModuleAction.request_record.copyRequest");
}
function cancelRequest(vr_seq){
	var f=document.stdform;
	f.rr_op_vr_seq.value=vr_seq;
	if(confirm("<%=Lang.set("Cancel this reservation?")%>")){
		opSubmit("venue.VenueModuleAction.request_record.cancelRequest");
	}
}
</script>
<%@include file="../include/body.jsp" %>
<%
RecordList venues=Venue.getVenueNames();
SelectMenu venueSM=new SelectMenu("rr_venue_seq",venues,"name","venue_seq",String.valueOf(msbean.getIData("rr_venue_seq")));
venueSM.setNilItem(Lang.set("-------"),"");
ExtJs extjs=new ExtJs();

ExtDateTextBox start_dateDTB=new ExtDateTextBox("rr_start_date",msbean.getSData("rr_start_date"),"From&nbsp;",extjs);
ExtDateTextBox end_dateDTB=new ExtDateTextBox("rr_end_date",msbean.getSData("rr_end_date"),"To&nbsp;",extjs);

HtmlTable t=new HtmlTable(new int[]{180,315,195,150,120,100});
t.addTitleCell(0,0,msbean.getCur_menu_node().getName());
t.addRCell(1,0,2,1,Lang.set("Venue&nbsp;")+venueSM.toHtml());
t.addLCell(3,0,start_dateDTB);
t.addLCell(4,0,end_dateDTB);
t.addRCell(5,0,new Button("Refresh","javascript:opSubmit('venue.VenueModuleAction.request_record.read')"));
t.toHtml(out);

int row=0;
t=new HtmlTable(new int[]{90,55,55,55,135,150,45,120,85,145});

t.addHeaderCell(0,row,"Date");
t.addHeaderCell(1,row,"Week");
t.addHeaderCell(2,row,"Start");
t.addHeaderCell(3,row,"End");
t.addHeaderCell(4,row,"Venue");
t.addHeaderCell(5,row,"Group");
t.addHeaderCell(6,row,"User#");
t.addHeaderCell(7,row,"Usage");
t.addHeaderCell(8,row,"Status");
t.addHeaderCell(9,row,"Action"+(new Hidden("rr_op_vr_seq","-1")).toHtml());

RecordList r=VenueRequest.search(
	msbean.getIData("rr_venue_seq")
	,msbean.getTData("rr_start_date")
	,msbean.getTData("rr_end_date")
	,msbean.getMember_seq()
	,true
	);
for(int i=0;i<r.size();i++){
    r.setCurrentRow(i);
    row++;
	int vr_seq=r.getI("venue_request_seq");
	String status=r.getS("status");
	String status_code=r.getS("status_code");

	Button readB=new Button("V","readRequest("+vr_seq+")");
	readB.addAttribute("style=\"padding:4px 6px 4px 6px\"");
	readB.setTooltip("View");
	Button updateB=new Button("E","updateRequest("+vr_seq+")");
	updateB.setTooltip("Edit");
	updateB.addAttribute("style=\"padding:4px 6px 4px 6px\"");
	Button copyB=new Button("C","copyRequest("+vr_seq+")");
	copyB.setTooltip("Copy");
	copyB.addAttribute("style=\"padding:4px 6px 4px 6px\"");
	Button cancelB=new Button("X","cancelRequest("+vr_seq+")");
	cancelB.setTooltip("Cancel");
	cancelB.addAttribute("style=\"padding:4px 6px 4px 6px\"");
	
    t.addLCell(0,row,TimeUtil.getStringByDate(r.getT("date")));
	t.addLCell(1,row,TimeUtil.getWeekByDate(r.getT("date")));
    t.addLCell(2,row,r.getS("start_time"));
    t.addLCell(3,row,r.getS("end_time"));
    t.addLCell(4,row,r.getS("venue_name"));
    t.addLCell(5,row,r.getS("member_group_name"));
    t.addLCell(6,row,r.getI("user_num"));
    t.addLCell(7,row,r.getS("purpose"));
	t.addLCell(8,row,status);
	t.addLCell(9,row,
		(!status_code.equals(VenueRequest.STATUS__WA)?(" "+readB.toHtml()):"")
		+(status_code.equals(VenueRequest.STATUS__WA)?(" "+updateB.toHtml()):"")
		+" "+copyB.toHtml()
		+(!status_code.equals(VenueRequest.STATUS__CL)?(" "+cancelB.toHtml()):"")
		);
}

t.toHtml(out);
extjs.toHtml(out);
%>
<%@include file="../include/footer.jsp" %>