CON008_1_1.php
5.91 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
//*****************************************************************************
//*
//* プログラム名:社員情報DB設定処理
//* プログラムID:CON008_1_1
//* 機能 :社員情報をDB設定する
//* 作成者 :
//*
//*****************************************************************************
header("Content-type: text/html; charset=EUC-JP");
//***************************
//* インクルードファイル
//***************************
include("./include/session_start.inc"); //セッション開始
include("./include/SessionChk.inc"); //セッションチェック
include("./include/dbcon.inc"); //DB接続
if ($birth_y != "" && $birth_m != "" && $birth_d){
$strBirthDay = sprintf("%d/%02d/%02d",$birth_y,$birth_m,$birth_d);
}
if ($nyusya_y != "" && $nyusya_m != "" && $nyusya_d){
$strNyusyaDay = sprintf("%d/%02d/%02d",$nyusya_y,$nyusya_m,$nyusya_d);
}
$strMailAdr = $email1."@".$email2;
$strYubinNo = $yubin_no1.$yubin_no2;
$strTelNo = $telno1."-".$telno2."-".$telno3;
$strkeitaiNo = $keitaiNo1."-".$keitaiNo2."-".$keitaiNo3;
$syain_cd=trim($syain_cd);
//$syain_id=trim($syain_id);
$syain_cd=str_replace(" ","",$syain_cd);
//$syain_id=str_replace(" ","",$syain_id);
//$syain_id="";
$sei_kj = addslashes($sei_kj);
$mei_kj = addslashes($mei_kj);
$address2 = addslashes($address2);
$address3 = addslashes($address3);
$address4 = addslashes($address4);
if ($sinki_edit_flg=="sinki") {
//新規登録
$num = 1;
while ($num >= 1){
$strArray = array(0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z);
for ($i = 0; $i < 5; $i++){
$tmp_num = rand(0, 51);
$strTmp = $strTmp . $strArray[$tmp_num];
}
$syain_cd = $strTmp;
$sql = "SELECT * FROM syain_tbl WHERE syain_cd = '$syain_cd'";
$rtn = pg_exec($sql);
if($rtn == false){
echo "SQLの実行に失敗しました。(#1)";
exit;
}
$num = pg_numrows($rtn);
}
//社員コードチェック
//$strSql = "SELECT syain_cd FROM syain_tbl WHERE syain_cd='".$syain_cd."' ";
//$rsResult = pg_exec($pg_con,$strSql);
//if (pg_numrows($rsResult)>=1) { //社員コード登録済み
// echo "<center>既に登録済みの社員コードです<br>";
// echo "<input type =\"button\" value=\" 戻 る \" onClick=\"history.back()\"></a></center><br>";
// exit;
//}
//IDチェック
//$strSql = "SELECT syain_cd FROM syain_tbl WHERE syain_id='".$syain_id."' ";
//$rsResult = pg_exec($pg_con,$strSql);
//管理者IDチェック
//$strSqlkanri = "SELECT su_id FROM super_user_tbl WHERE su_id='".$syain_cd."'";
//$rsResultkanri = pg_exec($strSqlkanri);
//$intSyainRsCnt = pg_numrows($rsResult);
//if (pg_numrows($rsResult)>=1 || pg_numrows($rsResultkanri)>=1) { //社員ID登録済み
// echo "<center>既に登録済みの社員IDです<br>";
// echo "<input type =\"button\" value=\" 戻 る \" onClick=\"history.back()\"></a></center><br>";
// exit;
//}
if ($work_type=="") {
$intWkType=0;
}else{
$intWkType=$work_type;
}
$strSql = "SELECT MAX(disp_rank) as a FROM syain_tbl";
$rsResult = pg_exec($pg_con,$strSql);
$intSyainNextValue = pg_result($rsResult,0,"a") + 1;
$strSql = "INSERT INTO syain_tbl VALUES(";
$strSql = $strSql."'$syain_cd','$syain_id','$syain_pwd','$sei_kj','$mei_kj','$sei_kn','$mei_kn',";
$strSql = $strSql."$intWkType,'$sex','$strBirthDay','$strNyusyaDay','$strMailAdr','$naisen_no','$strYubinNo',";
$strSql = $strSql."'$address1','$address2','$address3','$address4','$strTelNo','$strkeitaiNo',true,$intSyainNextValue)";
//echo $strSql;
$rsResult = pg_exec($pg_con,$strSql);
$strBumonArray=split("/",$stradd);
if ($bumon_num == 1){
$strSql = "INSERT INTO syozoku_tbl VALUES(";
$strSql = $strSql."'$syain_cd','$strBumonArray[0]')";
//echo $strSql;
$rsResult = pg_exec($pg_con,$strSql);
}else{
for ($i = 0 ; $i <= $bumon_num-1 ; $i++) {
$strSql = "INSERT INTO syozoku_tbl VALUES(";
$strSql = $strSql."'$syain_cd','$strBumonArray[$i]')";
//echo $strSql;
$rsResult = pg_exec($pg_con,$strSql);
}
}
//状況テーブルへの追加
//$strSql = "INSERT INTO jyokyo_tbl VALUES(";
//$strSql = $strSql."'$syain_cd',0)";
//$rsResult = pg_exec($pg_con,$strSql);
}elseif ($sinki_edit_flg=="edit") {
//修正
$strSQL = "SELECT password FROM syain_tbl WHERE syain_cd = '".$syain_code."'";
$objRec = pg_exec($pg_con,$strSQL);
$objRecData = pg_fetch_object($objRec, 0);
$password_bk = $objRecData->password;
$strSql = "UPDATE syain_tbl SET ";
$strSql = $strSql."syain_id='$syain_id',password='$syain_pwd',name_kj_sei='$sei_kj',name_kj_mei='$mei_kj',name_kn_sei='$sei_kn',name_kn_mei='$mei_kn',";
$strSql = $strSql."syugyo_type='$work_type',sex='$sex',birthday='$strBirthDay',nyusya_date='$strNyusyaDay',mail_addr='$strMailAdr',extension_no='$naisen_no',yubin_no='$strYubinNo',";
$strSql = $strSql."addr_pref='$address1',addr_city='$address2',addr_banti='$address3',addr_apart='$address4',tel_no='$strTelNo',keitai_no='$strkeitaiNo' ";
$strSql = $strSql."WHERE syain_cd='$syain_code'";
$rsResult = pg_exec($pg_con,$strSql);
//所属部門の設定
$strSql = "DELETE FROM syozoku_tbl WHERE syain_cd='$syain_code'";
$rsResult = pg_exec($pg_con,$strSql);
$strBumonArray=split("/",$stradd);
if ($bumon_num == 1){
$strSql = "INSERT INTO syozoku_tbl VALUES(";
$strSql = $strSql."'$syain_code','$strBumonArray[0]')";
$rsResult = pg_exec($pg_con,$strSql);
}else{
for ($i = 0 ; $i <= $bumon_num-1 ; $i++) {
$strSql = "INSERT INTO syozoku_tbl VALUES(";
$strSql = $strSql."'$syain_code','$strBumonArray[$i]')";
$rsResult = pg_exec($pg_con,$strSql);
}
}
if ($syain_pwd != $password_bk){
$strSQL = "DELETE FROM kojin_data_tbl WHERE seq=10 AND syain_cd='".$syain_code."'";
$objRec = pg_exec($strSQL);
if($objRec==false){
echo("SQL実行に失敗しました(Delete)");
exit;
}
$strSQLIns = "Insert Into kojin_data_tbl (syain_cd,seq,memo)";
$strSQLIns .= " VALUES ('".$syain_code."',10,'1')";
$objRecIns = pg_exec($strSQLIns);
if($objRecIns==false){
echo("SQL実行に失敗しました(INSERT)");
exit;
}
}
}
header("Location: CON008.php");
?>