<?
	session_start();
	
	$userid_pf = $_SESSION['userid'];
	
	 include "../../Connections/connect_mysql.php";
	 
	 if($userid_pf){
		$sqle=" select * from user_tb where userid=" . $userid_pf . "; ";
		$resulte = mysql_query($sqle) or die(mysql_error());
		$recorde = mysql_fetch_array($resulte);
		$usercode_pf = $recorde['usercode'];
		$usernameth_pf = $recorde['usernameth'];
		$userlnameth_pf = $recorde['userlnameth'];
		$usernameen_pf = $recorde['usernameen'];
		$userlnameen_pf = $recorde['userlnameen'];
		$usersex_pf = $recorde['usersex'];
		$userposition_pf = $recorde['userposition'];
		$userdepartment_pf = $recorde['userdepartment'];
		$usercompany_pf = $recorde['usercompany'];
		$userbranch_pf = $recorde['userbranch'];
		$userloginname_pf = $recorde['userloginname'];
		$userpassword_pf = $recorde['userpassword'];
		$userpin_pf = $recorde['userpin'];
		$userpicpath_pf = $recorde['userpicpath'];
	}
	//echo "{$userpicpath_pf}";
	if(($userpicpath_pf=='-') or ($userpicpath_pf=='')){
		$userpicpath_pf = 'user.png';
	}else{
			
	}

	
?>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>User Profile</title>

</head>

<body>

  <div class="col-md-12 col-xs-12">
      <div class="x_panel">
        <div class="x_title">
          <h2>User Profile <small>ข้อมูลผู้ใช้งาน</small></h2>
          <ul class="nav navbar-right panel_toolbox">
          </ul>
          <div class="clearfix"></div>
        </div>
        
        <div class="x_content">
        	<div class="row">
            	<div class="col-md-3">
                	<div class="row"><div class="col-md-12">
                    	<div style="text-align:center;">
                    		<img id="imgpf" src="modules/user/fileupload/<?=$userpicpath_pf?>" alt="" class="img-circle profile_img">
                        </div>
                    </div></div>
                	<div class="row" style=" padding-top:20px;"><div class="col-md-12">
                    	<? if($userpicpath_pf=='user.png'){ //  ?>
                    	<button style="width:100%;" id="addimgpf" type="button" class="btn btn-success" onClick="javascript:uploaduserpic2('<?=$usercode_pf?>','<?=$usernameth_pf?>','<?=$userlnameth_pf?>');"><i class="fa fa-image"></i> เลือกรูปโปรไฟล์</button>
                        <? }else{ ?>
                        <button style="width:100%;" id="delimgpf" type="button" class="btn btn-danger" onClick="javascript:delprofilepic(<?=$userid_pf?>);"><i class="fa fa-image"></i> ลบรูปโปรไฟล์</button>
                        <? } ?>
                    </div></div>
                </div>
                <div class="col-md-9">
                	<div class="row"><div class="col-md-12">
                       
                    	<div class="form-horizontal form-label-left">
                        
                        	<div class="form-group">
                        		<label class="control-label col-md-3 col-sm-3 col-xs-12" >รหัสพนักงาน <span class="required">*</span></label>
                        		<div class="col-md-9 col-sm-9 col-xs-12">
                          			<input id="pf1" type="text" class="form-control" placeholder="รหัสพนักงาน" value="<?=$usercode_pf?>" disabled onblur="chkdlgadduser(this.id);" >
                        		</div>
                      		</div>
                            <div class="form-group">
                        		<label class="control-label col-md-3 col-sm-3 col-xs-12" >ชื่อ (ไทย) <span class="required">*</span></label>
                        		<div class="col-md-9 col-sm-9 col-xs-12">
                          			<input id="pf2" type="text" class="form-control" placeholder="ชื่อ" onblur="chkdlgadduser(this.id);" value="<?=$usernameth_pf?>" >
                        		</div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12" >นามสกุล (ไทย) <span class="required">*</span></label>
                        		<div class="col-md-9 col-sm-9 col-xs-12">
                          			<input id="pf3" type="text" class="form-control" placeholder="นามสกุล" onblur="chkdlgadduser(this.id);" value="<?=$userlnameth_pf?>">
                        		</div>
                      		</div>
                            <div class="form-group">
                        		<label class="control-label col-md-3 col-sm-3 col-xs-12" >ชื่อ (Eng) <span class="required">*</span></label>
                        		<div class="col-md-9 col-sm-9 col-xs-12">
                          			<input id="pf4" type="text" class="form-control" placeholder="Name" onblur="chkdlgadduser(this.id);" value="<?=$usernameen_pf?>">
                        		</div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-3 col-sm-3 col-xs-12" >นามสกุล (Eng) <span class="required">*</span></label>
                        		<div class="col-md-9 col-sm-9 col-xs-12">
                          			<input id="pf5" type="text" class="form-control" placeholder="Last name" onblur="chkdlgadduser(this.id);" value="<?=$userlnameen_pf?>" >
                        		</div>
                      		</div>
                            <div class="form-group">
                             	<label class="control-label col-md-3 col-sm-3 col-xs-12" >เพศ</label>
                           		<div class="col-md-9 col-sm-9 col-xs-12">
                              		<label  class="radio-inline"><input id="pf6" type="radio" <? if($usersex_pf=='M'){ ?>checked="checked" <? } ?> name="optradio" value="M">ชาย</label>
									<label  class="radio-inline"><input id="pf7" type="radio" <? if($usersex_pf=='F'){ ?>checked="checked" <? } ?> name="optradio" value="F">หญิง</label>
                            	</div>
                            </div>
                            <div class="form-group">
                            	<label class="control-label col-md-3 col-sm-3 col-xs-12" >ตำแหน่ง</label>
                                <div class="col-md-9 col-sm-9 col-xs-12">
                                	<select id="pf8" class="form-control">
                            			<option value=""></option>
                                        <?
										   
											$sqls1=" select * from position_tb order by posid; ";
											$results1 = mysql_query($sqls1) or die(mysql_error());
											while($records1=mysql_fetch_array($results1)){
												$posids1 = $records1['posid'];
												$poscodes1 = $records1['poscode'];
												$posnames1 = $records1['posname'];
												
												
										?>
                            			<option value="<?=$posids1?>" <? if($userposition_pf==$posids1) { ?> selected <? } ?>>(<?=$poscodes1?>) <?=$posnames1?></option>
                            			<?
											}//while
										?>
                          			</select>
                                </div>
                            </div>
                            <div class="form-group">
                            	<label class="control-label col-md-3 col-sm-3 col-xs-12" >แผนก/ฝ่าย</label>
                                <div class="col-md-9 col-sm-9 col-xs-12">
                                	<select id="pf9" class="form-control">
                                    	<option value=""></option>
                            			 <?
										   
											$sqls2=" select * from department_tb order by dpmid; ";
											$results2 = mysql_query($sqls2) or die(mysql_error());
											while($records2=mysql_fetch_array($results2)){
												$dpmids2 = $records2['dpmid'];
												$dpmcodes2 = $records2['dpmcode'];
												$dpmnames2 = $records2['dpmname'];
												
												
										?>
                            			<option value="<?=$dpmids2?>" <? if($userdepartment_pf==$dpmids2) { ?> selected <? } ?>>(<?=$dpmcodes2?>) <?=$dpmnames2?></option>
                            			<?
											}//while
										?>
                          			</select>
                                </div>
                            </div>
                            <div class="form-group">
                            	<label class="control-label col-md-3 col-sm-3 col-xs-12" >บริษัท</label>
                                <div class="col-md-9 col-sm-9 col-xs-12">
                                	<select id="pf10" class="form-control">
                            			<option value=""></option>
                            			<?
										   
											$sqls3=" select * from company_tb order by compid; ";
											$results3 = mysql_query($sqls3) or die(mysql_error());
											while($records3=mysql_fetch_array($results3)){
												$compids3 = $records3['compid'];
												$compcodes3 = $records3['compcode'];
												$compnameths3 = $records3['compnameth'];
												
												
										?>
                            			<option value="<?=$compids3?>" <? if($usercompany_pf==$compids3) { ?> selected <? } ?>>(<?=$compcodes3?>) <?=$compnameths3?></option>
                            			<?
											}//while
										?>
                          			</select>
                                </div>
                            </div>
                            <div class="form-group">
                            	<label class="control-label col-md-3 col-sm-3 col-xs-12" >สาขา</label>
                                <div class="col-md-9 col-sm-9 col-xs-12">
                                	<select id="pf11" class="form-control">
                            			<option value=""></option>
                            			 <?
										   
											$sqls4=" select * from branch_tb order by branid; ";
											$results4 = mysql_query($sqls4) or die(mysql_error());
											while($records4=mysql_fetch_array($results4)){
												$branids4 = $records4['branid'];
												$brancodes4 = $records4['brancode'];
												$brannames4 = $records4['branname'];
												
												
										?>
                            			<option value="<?=$branids4?>" <? if($userbranch_pf==$branids4) { ?> selected <? } ?>>(<?=$brancodes4?>) <?=$brannames4?></option>
                            			<?
											}//while
										?>
                          			</select>
                          			</select>
                                </div>
                            </div>
                            <div class="form-group">
                        		<label class="control-label col-md-3 col-sm-3 col-xs-12" >Username <span class="required">*</span></label>
                        		<div class="col-md-9 col-sm-9 col-xs-12">
                          			<input id="pf12" type="text" class="form-control" placeholder="Username" onblur="chkdlgadduser(this.id);" value="<?=$userloginname_pf?>" >
                        		</div>
                      		</div>
                            <div class="form-group">
                        		<label class="control-label col-md-3 col-sm-3 col-xs-12" >Password <span class="required">*</span></label>
                        		<div class="col-md-9 col-sm-9 col-xs-12">
                          			<input id="pf13" type="password" class="form-control" placeholder="Password" onblur="chkdlgadduser(this.id);" value="<?=$userpassword_pf?>">
                        		</div>
                      		</div>
                            <div class="row"><div class="col-md-12" style="text-align:right;">
                    			<button  type="button" class="btn btn-success" onClick="javascript:saveeditprofile(<?=$userid_pf?>,'pf',13);"><i class="fa fa-save"></i> บันทึกการเปลี่ยนแปลง</button>
                    		</div></div>
                            
                        </div>
                        
                    </div></div>
                </div>
            </div>
        </div>
      </div>
  </div>

</body>
</html>
<?
	mysql_close($c);
?>