mscenq1

戻る

###################################### # mscenq1_p.pl==>(パーツ選択テストプログラム) # mscenq1_p.htmに出力する ###################################### use strict; use DBI; use CGI qw/:standard/; use HTML::Template; my(%t,$n,$n1,@loop1,@loop2,@loop3,@loop4,@loop5,@engine_loop); # データベースに連結 $t{dsn} = "DBI:mysql:host=localhost;database=cookbook"; $t{dbh} = DBI->connect($t{dsn}, "cbuser", "cbpass") or die "Cannot connect to server\n"; $t{dbh}->do("SET NAMES utf8"); if(!$t{dbh}){ print "SQL read ERROR!\n"; exit; } # enq1テーブルのourrefを読む $t{enq1_maxid} = $t{dbh}->selectrow_array("select max(id) from enq1"); @{ $t{list} } = $t{dbh}->selectrow_array("select name1id, type1id, maker1id, dwg1id,partsid,NUid,memo from enq1 where id = $t{enq1_maxid}"); $t{template} = HTML::Template->new(filename => 'mscenq1_p.htm'); $t{template}->param(pro => "mscenq1_p.pl"); $t{template}->param(enq1_id => $t{enq1_maxid}); $t{name1id} = $t{list}[0]; # name1id $t{type1id} = $t{list}[1]; # type1id $t{maker1id} = $t{list}[2]; # maker1id $t{dwg1id} = $t{list}[3]; # dwg1id # 主機名の処理 @loop1 = (); $t{NO}=0; if ( $t{name1id} != 0 ) { @{ $t{name1id_list} } = split(/==/,$t{name1id}); for $n ( 0 .. $#{ $t{name1id_list} } ) { $t{name1id1} = $t{name1id_list}[$n]; ($t{id1},$t{name1}) = $t{dbh}->selectrow_array("select id, name from main_name1 where id = $t{name1id1}"); $t{NO}++; my %row = ( enq1_id => $t{enq1_maxid}, NO1 => $t{NO}, id1 => $t{id1}, name1 => $t{name1} ); push(@loop1, \%row); } } $t{template}->param(LOOP1 => \@loop1); $t{template}->param(ENGINE_LOOP => \@engine_loop); # 主機タイプの処理 @loop2 = (); @engine_loop = (); $t{NO}=0; if ( $t{type1id} != 0 ) { @{ $t{type1id_list} } = split(/==/,$t{type1id}); for $n ( 0 .. $#{ $t{type1id_list} } ) { $t{type1id1} = $t{type1id_list}[$n]; ($t{id1},$t{type1}) = $t{dbh}->selectrow_array("select id, name from main_type1 where id = $t{type1id1}"); $t{NO}++; my %row = ( enq1_id => $t{enq1_maxid}, NO1 => $t{NO}, id1 => $t{id1}, type1 => $t{type1} ); push(@loop2, \%row); my %row = ( NO1 => $t{NO}, main_type1id => $t{id1} ); # put this row into the loop by reference push(@engine_loop, \%row); } } $t{template}->param(LOOP2 => \@loop2); $t{template}->param(ENGINE_LOOP => \@engine_loop); # パーツの処理 $t{partsid} = $t{list}[4]; # partsid $t{NUid} = $t{list}[5]; # NUid if ( $t{partsid} ) { @loop5 = (); @{ $t{partsid_list0} } = split(/==/,$t{partsid}); @{ $t{NUid_list0} } = split(/==/,$t{NUid}); for $n (0 .. $#{ $t{partsid_list0} } ) { $t{p_list1} = $t{partsid_list0}[$n]; $t{N_list1} = $t{NUid_list0}[$n]; @{ $t{partsid_list} } = split(/=/,$t{p_list1}); @{ $t{NUid_list} } = split(/=/,$t{N_list1}); $t{NO} = $n + 1; for $n1 ( 0 .. $#{ $t{partsid_list} } ) { $t{partsid1} = $t{partsid_list}[$n1]; $t{NUid1} = $t{NUid_list}[$n1]; @{ $t{parts} } = $t{dbh}->selectrow_array("select name, code from parts1 where id = $t{partsid1}"); $t{NU1} = $t{dbh}->selectrow_array("select parts_Unit from parts_nu where id = $t{NUid1}"); $t{NO2} = $n1 + 1; my %row = ( enq1_id => $t{enq1_maxid}, NO1 => $t{NO}, NO2 => $t{NO2}, parts_id => $t{partsid1}, parts_name => $t{parts}[0], parts_code => $t{parts}[1], NU1 => $t{NU1} ); # put this row into the loop by reference push(@loop5, \%row); } } $t{template}->param(LOOP5 => \@loop5); } # メモデータの処理 $t{memo} = $t{list}[6]; # memo $t{template}->param(memo => $t{memo}); $t{dbh}->disconnect; print $t{template}->output; 1; ------------------------------------------------------------------------------- <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>mscenq1_p</TITLE> <style type="text/css"> body { background: lightcyan; color:black; margin-left:2em;margin-right:2em;} </style> </HEAD> <BODY bgcolor="#FFFFFF"> <center><h2>mscenq1_p</h2></center> <a href="http://localhost/index.html">http://localhost/index.html</a><br> <hr color="#003366"> 目的:船主からのENQ情報をデータベースに入力する。<br> mode:mscenq1_p;table:enq1;Perl:<TMPL_VAR NAME="pro"> <hr color="#003366"> <h3>ENQ_ID==><TMPL_VAR NAME="enq1_id"></h3> <hr color="#003366"> <!-- this is a comment --> <!-- 主機名追加 --> <h3>主機名(main_name1)追加</h3> <br> <form method="POST" action="mscsearch.pl"> <input type="text" size=50 name=word1 value=""> <input type="submit" value="主機名を検索">==>http://localhost/scripts/mscsearch.pl <input type="hidden" name="enq1_id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="table" value="main_name1"> <input type="hidden" name="item" value="name1id"> </form> <!-- 主機名リスト --> <TMPL_LOOP NAME="LOOP1"> <form method="POST" action="mscdelete.pl"> <h3><TMPL_VAR NAME="NO1">==><TMPL_VAR NAME="name1"> <input type="submit" value="削除"> <input type="hidden" name="id1" value="<TMPL_VAR NAME="id1">"> <input type="hidden" name="enq1_id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="item" value="name1id"> </form> </h3> </TMPL_LOOP> <hr color="#003366"> <!-- 主機タイプ追加 --> <h3>主機名(main_type1)追加</h3> <br> <form method="POST" action="mscsearch.pl"> <input type="text" size=50 name=word1 value=""> <input type="submit" value="主機タイプを検索">==>http://localhost/scripts/mscsearch.pl <input type="hidden" name="enq1_id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="table" value="main_type1"> <input type="hidden" name="item" value="type1id"> </form> <!-- 主機タイプリスト --> <TMPL_LOOP NAME="LOOP2"> <form method="POST" action="mscdelete.pl"> <h3>主機<TMPL_VAR NAME="NO1">==><TMPL_VAR NAME="type1"> <input type="submit" value="削除"> <input type="hidden" name="id1" value="<TMPL_VAR NAME="id1">"> <input type="hidden" name="enq1_id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="item" value="type1id"> </form> </h3> </TMPL_LOOP> <hr color="#003366"> <!-- パーツ追加 --> <h3>パーツ追加<br> name,code,unit</h3> <form method="POST" action="mscsearch2.pl"> <select name="SEL1"> <TMPL_LOOP NAME="ENGINE_LOOP"> <option value="<TMPL_VAR NAME="main_type1id">">主機<TMPL_VAR NAME="NO1"> </option> </TMPL_LOOP> </select> <input type="text" size=50 name=word1 value=""> <input type="submit" value="パーツを検索">==>http://localhost/scripts/mscsearch2.pl <input type="hidden" name="enq1_id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="main_type1id" value="<TMPL_VAR NAME="main_type1id">"> </form> <TMPL_LOOP NAME="LOOP5"> <form method="POST" action="mscdelete2.pl"> <h4>主機<TMPL_VAR NAME="NO1">==>パーツ<TMPL_VAR NAME="NO2">,<TMPL_VAR NAME="parts_id">,<TMPL_VAR NAME="parts_name">,<TMPL_VAR NAME="parts_code">,<TMPL_VAR NAME="NU1"> <input type="submit" value="削除"> <input type="hidden" name="enq1_id" value="<TMPL_VAR NAME="enq1_id">"> <input type="hidden" name="id2" value="<TMPL_VAR NAME="parts_id">"> <input type="hidden" name="NO1" value="<TMPL_VAR NAME="NO1">"> </h4> </form> </TMPL_LOOP> <hr color="#003366"> <!-- メモ追加 --> <h3>メモ(memo)==><TMPL_VAR NAME="memo"></h3> <hr color="#003366"> <form action="" method="post"> <input type="submit" value="enq1(From 船主)作成開始へ戻る"><p> <input type="hidden" name="rm" value="modeenq1_start"> </form> </form> </BODY> </HTML>
戻る