#include "wsubformHTML.h"	//サブフォーム専用ヘッダファイルをインクルードする。

extern char gridtitles[MAX_POS][MAX_LEN];	//wsubformHTMLが利用するgridのタイトル。

extern TextBox	 *begin;	//textboxで使用する連鎖ポインタの開始位置
extern TextBox	 *tp;	//textboxで使用する連鎖ポインタ

typedef struct stat Dir;	//ファイル操作用
static Dir dirptr;
static Dir  *fptr = &dirptr;

char tmp[MAX_STR];
static int sqlcode = 0;	//PostgreSQLの返すコード

int DBcount[MAX_FORM];	//wsubformHTMLで利用するDBの現在の最大行数
extern char KEY[256][MAX_STR];	//INSERTとUPDATEが使用する更新項目

int DBConnect(void)
{
	// DB接続用変数宣言です。DB名、ユーザ名、パスワードを設定してください。
	EXEC SQL BEGIN DECLARE SECTION;
		char dbname[12];
		char user[12];
		char passwd[12];
	EXEC SQL END DECLARE SECTION;

	strcpy(dbname,"apsch");
	strcpy(user,"cms");
	strcpy(passwd,"cms");

#ifdef DEBUG
	// ECPGデバッグ文出力
	ECPGdebug (0, stderr);
#endif

	// 接続
	memset (sqlca.sqlstate, '0', 5);
	EXEC SQL CONNECT TO :dbname AS dbConnection user :user USING :passwd;
	if (memcmp (sqlca.sqlstate, "00000", 5) != 0)
	{
		sprintf(tmp,"CONNECT エラー。終了します。:%d - %s",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
	//	logmsg(tmp);
		exit (EXIT_FAILURE);
	}
}

int Fetch_otodoke_Menu(int no)
{
	static char DBbuff[MAX_STR];
	int i = 0;
	char *qs;
	int qcount;

	DBConnect();

	memset (sqlca.sqlstate, '0', 5);

	EXEC SQL BEGIN DECLARE SECTION;
		int rec_count;
		char	 key[256][MAX_STR];
		char	No[3 + 1];	//TEXT
		char	yubinNo[7 + 1];	//TEXT
		char	todofuken[24 + 1];	//TEXT
		char	jusho1[96 + 1];	//TEXT
		char	jusho2[96 + 1];	//TEXT
		char	shimei1[96 + 1];	//TEXT
		char	shimei_f1[192 + 1];	//TEXT
		char	shimei2[96 + 1];	//TEXT
		char	shimei_f2[200 + 1];	//TEXT
		char	TEL[13 + 1];	//TEXT
		char	hinmei[90 + 1];	//TEXT
		char	yoryo[5 + 1];	//TEXT
		char	grade[144 + 1];	//TEXT
		char	size[10 + 1];	//TEXT
		int		kingaku;		//NUMERIC
		unsigned char		jikankibou;		//BOOL
		int		takuhai_s;		//NUMERIC
		unsigned char		tuchi;		//BOOL
		char	denNo[13 + 1];	//TEXT
		unsigned char		tokui;		//BOOL
		char	uketukeDATE[10 + 1];	//TEXT
		char	expDATE[10 + 1];	//TEXT
		char	hopeDATE[10 + 1];	//TEXT
		char	bikou[256 + 1];	//TEXT
		char	hassoCD[5 + 1];	//TEXT
		char	hatutenCD[7 + 1];	//TEXT
		unsigned char		hatuEND;		//BOOL
		unsigned char		prEND;		//BOOL
		int		denNUM;		//NUMERIC
		int		hakoNUM;		//NUMERIC
		char	memo[1024 + 1];	//TEXT
		unsigned char		reserve;		//BOOL
		char	resDATE[10 + 1];	//TEXT
		unsigned char		print;		//BOOL
		int		prNUM;		//NUMERIC
		char	daitaiCD[5 + 1];	//TEXT
		unsigned char		daitai;		//BOOL
		char	FAX[13 + 1];	//TEXT
		char	hm_kubun[2 + 1];	//TEXT
		int		hinsyu;		//NUMERIC
		char	keitaiTEL[13 + 1];	//TEXT
		int		hopeTIME;		//NUMERIC
		int		hopeTIME2;		//NUMERIC
		int		hopeTIME3;		//NUMERIC
		unsigned char		umu;		//BOOL
		int		soryo;		//NUMERIC
		int		hatu_kosuu;		//NUMERIC
		int		hakodai;		//NUMERIC
		char	chitai[60 + 1];	//TEXT
		char	mail[50 + 1];	//TEXT
		int		tesuu;		//NUMERIC
		int		tac;		//NUMERIC
		unsigned char		reitou;		//BOOL
		char	YahooID[32 + 1];	//TEXT
		char	shiwakeCD[13 + 1];	//TEXT
		unsigned char		kariseikyu;		//BOOL
		int		cc_kingaku;		//NUMERIC
		int		st_kingaku;		//NUMERIC
		int		base_soryo;		//NUMERIC
		unsigned char		seikyuEND;		//BOOL
		int		den_hakoNUM;		//NUMERIC
		int		soukin_tesuuryo;		//NUMERIC
	EXEC SQL END DECLARE SECTION;

	sqlcode = 0;
	DBcount[no] = 0;

	rec_count = 0;

	if((qs = getenv("QUERY_STRING")) != (char *)NULL)
	{
		qcount = query_getHTML(qs,'&');
		for(i=0;i < qcount;i++)
		{
			sprintf(key[i],"%s",qt.get[i]);
		}
	}
	else
	{
		sprintf(key[0],"NONE");
		printf("%s<br>\n",key[0]);
	}

//	以下の部分はリレーションテーブルを利用する場合にコメントを外して使用可能にして利用してください。
//	sprintf(KEY[0],"%s",key[0]);

	// DBの行数を取得
	EXEC SQL 
	SELECT 
	COUNT(*)
	INTO :rec_count
	FROM	otodoke
	WHERE hassoCD = :key[0];

	// SELECTエラー 
	if(memcmp (sqlca.sqlstate, "00000", 5) != 0)
	{
		sprintf(tmp,"SELECT COUNTエラー:%d - %s",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
	//	logmsg(tmp);
		return(-1) ;
	}

	DBcount[no] = rec_count;

	EXEC SQL DECLARE otodoke_Menu_CURSOR CURSOR FOR 
	SELECT 
		coalesce(No,' ','0'),
		coalesce(yubinNo,' ','0'),
		coalesce(todofuken,' ','0'),
		coalesce(jusho1,' ','0'),
		coalesce(jusho2,' ','0'),
		coalesce(shimei1,' ','0'),
		coalesce(shimei_f1,' ','0'),
		coalesce(shimei2,' ','0'),
		coalesce(shimei_f2,' ','0'),
		coalesce(TEL,' ','0'),
		coalesce(hinmei,' ','0'),
		coalesce(yoryo,' ','0'),
		coalesce(grade,' ','0'),
		coalesce(size,' ','0'),
		kingaku,
		jikankibou,
		takuhai_s,
		tuchi,
		coalesce(denNo,' ','0'),
		tokui,
		coalesce(uketukeDATE,' ','0'),
		coalesce(expDATE,' ','0'),
		coalesce(hopeDATE,' ','0'),
		coalesce(bikou,' ','0'),
		coalesce(hassoCD,' ','0'),
		coalesce(hatutenCD,' ','0'),
		hatuEND,
		prEND,
		denNUM,
		hakoNUM,
		coalesce(memo,' ','0'),
		reserve,
		coalesce(resDATE,' ','0'),
		print,
		prNUM,
		coalesce(daitaiCD,' ','0'),
		daitai,
		coalesce(FAX,' ','0'),
		coalesce(hm_kubun,' ','0'),
		hinsyu,
		coalesce(keitaiTEL,' ','0'),
		hopeTIME,
		hopeTIME2,
		hopeTIME3,
		umu,
		soryo,
		hatu_kosuu,
		hakodai,
		coalesce(chitai,' ','0'),
		coalesce(mail,' ','0'),
		tesuu,
		tac,
		reitou,
		coalesce(YahooID,' ','0'),
		coalesce(shiwakeCD,' ','0'),
		kariseikyu,
		cc_kingaku,
		st_kingaku,
		base_soryo,
		seikyuEND,
		den_hakoNUM,
		soukin_tesuuryo
	FROM	otodoke
	WHERE hassoCD = :key[0]
	ORDER BY hassoCD;

	// カーソルオープン
	EXEC SQL OPEN otodoke_Menu_CURSOR;

	// CURSOR OPENエラー 
	if (memcmp (sqlca.sqlstate, "00000", 5) != 0)
	{
		sprintf(tmp,"CURSOR OPENエラー:%d - %s",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
	//	logmsg(tmp);
		return(-1);
	}

	for(i=0;i<DBcount[no];i++)
	{
		EXEC SQL FETCH otodoke_Menu_CURSOR INTO
			:No,
			:yubinNo,
			:todofuken,
			:jusho1,
			:jusho2,
			:shimei1,
			:shimei_f1,
			:shimei2,
			:shimei_f2,
			:TEL,
			:hinmei,
			:yoryo,
			:grade,
			:size,
			:kingaku,
			:jikankibou,
			:takuhai_s,
			:tuchi,
			:denNo,
			:tokui,
			:uketukeDATE,
			:expDATE,
			:hopeDATE,
			:bikou,
			:hassoCD,
			:hatutenCD,
			:hatuEND,
			:prEND,
			:denNUM,
			:hakoNUM,
			:memo,
			:reserve,
			:resDATE,
			:print,
			:prNUM,
			:daitaiCD,
			:daitai,
			:FAX,
			:hm_kubun,
			:hinsyu,
			:keitaiTEL,
			:hopeTIME,
			:hopeTIME2,
			:hopeTIME3,
			:umu,
			:soryo,
			:hatu_kosuu,
			:hakodai,
			:chitai,
			:mail,
			:tesuu,
			:tac,
			:reitou,
			:YahooID,
			:shiwakeCD,
			:kariseikyu,
			:cc_kingaku,
			:st_kingaku,
			:base_soryo,
			:seikyuEND,
			:den_hakoNUM,
			:soukin_tesuuryo;

	// テーブル項目をsplitbDBbuff[][]にセットする
		sf_assgetDB(no,i,0,No,3 + 1);
		sf_assgetDB(no,i,1,yubinNo,7 + 1);
		sf_assgetDB(no,i,2,todofuken,24 + 1);
		sf_assgetDB(no,i,3,jusho1,96 + 1);
		sf_assgetDB(no,i,4,jusho2,96 + 1);
		sf_assgetDB(no,i,5,shimei1,96 + 1);
		sf_assgetDB(no,i,6,shimei_f1,192 + 1);
		sf_assgetDB(no,i,7,shimei2,96 + 1);
		sf_assgetDB(no,i,8,shimei_f2,200 + 1);
		sf_assgetDB(no,i,9,TEL,13 + 1);
		sf_assgetDB(no,i,10,hinmei,90 + 1);
		sf_assgetDB(no,i,11,yoryo,5 + 1);
		sf_assgetDB(no,i,12,grade,144 + 1);
		sf_assgetDB(no,i,13,size,10 + 1);
		sf_to_text(kingaku,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,14,DBbuff,5 + 1);
		sprintf(DBbuff,"%c",jikankibou);	//BOOL型(unsigned char)を文字に変換する。
		sf_assgetDB(no,i,15,DBbuff,2 + 1);
		sf_to_text(takuhai_s,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,16,DBbuff,3 + 1);
		sprintf(DBbuff,"%c",tuchi);	//BOOL型(unsigned char)を文字に変換する。
		sf_assgetDB(no,i,17,DBbuff,2 + 1);
		sf_assgetDB(no,i,18,denNo,13 + 1);
		sprintf(DBbuff,"%c",tokui);	//BOOL型(unsigned char)を文字に変換する。
		sf_assgetDB(no,i,19,DBbuff,2 + 1);
		sf_assgetDB(no,i,20,uketukeDATE,10 + 1);
		sf_assgetDB(no,i,21,expDATE,10 + 1);
		sf_assgetDB(no,i,22,hopeDATE,10 + 1);
		sf_assgetDB(no,i,23,bikou,256 + 1);
		sf_assgetDB(no,i,24,hassoCD,5 + 1);
		sf_assgetDB(no,i,25,hatutenCD,7 + 1);
		sprintf(DBbuff,"%c",hatuEND);	//BOOL型(unsigned char)を文字に変換する。
		sf_assgetDB(no,i,26,DBbuff,2 + 1);
		sprintf(DBbuff,"%c",prEND);	//BOOL型(unsigned char)を文字に変換する。
		sf_assgetDB(no,i,27,DBbuff,2 + 1);
		sf_to_text(denNUM,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,28,DBbuff,3 + 1);
		sf_to_text(hakoNUM,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,29,DBbuff,3 + 1);
		sf_assgetDB(no,i,30,memo,1024 + 1);
		sprintf(DBbuff,"%c",reserve);	//BOOL型(unsigned char)を文字に変換する。
		sf_assgetDB(no,i,31,DBbuff,2 + 1);
		sf_assgetDB(no,i,32,resDATE,10 + 1);
		sprintf(DBbuff,"%c",print);	//BOOL型(unsigned char)を文字に変換する。
		sf_assgetDB(no,i,33,DBbuff,2 + 1);
		sf_to_text(prNUM,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,34,DBbuff,3 + 1);
		sf_assgetDB(no,i,35,daitaiCD,5 + 1);
		sprintf(DBbuff,"%c",daitai);	//BOOL型(unsigned char)を文字に変換する。
		sf_assgetDB(no,i,36,DBbuff,2 + 1);
		sf_assgetDB(no,i,37,FAX,13 + 1);
		sf_assgetDB(no,i,38,hm_kubun,2 + 1);
		sf_to_text(hinsyu,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,39,DBbuff,3 + 1);
		sf_assgetDB(no,i,40,keitaiTEL,13 + 1);
		sf_to_text(hopeTIME,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,41,DBbuff,2 + 1);
		sf_to_text(hopeTIME2,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,42,DBbuff,2 + 1);
		sf_to_text(hopeTIME3,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,43,DBbuff,2 + 1);
		sprintf(DBbuff,"%c",umu);	//BOOL型(unsigned char)を文字に変換する。
		sf_assgetDB(no,i,44,DBbuff,2 + 1);
		sf_to_text(soryo,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,45,DBbuff,3 + 1);
		sf_to_text(hatu_kosuu,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,46,DBbuff,3 + 1);
		sf_to_text(hakodai,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,47,DBbuff,3 + 1);
		sf_assgetDB(no,i,48,chitai,60 + 1);
		sf_assgetDB(no,i,49,mail,50 + 1);
		sf_to_text(tesuu,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,50,DBbuff,3 + 1);
		sf_to_text(tac,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,51,DBbuff,3 + 1);
		sprintf(DBbuff,"%c",reitou);	//BOOL型(unsigned char)を文字に変換する。
		sf_assgetDB(no,i,52,DBbuff,2 + 1);
		sf_assgetDB(no,i,53,YahooID,32 + 1);
		sf_assgetDB(no,i,54,shiwakeCD,13 + 1);
		sprintf(DBbuff,"%c",kariseikyu);	//BOOL型(unsigned char)を文字に変換する。
		sf_assgetDB(no,i,55,DBbuff,2 + 1);
		sf_to_text(cc_kingaku,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,56,DBbuff,3 + 1);
		sf_to_text(st_kingaku,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,57,DBbuff,3 + 1);
		sf_to_text(base_soryo,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,58,DBbuff,3 + 1);
		sprintf(DBbuff,"%c",seikyuEND);	//BOOL型(unsigned char)を文字に変換する。
		sf_assgetDB(no,i,59,DBbuff,2 + 1);
		sf_to_text(den_hakoNUM,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,60,DBbuff,3 + 1);
		sf_to_text(soukin_tesuuryo,DBbuff);	//NUMERIC型(int)を文字に変換する。
		sf_assgetDB(no,i,61,DBbuff,3 + 1);

	}
	// カーソルクローズ 
	EXEC SQL CLOSE otodoke_Menu_CURSOR;

	DBcount[no] = rec_count;

	// 結果チェック
	if (sqlca.sqlcode == 0)
	{
		sprintf(tmp,"FETCH結果チェック:%d - %s",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc);
	//	logmsg(tmp);
	}
	// 切断
	sqlca.sqlcode = 0;
	EXEC SQL DISCONNECT dbConnection;
	return(0);
}


int subformHTML(void)
{
	int i;
	char s[MAX_STR];

	int startline;

	int line;
	setlocale(LC_ALL,"");

//------------------------------------------------------------------------
//下ののハイフンのラインまでの以下の関数はDBと画面の設計を実際のフォームに適用します。
//これらの関数が無い場合は設計情報はDB設計以外は反映されません。

// DBから入出力(画面)ウインドウに書き込みます。
void otodoke_Menu_text_writeHTML(int no, int post, int line,int maxcol, char **db_titles)
{
	int i;
	char s[MAX_TMP];

	printf("Content-type: text/html\n\n");
	printf("<html>\n");
	printf("<head>\n");
	printf("<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">\n"); 
	printf("<title>form Menu_text_writeHTML page</title>\n");
	printf("</head>\n");
	printf("<body>\n");
	printf("<br>\n");
	//送信はGETを使用します。
	printf("<form method=\"get\" accept-charset=\"utf-8\" action=\"/cgi-bin/otodoke.cgi\">\n");
	printf("<select name=\"field0\" size=\"8\" maxlength=\"64\"><br>\n");
	for(i=0;i<DBcount[no];i++)
	{
		printf("<option value=\"%s\"> %s\n",ft[post].splitDBbuff[i][1],ft[post].splitDBbuff[i][1]);
	}
	printf("</select>\n");
	printf("<td><input type=\"submit\" name=\"field\" value=\"%s\"></td>",KEY[1]);
	printf("</form>\n");
}

// FETCHした後にHTMLのテーブルにDBの行列を書き込みます。
int otodoke_Menu_grid_dispHTML(int no, int startline, int maxcol, int grid_ey, int grid_sy)
{
	int i, j;
	char s[MAX_TMP];
	char hs[MAX_TMP];

	if((Fetch_otodoke_Menu(no)) == 0)
	{
		for(i=startline;i<DBcount[no];i++)
		{
			for(j=0;j<maxcol;j++)
			{
				sf_gputDBHTML(no,i,j,startline,s);
			}
		}

		return(0);
	}
	else
	{
		return(-1);
	}
}

	static int xcol = 211;
	static int rows = 73;

//for label
	static int label_length[] = {0};
	static int label_no[] = {0};
	static int label_align[] = {0};
	static char *label_text[1][128] = {""};
	static int label_x[] = {0};
	static int label_y[] = {0};
//for textbox
	static int textbox_length[] = {3,7,24,96,96,96,192,96,200,13,90,5,144,10,15,2,3,2,13,2,10,10,10,209,5,7,2,2,5,5,209,2,10,2,5,5,2,13,2,5,13,2,2,2,2,15,5,15,60,50,15,15,2,32,13,2,15,15,15,2,5,15,0};
	static int textbox_no[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,0};
	static int textbox_align[] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,1,2,2,2,1,1,1,2,2,2,2,2,1,1,2,2,1,2,1,2,2,2,2,1,2,1,1,1,2,1,1,1,2,2,1,1,2,2,2,2,1,1,1,2,1,1,0};
	static int textbox_action[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	static int textbox_skipstep[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0};
	static int textbox_field[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,3,2,3,1,3,5,5,5,1,1,1,3,3,2,2,1,3,5,3,2,1,3,1,1,2,1,1,1,1,3,4,4,4,1,1,4,4,3,1,1,3,4,4,4,3,2,4,0};
	static int textbox_x[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	static int textbox_y[] = {6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,0};


//for grid
	static int cell_length[] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,5,2,3,2,2,2,3,3,3,2,2,2,2,2,3,3,2,2,3,2,3,2,2,2,2,3,2,2,2,2,2,3,3,3,2,2,3,3,2,2,2,2,3,3,3,2,3,3,0};
	static int cell_align[] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,1,2,2,2,2,2,2,2,2,2,2,2,1,1,2,2,2,2,1,2,2,2,2,1,2,1,1,1,2,1,1,1,2,2,1,1,2,2,2,2,1,1,1,2,1,1,0};
	static int cell_action[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	static int grid_field[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,3,2,3,1,3,1,1,1,1,1,1,3,3,2,2,1,3,1,3,2,1,3,1,1,2,1,2,2,2,3,4,4,4,1,1,4,4,3,1,1,3,4,4,4,3,2,4,0};
	static int grid_skipstep[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0};
	char *grid_titles[63][128] = {"Grid_1","Grid_2","Grid_3","Grid_4","Grid_5","Grid_6","Grid_7","Grid_8","Grid_9","Grid_10","Grid_11","Grid_12","Grid_13","Grid_14","Grid_15","Grid_16","Grid_17","Grid_18","Grid_19","Grid_20","Grid_21","Grid_22","Grid_23","Grid_24","Grid_25","Grid_26","Grid_27","Grid_28","Grid_29","Grid_30","Grid_31","Grid_32","Grid_33","Grid_34","Grid_35","Grid_36","Grid_37","Grid_38","Grid_39","Grid_40","Grid_41","Grid_42","Grid_43","Grid_44","Grid_45","Grid_46","Grid_47","Grid_48","Grid_49","Grid_50","Grid_51","Grid_52","Grid_53","Grid_54","Grid_55","Grid_56","Grid_57","Grid_58","Grid_59","Grid_60","Grid_61","Grid_62",""};
	static char *db_titles[63][128] = {"No","yubinNo","todofuken","jusho1","jusho2","shimei1","shimei_f1","shimei2","shimei_f2","TEL","hinmei","yoryo","grade","size","kingaku","jikankibou","takuhai_s","tuchi","denNo","tokui","uketukeDATE","expDATE","hopeDATE","bikou","hassoCD","hatutenCD","hatuEND","prEND","denNUM","hakoNUM","memo","reserve","resDATE","print","prNUM","daitaiCD","daitai","FAX","hm_kubun","hinsyu","keitaiTEL","hopeTIME","hopeTIME2","hopeTIME3","umu","soryo","hatu_kosuu","hakodai","chitai","mail","tesuu","tac","reitou","YahooID","shiwakeCD","kariseikyu","cc_kingaku","st_kingaku","base_soryo","seikyuEND","den_hakoNUM","soukin_tesuuryo",0};
	static int grid_sx = 0;
	static int grid_ex = 206;
	static int grid_sy = 4;
	static int grid_ey = 4;

	static int maxtext;
	static int no = 0;

	char **gt;
	char **lt;

	gt = (char **)&grid_titles;

	xcol = MakeWsubFormHTML(no,xcol,rows,0,2,grid_sx,grid_sy,grid_ex,grid_ey,cell_length,cell_align,cell_action,grid_field,grid_skipstep,gt,62);

	lt = (char **)&label_text;

//	以下の関数は<SELECT>でコンボボックスを作成する場合、一つのCGIで重複して利用出来ませんのでどちらかを削除してください。
	maxtext = MakeTextBoxHTML(no,0,2,xcol,rows,label_no,lt,label_x,label_y,label_length,textbox_no,textbox_x,textbox_y,textbox_length,textbox_align,textbox_action,textbox_field,textbox_skipstep, 62);

//------------------------------------------------------------------------

	for(i=0;i<MAX_POS;i++)
	{
		memset(gridtitles[i],'\0',MAX_LEN);
	}

	sf_startcell(0);

	startline = 0;	//画面初期行

	if(otodoke_Menu_grid_dispHTML(no,startline,maxtext,grid_sy,grid_ey) == -1)	//*splitDBbuff[][]を表示する。
	{
		printf("grid_dispHTML():error\n");
	}

	//DBへのメニュー用フォームの作成
	otodoke_Menu_text_writeHTML(no,0,i,maxtext,*db_titles);
}

int main(void)
{
	subformHTML();
}

