/jibas/smsgateway/library/pegawai.class.php

https://github.com/wildanm/Jibas · PHP · 124 lines · 121 code · 3 blank · 0 comment · 8 complexity · 28591317b61cfb5a8f07ec26b8337dd3 MD5 · raw file

  1. <?php
  2. require_once('../include/config.php');
  3. require_once('../include/db_functions.php');
  4. require_once('../include/common.php');
  5. new Pegawai();
  6. class Pegawai{
  7. public function __construct(){
  8. $op = (isset($_REQUEST['op']))?$_REQUEST['op']:'';
  9. $this->bag = (isset($_REQUEST['bagian']))?$_REQUEST['bagian']:"";
  10. $this->nip = (isset($_REQUEST['nip']))?$_REQUEST['nip']:"";
  11. $this->nama = (isset($_REQUEST['nama']))?$_REQUEST['nama']:"";
  12. $this->filter = "";
  13. switch($op){
  14. case 'pilih':$this->headerPilih();break;
  15. case 'cari':$this->headerCari();break;
  16. }
  17. }
  18. public function headerPilih(){
  19. ob_start();
  20. global $db_name_sdm;
  21. OpenDb();
  22. $sql = "SELECT replid,bagian FROM $db_name_sdm.bagianpegawai ORDER BY urutan ASC";
  23. $res = QueryDb($sql);
  24. $bag = array();
  25. while($row = @mysql_fetch_row($res))
  26. array_push($bag,$row[1]);
  27. ?>
  28. <table border='0'>
  29. <tr>
  30. <td>Bagian : </td>
  31. <td>
  32. <select id='bag' class='InputTxt'>
  33. <?php
  34. foreach($bag as $bagian){
  35. $this->bag = ($this->bag=="")?$bagian:$this->bag;
  36. echo "<option value='$bagian' ";
  37. if ($bagian==$this->bag)
  38. echo "selected";
  39. echo ">$bagian</option>";
  40. }
  41. ?>
  42. </select>
  43. </td>
  44. </tr>
  45. </table>
  46. <?php
  47. $this->filter = " AND bagian='$this->bag'";
  48. $this->showPegawai();
  49. ob_flush();
  50. }
  51. public function headerCari(){
  52. ob_start();
  53. ?>
  54. <table border='0'>
  55. <tr>
  56. <td>NIP:</td>
  57. <td>
  58. <input type='text' class='InputTxt' id='nip' value="<?php echo $this->nip ?>">
  59. </td>
  60. <td>&nbsp;&nbsp;Nama:</td>
  61. <td>
  62. <input type='text' class='InputTxt' id='nama' value="<?php echo $this->nama ?>">
  63. </td>
  64. <td><input type='button' value="Cari" id='btnCari' class="Btn"></td>
  65. </tr>
  66. </table>
  67. <?php
  68. if ($this->nip!="")
  69. $this->filter .= " AND nip LIKE '%$this->nip%'";
  70. if ($this->nama!="")
  71. $this->filter .= " AND nama LIKE '%$this->nama%'";
  72. if ($this->nip!="" || $this->nama!="")
  73. $this->showPegawai();
  74. ob_flush();
  75. }
  76. public function showPegawai(){
  77. global $db_name_sdm;
  78. global $db_name_user;
  79. ob_start();
  80. OpenDb();
  81. $sql = "SELECT nip,nama FROM $db_name_sdm.pegawai WHERE 1 $this->filter";
  82. $res = QueryDb($sql);
  83. $num = @mysql_num_rows($res);
  84. if ($num>0){
  85. $cnt = 1;
  86. ?>
  87. <table cellspacing="0" cellpadding="0" border="1" width="100%" class="tab">
  88. <tr class="Header">
  89. <td>No</td>
  90. <td>NIP</td>
  91. <td>Nama</td>
  92. <td>&nbsp;</td>
  93. </tr>
  94. <?php
  95. while ($row = @mysql_fetch_row($res)){
  96. $sqlpass = "SELECT count(replid) FROM $db_name_user.login WHERE login='$row[0]'";
  97. $respass = QueryDb($sqlpass);
  98. $rowpass = @mysql_fetch_row($respass);
  99. $hp = ($rowpass[0]==0)?'false':'true';
  100. ?>
  101. <tr height="20">
  102. <td align="center"><?php echo $cnt ?></td>
  103. <td style="padding: 2px;"><?php echo $row[0] ?></td>
  104. <td style="padding: 2px;"><?php echo $row[1] ?></td>
  105. <td align="center">
  106. <img class='btnSelectPeg' nip='<?php echo $row[0] ?>' nama='<?php echo $row[1] ?>' hp='<?php echo $hp ?>' style="cursor: pointer;" alt="Pilih" src="../images/ico/down.png">
  107. </td>
  108. </tr>
  109. <?php
  110. $cnt++;
  111. }
  112. ?>
  113. </table>
  114. <?php
  115. } else {
  116. echo "<div align='center' class='ui-state-highlight'>Tidak ditemukan data Pegawai</div>";
  117. }
  118. ob_flush();
  119. }
  120. }
  121. ?>