<?php
for($i=0;$i<$num;$i++)
{
$n=$i+1;
echo "<tr><td align=center id=th3>$n";
$idd='stt_'.$i ;
echo "<input type=text name=kname[$i] value='$kname[$i]' placeholder='单位检索' class='stt' id=\"$idd\" ></input>";
$add='add_'.$i ;
echo "<td><center><input type=text name=acc_name1[$i] value='$acc_name1[$i]' size=30></td>
<td><center><input type=text name=amt1[$i] value='$amt1[$i]' class='add' id=\"$add\" size=10></td>";
$id1='user_'."$i";
echo "<td ><select name=user[$i] id=\"$id1\">
</select>";
echo"</tr>";
}
echo "</table>";
?>
<script type="text/javascript">
$(".sty").change(function() {
var inno = this.value;
var next = this.id.split('_')[1];
$.ajax({
type:'post',
url:"find_user.php?"+ Math.round(Math.random()*100),
data:{"inno":inno},
contentType: "application/x-www-form-urlencoded; charset=utf-8",
success:function(data) {
data = eval('('+data+')');
$("#user_"+next).empty();
for(i=0;i<data.length;i++){
$("<option></option>").val(data[i].empl).text(data[i].empl+'-'+data[i].name+'-'+data[i].dep).appendTo($("#user_"+next));
}
},
error:function() { alert("error"); }
});
});
</script>
//find_user.php
<?php
require_once('/php/public/id.inc');
require_once('/php/public/opendb.inc');
require("/php/public/power.inc");
header("Content-type: text/html;charset=utf-8");
function field_ora($sql) {
global $dbhUTF;
$stmt = $dbhUTF->prepare("$sql");
if ($stmt->execute()) {
return $stmt->fetch();
}
}
$inno=$_POST[inno];
$sql_exx="select depart_no from acc_gl_depart where acc_depart_no='$inno'";
$sql_exp=$dbhUTF->prepare($sql_exx);
$sql_exp->execute();
list($dept_clear)=$sql_exp->fetch();
if($dept_clear=='516000'){
$sql4="select employee_no,name,get_depart(employee_no)
from employee
where depart_no ='$dept_clear' and lead_code='20' ";
$sql4_exe=$dbhUTF->prepare($sql4);
$sql4_exe->execute();
$i=0;
while (list($employee_no,$name,$dept_no)=$sql4_exe->fetch()){
#echo "$employee_no-$name-$dept_no";
$a[$i]=array('empl'=>$employee_no,'name'=>$name,'dep'=>$dept_no);
$i++;
}
}
elseif($dept_clear=='300001' or $dept_clear=='300002' or $dept_clear=='300003' or $dept_clear=='300004'){
$dep_no3=substr($dept_clear,0,2);
$sql4="select employee_no,name(employee_no),get_depart(employee_no)
from psm_double_work
where depart_no like '$dep_no3%'";
$sql4_exe=$dbhUTF->prepare($sql4);
$sql4_exe->execute();
$i=0;
while (list($employee_no,$name,$dept_no)=$sql4_exe->fetch()) {
#echo "$employee_no-$name-$dept_no";
$a[$i]=array('empl'=>$employee_no,'name'=>$name,'dep'=>$dept_no);
$i++;
}
}
ELSE if($dept_clear=='J11040'){
$sql4="select employee_no,name,get_depart(employee_no)
from employee
where depart_no ='$dept_clear' and lead_code='50'";
$sql4_exe=$dbhUTF->prepare($sql4);
$sql4_exe->execute();
$i=0;
while (list($employee_no,$name,$dept_no)=$sql4_exe->fetch()){
#echo "$employee_no-$name-$dept_no";
$a[$i]=array('empl'=>$employee_no,'name'=>$name,'dep'=>$dept_no);
$i++;
}
}
else{
$dep_no1=substr($dept_clear,0,5)."0";
list($sqlcnt)=field_ora("select count(*) from psm_double_work where depart_no='$dep_no1'");
if ($sqlcnt>0)
{
$sql4="select employee_no,name(employee_no),get_depart(employee_no)
from psm_double_work
where depart_no='$dep_no1' order by lead_code desc ";
$sql4_exe=$dbhUTF->prepare($sql4);
$sql4_exe->execute();
$i=0;
while (list($employee_no,$name,$dept_no)=$sql4_exe->fetch()) {
# echo "$employee_no-$name-$dept_no";
$a[$i]=array('empl'=>$employee_no,'name'=>$name,'dep'=>$dept_no);
$i++;
}
}
else
{
$dep_no2=substr($dept_clear,0,3)."000";
list($sqlcnt2)=field_ora("select count(*) from psm_double_work where depart_no='$dep_no2'");
if ($sqlcnt2>0)
{
$sql4="select employee_no,name(employee_no),get_depart(employee_no)
from psm_double_work
where depart_no='$dep_no2'";
$sql4_exe=$dbhUTF->prepare($sql4);
$sql4_exe->execute();
$i=0;
while (list($employee_no,$name,$dept_no)=$sql4_exe->fetch()) {
#echo "$employee_no-$name-$dept_no";
$a[$i]=array('empl'=>$employee_no,'name'=>$name,'dep'=>$dept_no);
$i++;
}
}
else
{
$dep_no3=substr($dept_clear,0,2)."0000";
$sql4="select employee_no,name(employee_no),get_depart(employee_no)
from psm_double_work
where depart_no='$dep_no3'";
$sql4_exe=$dbhUTF->prepare($sql4);
$sql4_exe->execute();
$i=0;
while (list($employee_no,$name,$dept_no)=$sql4_exe->fetch()) {
# echo "$employee_no-$name-$dept_no";
$a[$i]=array('empl'=>$employee_no,'name'=>$name,'dep'=>$dept_no);
$i++;
}
list($employee_no,$name,$dept_no)=$sql4_exe->fetch();
if (!$employee_no) {
$sql5="select employee_no,name(employee_no),get_depart(employee_no)
from employee
where depart_no='$dept_clear'";
$sql5_exe=$dbhUTF->prepare($sql5);
$sql5_exe->execute();
$i=0;
while (list($employee_no,$name,$dept_no)=$sql5_exe->fetch()) {
#echo "$employee_no-$name-$dept_no";
$a[$i]=array('empl'=>$employee_no,'name'=>$name,'dep'=>$dept_no);
$i++;
}
}
}
}
}
echo json_encode($a);
?>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。