File manager - Edit - /var/www/ams.cmtc.ac.th/pages/admin-user-list.php
Back
<h2>ผู้ใช้งานระบบ</h2> <div align="right"><button type="button" class="btn btn-success " id="myBtnAdd"><i class="fa fa-plus" aria-hidden="true"></i> เพิ่มผู้ใช้งาน</button></div> <?php $action=$_POST['action']; //echo "action=$action<br>"; if($_POST['action']=="add"){ //echo "<center><img src=\"images/reload.gif\" width=\"48\" height=\"48\" alt=\"\"/><br>บันทึกข้อมูล</center>"; $ffname=$_POST['ffname']; $ffusername=$_POST['ffusername']; $ffpassword=$_POST['ffpassword']; $ffgroup=$_POST['ffgroup']; $f1=$_POST['f1']; $f2=$_POST['f2']; $f3=$_POST['f3']; $f4=$_POST['f4']; $f5=$_POST['f5']; $f6=$_POST['f6']; echo "$ffname $ffusername $ffpassword $ffgroup $f1 $f2 $f3 $f4 $f5 $f6"; //ตรวจสอบว่าใช้ username ซำ้หรือไม่ $result=num_record("office_users","where username='$ffusername'"); if($result==0){ insert("NULL,'$ffusername','$ffpassword','$ffname','$ffgroup' ","office_users"); insert("NULL,'เพิ่มผู้ใช้งาน : $ffname','$today $time','$_SESSION[name]'","regis_system_log"); //เพิ่มสิทธิการใช้งานระบบ $result=select("office_users","where username='$ffusername'"); $user_id22=$result["user_id"]; echo "id=$user_id22"; if($f1!=""){ insert("NULL,'$user_id22','1'","office_permission"); } if($f2!=""){ insert("NULL,'$user_id22','2'","office_permission"); } if($f3!=""){ insert("NULL,'$user_id22','3'","office_permission"); } if($f4!=""){ insert("NULL,'$user_id22','4'","office_permission"); } if($f5!=""){ insert("NULL,'$user_id22','5'","office_permission"); } if($f6!=""){ insert("NULL,'$user_id22','6'","office_permission"); } ?> <div class="alert alert-success alert-dismissible"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Success</strong> เพิ่มผู้ใช้เรียบร้อยแล้ว. </div> <?php }else{ ?> <div class="alert alert-danger alert-dismissible"> <button type="button" class="close" data-dismiss="alert">×</button> <strong>Warning</strong> ไม่สามารถเพิ่มผู้ใช้ได้เนื่องจากการใช้ชื่อใช้งาน <?=$ffusername?> นี้อยู่ในระบบแล้ว. </div> <?php } //echo "<meta http-equiv=\"refresh\" content=\"0;url=?op=user&module=list\">"; //exit(); } if($_POST['action']=="del"){ global $connect; //echo "<center><img src=\"images/reload.gif\" width=\"48\" height=\"48\" alt=\"\"/><br>บันทึกข้อมูล</center>"; $dname=$_POST['dname']; $duser_id=$_POST['duser_id']; delete("office_users","where user_id='$duser_id'"); //ลบสิทธิการใช้งาน $sql="Select * From office_permission where user_id='$duser_id'"; $db_query=mysqli_query($connect,$sql); $num_rows=mysqli_num_rows($db_query); $a=0; while($a < $num_rows) { $result = mysqli_fetch_array($db_query); $office_permission_id=$result['office_permission_id']; delete("office_permission","where office_permission_id='$office_permission_id'"); $a++; } insert("NULL,'ลบผู้ใช้งาน : $dname','$today $time','$_SESSION[name]'","regis_system_log"); echo "<meta http-equiv=\"refresh\" content=\"0;url=?op=user&module=list\">"; exit(); } ?> <?php global $connect; $sql="Select * From office_users order by user_id ASC"; $db_query=mysqli_query($connect,$sql); $num_rows=mysqli_num_rows($db_query); /* นับ Reccord ที่พบ */ echo "มีจำนวน <b>$num_rows</b> Users"; ?> <table class="table table-hover table-bordered table-sm"> <thead> <tr> <th><center>#</center></th> <th style="text-align: left" width="20%">ชื่อ นามสกุล</th> <th style="text-align: center" width="15%">ชื่อผู้ใช้งาน</th> <th style="text-align: center" width="15%">รหัสใช้งาน</th> <th style="text-align: center" width="10%">กลุ่ม</th> <th style="text-align: center">ตั้งค่า<br> เริ่มต้นระบบ</th> <th style="text-align: center">กำหนดกลุ่มเรียน<br> นักเรียน นักศึกษา</th> <th style="text-align: center">กำหนดแผนกวิชา/<br> ครูที่ปรึกษา</th> <th style="text-align: center">กำหนดปฎิทิน<br> กิจกรรมฯ</th> <th style="text-align: center">กำหนดปฏิทิน<br> วันหยุด</th> <th style="text-align: center">สรุปผลการเข้าร่วม<br> กิจกรรม</th> <th style="text-align: center" width="15%"></th> </tr> </thead> <tbody> <?php $a=0; while($a < $num_rows) { $result = mysqli_fetch_array($db_query); $user_id2=$result['user_id']; $name2=$result['name']; $username2=$result['username']; $password2=$result['password']; $section_group2=$result['section_group']; ?> <tr> <td align="center"><?php echo $a+1;?><a name="d<?=$cost_item_id?>" id="d<?=$cost_item_id?>"></a></td> <td> <?php if($_GET['action']=='edit' and $_GET['id']==$user_id2) { echo "<form id=\"mform1\" name=\"mform1\" method=\"post\" action=\"\" >"; echo "<input name=\"fname2\" type=\"text\" id=\"fname2\" value=\"$name2\" class=\"form-control\" />"; } else { echo " $name2"; } ?></td> <td align="center"> <?php if($_GET['action']=='edit' and $_GET['id']==$user_id2) { echo "<input name=\"fusername2\" type=\"text\" id=\"fusername2\" value=\"$username2\" class=\"form-control\" size=\"2\" />"; } else { echo "$username2"; } ?> </td> <td align="center"> <?php if($_GET['action']=='edit' and $_GET['id']==$user_id2) { echo "<input name=\"fpassword2\" type=\"text\" id=\"fpassword2\" value=\"$password2\" class=\"form-control\" size=\"2\" />"; } else { echo "*******"; } ?> </td> <td align="center"><?=$section_group2?></td> <td align="center"><?php $permission=num_record("office_permission","where user_id='$user_id2' and system_id='1'"); if($_GET['action']=='edit' and $_GET['id']==$user_id2){ if($permission!=0){ echo "<input type=\"checkbox\" name=\"f1\" id=\"f1\" class=\"form-check-input\" value=\"1\" checked>"; }else{ echo "<input type=\"checkbox\" name=\"f1\" id=\"f1\" class=\"form-check-input\" value=\"1\">"; } }else{ if($permission!=0){ echo"<i class=\"fa fa-check\" aria-hidden=\"true\" style=\"color:blue\"></i>"; } } ?></td> <td align="center"><?php $permission=num_record("office_permission","where user_id='$user_id2' and system_id='2'"); if($_GET['action']=='edit' and $_GET['id']==$user_id2){ if($permission!=0){ echo "<input type=\"checkbox\" name=\"f2\" id=\"f2\" class=\"form-check-input\" value=\"2\" checked>"; }else{ echo "<input type=\"checkbox\" name=\"f2\" id=\"f2\" class=\"form-check-input\" value=\"2\">"; } }else{ if($permission!=0){ echo"<i class=\"fa fa-check\" aria-hidden=\"true\" style=\"color:blue\"></i>"; } } ?></td> <td align="center"><?php $permission=num_record("office_permission","where user_id='$user_id2' and system_id='3'"); if($_GET['action']=='edit' and $_GET['id']==$user_id2){ if($permission!=0){ echo "<input type=\"checkbox\" name=\"f3\" id=\"f3\" class=\"form-check-input\" value=\"3\" checked>"; }else{ echo "<input type=\"checkbox\" name=\"f3\" id=\"f3\" class=\"form-check-input\" value=\"3\">"; } }else{ if($permission!=0){ echo"<i class=\"fa fa-check\" aria-hidden=\"true\" style=\"color:blue\"></i>"; } } ?></td> <td align="center"><?php $permission=num_record("office_permission","where user_id='$user_id2' and system_id='4'"); if($_GET['action']=='edit' and $_GET['id']==$user_id2){ if($permission!=0){ echo "<input type=\"checkbox\" name=\"f4\" id=\"f4\" class=\"form-check-input\" value=\"1\" checked>"; }else{ echo "<input type=\"checkbox\" name=\"f4\" id=\"f4\" class=\"form-check-input\" value=\"4\">"; } }else{ if($permission!=0){ echo"<i class=\"fa fa-check\" aria-hidden=\"true\" style=\"color:blue\"></i>"; } } ?></td> <td align="center"><?php $permission=num_record("office_permission","where user_id='$user_id2' and system_id='5'"); if($_GET['action']=='edit' and $_GET['id']==$user_id2){ if($permission!=0){ echo "<input type=\"checkbox\" name=\"f5\" id=\"f5\" class=\"form-check-input\" value=\"5\" checked>"; }else{ echo "<input type=\"checkbox\" name=\"f5\" id=\"f5\" class=\"form-check-input\" value=\"5\">"; } }else{ if($permission!=0){ echo"<i class=\"fa fa-check\" aria-hidden=\"true\" style=\"color:blue\"></i>"; } } ?></td> <td align="center"> <?php $permission=num_record("office_permission","where user_id='$user_id2' and system_id='6'"); if($_GET['action']=='edit' and $_GET['id']==$user_id2){ if($permission!=0){ echo "<input type=\"checkbox\" name=\"f6\" id=\"f6\" class=\"form-check-input\" value=\"6\" checked>"; }else{ echo "<input type=\"checkbox\" name=\"f6\" id=\"f6\" class=\"form-check-input\" value=\"6\">"; } }else{ if($permission!=0){ echo"<i class=\"fa fa-check\" aria-hidden=\"true\" style=\"color:blue\"></i>"; } } ?> </td> <td><center> <?php if($_GET['action']=='edit' and $_GET['id']==$user_id2) { //echo $_POST['action']; if($_POST['action']=='edit'){ echo " <img src=\"images/reload.gif\" width=\"32\" alt=\"\"/> "; $fname2=$_POST['fname2']; $fusername2=$_POST['fusername2']; $fpassword2=$_POST['fpassword2']; $id=$_POST['id']; $f1=$_POST['f1']; $f2=$_POST['f2']; $f3=$_POST['f3']; $f4=$_POST['f4']; $f5=$_POST['f5']; $f6=$_POST['f6']; update("office_users","username='$fusername2',password='$fpassword2',name='$fname2' ","where user_id ='$id' "); delete("office_permission","where user_id='$id'"); if($f1!=""){ insert("NULL,'$id','1'","office_permission"); } if($f2!=""){ insert("NULL,'$id','2'","office_permission"); } if($f3!=""){ insert("NULL,'$id','3'","office_permission"); } if($f4!=""){ insert("NULL,'$id','4'","office_permission"); } if($f5!=""){ insert("NULL,'$id','5'","office_permission"); } if($f6!=""){ insert("NULL,'$id','6'","office_permission"); } echo "<meta http-equiv=\"refresh\" content=\"0;url=?op=user&module=list#d$id\">"; }else{ echo "<button type=\"submit\" class=\"btn btn-sm btn-success\" id=\"btnSave\" ><i class=\"fa fa-save fa-fw\"></i> บันทึก</button>"; } echo "<input name=\"action\" type=\"hidden\" id=\"action\" value=\"edit\" />"; echo "<input name=\"id\" type=\"hidden\" id=\"id\" value=\"$user_id2\" />"; echo "</form>"; }else{ ?> <a href="?op=user&module=list&action=edit&id=<?=$user_id2?>#d<?=$user_id2?>" class="btn btn-sm btn-info" role="button"><i class="fa fa-pencil" aria-hidden="true"></i> แก้ไข</a><?php } ?> <?php echo"<a data-id=\"$user_id2\" class=\"open-AddBookDialog btn btn-danger btn-sm\" data-toggle=\"modal\" data-target=\"#myModalDel$user_id2\" onclick=\"setval($user_id2);\"><i class=\"fa fa-trash\" aria-hidden=\"true\"></i> ลบ</a>"; ?></center> </td> </tr> <!-- The Modal --> <div class="modal fade" id="myModalDel<?=$user_id2?>"> <div class="modal-dialog modal-xl"> <div class="modal-content"> <!-- Modal Header --> <div class="modal-header"> <h5 class="modal-title">ยืนยันการลบผู้ใช้งาน ?</h5> <button type="button" class="close" data-dismiss="modal">×</button> </div> <form action="?op=user&module=list" method="post" > <!-- Modal body --> <div class="modal-body"> <?php echo "[$name2] $username2 "; ?> </div> <!-- Modal footer --> <div class="modal-footer"> <button type="submit" class="btn btn-danger" id="btnDel" ><i class="fa fa-trash" aria-hidden="true"></i> ลบรายการ</button> <button type="button" class="btn btn-secondary" data-dismiss="modal"><i class="fa fa-reply" aria-hidden="true"></i> ยกเลิก</button> <input name="action" type="hidden" id="action" value="del"> <input name="duser_id" type="hidden" id="duser_id" value="<?=$user_id2?>"> <input name="dname" type="hidden" id="dname" value="<?=$name2?>"> </div> </form> </div> </div> </div> <!-- end --> <?php $a++; } ?> </tbody> </table> <!-- Modal --> <div class="modal fade" id="myModalAdd" role="dialog" align="left"> <div class="modal-dialog modal-lg"> <form action="?op=user&module=list" method="post" enctype="multipart/form-data" > <!-- Modal content--> <div class="modal-content" > <div class="modal-header" align="left"> <h4 class="modal-title" align="left">เพิ่มผู้ใช้งาน</h4> </div> <div class="modal-body"> <div class="form-group"> <label for="cost_subject">ชื่อ นามสกุล:</label> <input name="ffname" type="text" required="required" class="form-control" id="ffname" placeholder="ชื่อ นามสกุล"> </div> <div class="form-group"> <label for="ffusername">ชื่อผู้ใช้งาน (User Name):</label> <input name="ffusername" type="text" required="required" class="form-control" id="ffusername" placeholder="ชื่อผู้ใช้งาน"> </div> <div class="form-group"> <label for="ffpassword">รหัสใช้งาน (Password):</label> <input name="ffpassword" type="password" required="required" class="form-control" id="ffpassword" placeholder="รหัสใช้งาน"> </div> <div class="form-group"> <label for="ffgroup">กลุ่ม (Group):</label> <div class="form-check"> <label class="form-check-label"> <input type="radio" class="form-check-input" name="ffgroup" value="admin" required>ผู้ดูแลระบบ (Admin) </label> </div> <div class="form-check-inline"> <label class="form-check-label"> <input type="radio" class="form-check-input" name="ffgroup" value="user">ผู้ใช้งานระบบ (User) </label> </div> </div> <div class="form-group"> <label for="fcost_var">สิทธิการใช้งานระบบ :</label> <div class="form-check"> <label class="form-check-label"> <input type="checkbox" class="form-check-input" name="f1" value="1">ตั้งค่าระบบ </label> </div> <div class="form-check"> <label class="form-check-label"> <input type="checkbox" class="form-check-input" name="f2" value="2"> กำหนดกลุ่มเรียน </label> </div> <div class="form-check"> <label class="form-check-label"> <input type="checkbox" class="form-check-input" name="f3" value="3"> กำหนดแผนกวิชา/ครูที่ปรึกษา </label> </div> <div class="form-check"> <label class="form-check-label"> <input type="checkbox" class="form-check-input" name="f4" value="4"> กำหนดปฏิทินกิจกรรมหน้าเสาธง </label> </div> <div class="form-check"> <label class="form-check-label"> <input type="checkbox" class="form-check-input" name="f5" value="5"> กำหนดปฎิทินวันหยุด </label> </div> <div class="form-check"> <label class="form-check-label"> <input type="checkbox" class="form-check-input" name="f6" value="6"> สรุปผลการร่วมกิจกรรมหน้าเสาธง</label></div> </div> </div> <div class="modal-footer"> <button type="submit" class="btn btn-success" id="btnAdd" ><i class="fa fa-save fa-fw"></i> เพิ่มผู้ใช้งาน</button> <input name="action" type="hidden" id="action" value="add"> <button type="button" class="btn btn-secondary" data-dismiss="modal"><i class="fa fa-reply" aria-hidden="true"></i> ยกเลิก</button> </div> </div> </form> </div> </div> <script> $(document).ready(function(){ $("#myBtnAdd").click(function(){ $("#myModalAdd").modal(); }); }); </script>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.42 |
proxy
|
phpinfo
|
Settings