选择复数个项目的界面和程序

戻る

mscparts_gd.pl

sub mscparts_gd { my $self = shift; my(%t,@loop,$n,@rec); # Get CGI query object $t{q} = $self->query(); $t{html} = $t{q}->param("tmpl"); $t{html} = $t{html} . '.htm'; $t{template} = $self->load_tmpl("$t{html}") || die "error loading tmpl"; $t{id} = $t{q}->param("id"); $t{GNO} = $t{q}->param("NO"); $t{table} = $t{q}->param("table"); $t{item} = $t{q}->param("item"); $t{name} = $t{q}->param("name"); # パーツテーブルを読む $t{sth} = $self->dbh->prepare("SELECT id, name, code FROM $t{table}"); $t{sth}->execute; while ( @rec = $t{sth}->fetchrow_array ) { $t{NO} = 'ss' . $rec[0]; my %row = ( NO => $t{NO}, id => $rec[0], name => $rec[1], code => $rec[2] ); push(@loop, \%row); } $t{sth}->finish; if ( $t{item} eq 'GR' ) { $t{tmpl0} = 'mscengine_gr'; } else { $t{tmpl0} = 'mscengine_dwg'; } $t{template}->param(LOOP => \@loop); $t{template}->param(id => $t{id}); $t{template}->param(GNO => $t{GNO}); $t{template}->param(table => $t{table}); $t{template}->param(item => $t{item}); $t{template}->param(tmpl0 => $t{tmpl0}); $t{template}->param(name => $t{name}); return $t{template}->output; } 1;

mscparts_gd.htm

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>Partsの<TMPL_VAR NAME="item">選択</TITLE> <style type="text/css"> body { background: lightcyan; color:black; margin-left:2em;margin-right:2em;} </style> </HEAD> <BODY> <center> <h2>Partsの<TMPL_VAR NAME="item">選択</h2></center> mode:modeparts_gd <form action="" method="post"> <input type="submit" value="<TMPL_VAR NAME="item">の追加と修正へ戻る"><p> <input type="hidden" name="tmpl" value="<TMPL_VAR NAME="tmpl0">"> <input type="hidden" name="table" value="main_type1"> <input type="hidden" name="items" value="<TMPL_VAR NAME="item">"> <input type="hidden" name="id" value="<TMPL_VAR NAME="id">"> <input type="hidden" name="rm" value="modeengine_gd_add"> </form> <hr color="#003366"> id=><TMPL_VAR NAME="id"><br> table=><TMPL_VAR NAME="table"><br> <h3><TMPL_VAR NAME="item">=><TMPL_VAR NAME="name"></h3> <table> <tr bgcolor="white"> <th> チェックボックス </th> <th> ID </th> <th> name </th> <th> code </th> </tr> <form action="" method="post"> <TMPL_LOOP NAME="LOOP"> <tr bgcolor=cyan> <td> <INPUT TYPE="checkbox" NAME="<TMPL_VAR NAME="NO">"> </td> <td> <TMPL_VAR NAME="id"> </td> <td> <TMPL_VAR NAME="name"> </td> <td> <TMPL_VAR NAME="code"> </td> </tr> </TMPL_LOOP> </table> <input type="submit" value="確定"><p> <input type="hidden" name="table" value="<TMPL_VAR NAME="table">"> <input type="hidden" name="id" value="<TMPL_VAR NAME="id">"> <input type="hidden" name="GNO" value="<TMPL_VAR NAME="GNO">"> <input type="hidden" name="item" value="<TMPL_VAR NAME="item">"> <input type="hidden" name="tmpl" value="mscparts_gd1"> <input type="hidden" name="rm" value="modeparts_gd1"> </form> </BODY> </HTML>

mscparts_gd1.pl

sub mscparts_gd1 { my $self = shift; my(%t,@loop,$n,@rec); # Get CGI query object $t{q} = $self->query(); $t{html} = $t{q}->param("tmpl"); $t{item} = $t{q}->param("item"); $t{GNO} = $t{q}->param("GNO"); $t{html} = $t{html} . '.htm'; $t{template} = $self->load_tmpl("$t{html}") || die "error loading tmpl"; $t{id} = $t{q}->param("id"); $t{table} = $t{q}->param("table"); # パーツ数を取得 $t{sth} = $self->dbh->prepare("SELECT id FROM $t{table}"); $t{sth}->execute; $t{s} = ''; while ( @rec = $t{sth}->fetchrow_array ) { $t{NO} = 'ss' . $rec[0]; $t{s1} = $t{q}->param($t{NO}); push(@{ $t{slist} },$t{s1}); } $t{sth}->finish; if ( $t{item} eq 'GR' ) { $t{item1} = 'group_id'; } else { $t{item1} = 'dwg_id'; } # GR/DWGを書く for $n ( 0 .. $#{ $t{slist} } ) { $t{id1} = $n + 1; if ( $t{slist}[$n] eq 'on' ) { $t{sql} = 'UPDATE ' . $t{table} . ' set ' . $t{item1} . ' = "'; $t{sql} .= $t{GNO} . '" where id = ' . $t{id1}; $t{DO} = $self->dbh->do($t{sql}); } } if ( $t{item} eq 'GR' ) { $t{tmpl0} = 'mscengine_gr'; } else { $t{tmpl0} = 'mscengine_dwg'; } $t{template}->param(id => $t{id}); $t{template}->param(item => $t{item}); $t{template}->param(GNO => $t{GNO}); $t{template}->param(DO => $t{DO}); $t{template}->param(tmpl0 => $t{tmpl0}); return $t{template}->output; } 1;

mscparts_gd1.htm

<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE><TMPL_VAR NAME="item">選択完了</TITLE> <style type="text/css"> body { background: lightcyan; color:black; margin-left:2em;margin-right:2em;} </style> </HEAD> <BODY> <center> <h2><TMPL_VAR NAME="item">選択完了</h2></center> mode:modeparts_gd1 <form action="" method="post"> <input type="submit" value="<TMPL_VAR NAME="item">の追加と修正へ戻る"><p> <input type="hidden" name="tmpl" value="<TMPL_VAR NAME="tmpl0">"> <input type="hidden" name="table" value="main_type1"> <input type="hidden" name="items" value="<TMPL_VAR NAME="item">"> <input type="hidden" name="id" value="<TMPL_VAR NAME="id">"> <input type="hidden" name="rm" value="modeengine_gd_add"> </form> <hr color="#003366"> id==><TMPL_VAR NAME="id"><br> GNO==><TMPL_VAR NAME="GNO"><br> DO==><TMPL_VAR NAME="DO"><br> </BODY> </HTML>
戻る