Path : /var/www/html/main/ap/job-description/
File Upload :
Current File : /var/www/html/main/ap/job-description/index.php

<?php
/*!
 * Copyright Anucha Puangpaka
 * Contacts anucha.ppk@icloud.com 062-479-9836
 */

$ap_project = "job-description";

if($_GET['nu']==""){
  include('../../head.php');
  if(!empty($_GET['id'])){
    echo "<meta http-equiv='refresh' content='0;URL=$ap_site$ap_folder"."ap/job-description/?nu=info&id=$_GET[id]&code=$_GET[code]'>";
  }
  ?>
  <div class="container theme-showcase body-main-row-body" role="main">
    <div class="breadcrumbx">
    <?php 
    if(empty($_GET['code']) || $_GET['code']=="IndDev"){ 
      echo "<p class=\"h3\"align=\"center\">ฐานข้อมูล การพัฒนาบุคลากร</p>";
    }else{
      echo "<p class=\"h3\"align=\"center\">ฐานข้อมูล การบริการวิชาการ</p>";
    }
    ?> 
    <h5 align="center"><?php echo $title; ?></h5>

    <div class="row">
      <div class="col-lg-6 col-md-6 col-sm-6">
        <a class="btn btn-primary" href="<?php echo $ap_site.$ap_folder; ?>ap/job-description/print.php?nu=&code=<?php echo $_GET['code']; ?>&q=<?php echo $_GET['q']; ?>" target="_blank">พิมพ์</a>
      </div>
      <div class="col-lg-6 col-md-6 col-sm-6 text-right">
        <form class="form-inline text-right" action="ap/job-description/" method="GET">
          <input type="hidden" name="nu" value="">
          <input type="hidden" name="code" value="<?php echo $_GET['code']; ?>">
          <div class="form-group">
            ระบุคำค้น <input type="text" name="q" value="<?php if($_GET['q']==''){  }else{ echo $_GET['q']; } ?>" placeholder="ต.ย. 2019-03-20" class="form-control" autofocus>
          </div>
          <button type="submit" class="btn btn-default">ค้นหา</button>
        </form>
      </div>
    </div>
    <div class="row">
      <div class="col-lg-12 col-md-12 col-sm-12"><hr></div>
    </div>
    <div class="row">
      <div class="col-lg-12 col-md-12 col-sm-12">
        <div class="table-responsive">
          <table class="table table-striped">
            <thead>
              <tr>
                <th width="70">ลำดับ</th>
                <th width="150">วันที่</th>
                <th>เรื่อง</th>
                <th>สถานที่</th>
                <th>จังหวัด</th>
              </tr>
            </thead>
            <tbody>
              <?php
              if(empty($_GET['q'])){
                $_GET['q'] = date('Y');
              }
              $xq = explode('/', $_GET['q']);
              $cxq = count($xq);
              if($cxq==1){
                $sql = "select * from ap_users_job_description where code='$_GET[code]' and (date_time like '$_GET[q]%') or (listname like '%$_GET[q]%') or (title like '%$_GET[q]%') or (province like '%$_GET[q]%') or (location like '%$_GET[q]%') order by date_time asc";
              }else{
                $sql = "select * from ap_users_job_description where code='$_GET[code]' and (date_time > '$xq[0]%' and date_time < '$xq[1]%') order by date_time asc";
              }
              $query = mysqli_query($conn,$sql);
              $i = 0;
              while($rows = mysqli_fetch_array($query)){
              $i++;
                $sql2 = "select * from ap_users where user='$rows[createBy]'";
                $query2 = mysqli_query($conn,$sql2);
                $rows2 = mysqli_fetch_array($query2);
                ?>
                <tr>
                  <td><?php echo $i;?>.</td>
                  <td><?php echo $rows['dateTime'];?></td>
                  <?php if(empty($rows['description'])){ ?>
                  <td><?php echo $rows['title'];?></td>
                  <?php }else{ ?>
                  <td><a href="<?php echo $ap_site.$ap_folder; ?>ap/job-description/?nu=info&id=<?php echo $rows['id'] ?>" target="_blank"><?php echo $rows['title'];?></a></td>
                  <?php } ?>
                  <td><?php echo $rows['location'];?></td>
                  <td><?php echo $rows['province'];?></td>
                </tr>
              <?php
              }

              if(!empty($_GET['api'])){
                $url = "https://arit.kpru.ac.th/ap/api/?nu=api-3d-fd-D1&type=5&citizen_id=3620401045039";
                $ch = curl_init($url);
                curl_setopt($ch, CURLOPT_TIMEOUT, 5);
                curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                $data = curl_exec($ch);
                curl_close($ch);
                $json = json_decode($data, true);
                $json_total = count($json);
                for($i=0;$i<$json_total;$i++){
                ?>
                <tr>
                  <td><?php echo $i; ?></td>
                  <td><?php echo $json[$i]['start_date']; ?></td>
                  <td><?php echo $json[$i]['subject_remark']; ?></td>
                  <td><?php echo $json[$i]['location1']; ?></td>
                  <td><?php echo $json[$i]['province']; ?></td>
                </tr>
                <?php
                }
              }
              ?>
            </tbody>
          </table>
        </div>
        <?php 
        $_GET['text'] = $rows['title'];  
        echo social(); 
        ?>
      </div>
    </div>
    
    </div>
    <p></p>
  </div><!-- /.container -->
  <?php
  include ('../../footText.php');
  include ('../../foot.php');
}

if($_GET['nu']=="info"){
  include('../../head.php');
  ?>
  <div class="container theme-showcase body-main-row-body" role="main">
    <div class="breadcrumbx">
    <?php
    $sql = "select * from ap_users_job_description where id='$_GET[id]'";
    $query = mysqli_query($conn,$sql);
    $rows = mysqli_fetch_array($query);

    $sql2 = "select * from ap_users where user='$rows[createBy]'";
    $query2 = mysqli_query($conn,$sql2);
    $rows2 = mysqli_fetch_array($query2);
    
    /*mkdir("../../contents/edms2/thumbs/", 0777, true);
    if(!file_exists("../../contents/edms2/thumbs/thumb_m_$rows[files]")){
      resize(300, "../../contents/edms2/thumbs/thumb_m_$rows[files]","../../contents/edms2/$rows[files]");
    }*/
    ?>

    <h3 align="center"><?php echo $rows['title']; ?></h3>
    <!-- <p align="center"><b><?php echo $rows['title']; ?></b></p> -->
    <p align="center">วันที่ <?php echo $rows['dateTime']; ?> ณ <?php echo $rows['location']; ?></p>
    <!-- <div class="input-group">
      <label for="">กรุณาระบุคำค้น</label>
      <input type="text" name="q" id="q" class="form-control" placeholder="กรุณาระบุคำค้น" onkeyup="APSearch()"/>
    </div> -->
    <hr>
    <?php 
    if(!empty($rows['files'])){
    ?>
      <center><img src="<?php echo "$ap_site$ap_folder";?>contents/edms2/<?php echo $rows['files']; ?>" width="70%" alt="<?php echo $rows['title']; ?>" title="<?php echo $rows['title']; ?>"></center><p></p>
    <?php
    } 
    ?>
    <!-- <p align="right"><b><?php echo $rows2['fullname']; ?></b></p> -->
    <p class="btn btn-info"><b>สรุปเนื้อหา</b></p>
    <p><?php echo $rows['description'] ?></p>
    <p class="btn btn-primary"><b>คาดว่าจะนำไปใช้ประโยชน์</b></p>
    <p><?php echo $rows['description2'] ?></p>
    <p class="btn btn-success"><b>ผู้เข้าร่วม</b></p>
    <p><?php echo $rows['listname'] ?></p>
    <div class="row">
      <div class="col-lg-12 col-md-12 col-sm-12"><?php $_GET['text'] = $rows['title'];  echo social(); ?></div>
    </div>
    <p></p>
    <?php
    if($_GET['pdf']==1){
      require_once('../../mpdf/mpdf.php');
      $header = "
      <table width=\"100%\" style=\"border-bottom: 1px solid #000000; color: #000088;\">
      <tr>
        <td width=\"50\"><img src=\"$logo\" style=\"width: 50px\" alt=\"\"></td>
        <td><font class=\"style1\">$title</font><br><font class=\"style4\">$title_en</font></span></td>
      </tr>
      </table>";
      $today = date('Y-m-d H:i:s');
      $footer = "
      <table width=\"100%\" style=\"border-bottom: 0px solid #000000; color: #000088;\">
      <tr>
        <td></td>
        <td align=\"right\"><font class=\"style4\">
        <p>$ap_page {PAGENO}</p>
        <p>$title<br></p>
        <p>$ap_expire : ".date('Y-m-d H:i:s',strtotime("$today +1 month"))."</p>
        </font></td>
      </tr>
      </table>";/*<img src='https://arit.kpru.ac.th/ap/qrcode/qrcode.php?data=$ap_site$ap_folder"."ap/job-description/?nu=&id=$_GET[id]&size=114x114&logo=$logo' border='0' />*/

      $html = "
      <p align=\"center\"><b>รายงานการปฏิบัติงาน</b>
      <br><b>******************************</b></p>
      <p><b>$ap_title</b> : $rows[title]</p>
      <p><b>สรุปเนื้อหาการปฏิบัติงาน<b> :
      $rows[description]</p>
      <p><b>คาดว่าจะนำไปใช้ประโยชน์<b> :
      $rows[description2]</p>
      <p>$ap_report : $rows2[fullname]<br>
      $ap_date : ".$rows['date_time']."<br>
      <a href=\"$ap_site$ap_folder"."ap/job-description/?nu=&id=$_GET[id]\">$ap_site$ap_folder"."ap/job-description/?nu=&id=$_GET[id]</a>";

      $pdf = new mPDF('th', 'A4', '0', '', 20, 15, 30, 35);
      $pdf->mirrorMargins = 1;
      $pdf->SetDisplayMode('fullpage');
      $stylesheet = file_get_contents('../../theme.css');
      $pdf->WriteHTML($stylesheet,1);
      $pdf->SetHTMLHeader($header);
      $pdf->SetHTMLHeader($header,'E');
      $pdf->SetHTMLFooter($footer);
      $pdf->SetHTMLFooter($footer,'E');
      $pdf->SetWatermarkText("$ap_watermark");
      $pdf->watermark_font = 'DejaVuSansCondensed';
      $pdf->showWatermarkText = true;
      $pdf->SetTitle("$rows[title]");
      $pdf->SetAuthor("$title");
      $pdf->SetCreator("Anucha Puangpaka");
      $pdf->SetSubject("$rows[title]");
      $pdf->SetKeywords("$keywords");
      $pdf->WriteHTML($html, 2);
      // $pdf->Output();
      $pdf->Output("../../contents/edms2/$_GET[id].pdf");
      echo "<meta http-equiv='refresh' content='0;URL=$ap_site$ap_folder"."contents/edms2/$_GET[id].pdf'>";
    }

    $sql = "select * from ap_edms2 where catalogCode='$_GET[id]' order by id asc";
    $query = mysqli_query($conn,$sql);
    $num_rows = mysqli_num_rows($query);
    if($num_rows>0){
    ?>
    <hr>
    <table class="table table-striped" id="APTabel">
    <thead>
    <tr>
      <th width="70"><?php echo $ap_num; ?></th>
      <th><?php echo $ap_date; ?></th>
      <th><?php echo $ap_document; ?></th>
      <th width="100"><?php echo $ap_filesize; ?></th>
      <th width="100"><?php echo $ap_stat; ?></th>
    </tr>
    </thead>
    <tbody>
    <?php
    $i = 0;
    while($rows = mysqli_fetch_array($query)){
      $i++;
      $fullPath = "c:/inetpub/wwwroot/$ap_folder"."contents/edms2/".$rows['files'];
      if (is_file($fullPath)) {
        $information = pathinfo($fullPath);
        $type = $information['extension'];
      }
      $size = filesize($fullPath);
      if ($size >= 1073741824) {
        $size = round($size / 1073741824, 2) . " GB";
      } elseif ($size >= 1048576) {
        $size = round($size / 1048576, 2) . " MB";
      } elseif ($size >= 1024) {
        $size = round($size / 1024, 2) . " KB";
      }
      ?>
      <tr>
        <td><?php echo $i;?></td>
        <td width="100"><?php echo dateThai2($rows['date_time']);?></td>
        <td><a href="<?php echo $ap_site.$ap_folder; ?>ap/job-description/?nu=downloads&id=<?php echo $rows['id'] ?>&type=<?php echo $type; ?>" target="_blank"><?php echo $rows['name'];?></td>
        <td><?php echo $size;?></td>
        <td><?php echo number_format($rows['counters']) ?></td>
      </tr>
    <?php
    }
    ?>
    </tbody>
    </table>
    <?php
    }

     /* ?><div class="row">
      <div class="col-lg-8 col-md-8 col-sm-12">
        <p><img src='https://arit.kpru.ac.th/ap/qrcode/qrcode.php?data=<?php echo htmlspecialchars("$ap_site$ap_folder$_SERVER[REQUEST_URI]"); ?>&size=114x114&logo=<?php echo $logo;?>' border='0' alt="QRCODE" /></p>
        <p><a href="<?php echo "$ap_site$ap_folder$_SERVER[REQUEST_URI]"; ?>"><?php echo $ap_site.$ap_folder.$_SERVER['REQUEST_URI']; ?></a></p>
      </div>
      <div class="col-lg-4 col-md-4 col-sm-12">
        <p align="right"><a href="javascript:open.Window();" onClick="MM_openBrWindow('https://www.facebook.com/sharer/sharer.php?u=<?php echo "$ap_site$ap_folder$_SERVER[REQUEST_URI]";?>','facebook','scrollbars=yes,resizable=yes,width=560,height=600')">
          <img src="contents/images/facebook.png" width="45px" alt="Facebook">
        </a>
        <a href="javascript:open.Window();" onClick="MM_openBrWindow('https://twitter.com/share?url=<?php echo "$ap_site$ap_folder$_SERVER[REQUEST_URI]";?>','twitter','scrollbars=yes,resizable=yes,width=560,height=600')">
          <img src="contents/images/twitter.png" width="45px" alt="Twitter">
        </a>
        <!-- <a href="https://plus.google.com/share?url=<?php echo "$ap_site$ap_folder$_SERVER[REQUEST_URI]"?>" target="google_window">
          <img src="contents/images/google-plus.png" width="45px" alt="Google Plus">
        </a> -->
        <a href="javascript:open.Window();" onClick="MM_openBrWindow('https://lineit.line.me/share/ui?url=<?php echo "$ap_site$ap_folder$_SERVER[REQUEST_URI]";?>','LINE','scrollbars=yes,resizable=yes,width=560,height=600')">
          <img src="contents/images/line.png" width="45px" alt="LINE">
        </a></p>
      </div>
    </div><?php */ ?>

    <script>
    function APSearch() {
      var input, filter, table, tr, td, i;
      input = document.getElementById("q");
      filter = input.value.toUpperCase();
      table = document.getElementById("APTabel");
      tr = table.getElementsByTagName("tr");
      for (i = 0; i < tr.length; i++) {
        td = tr[i].getElementsByTagName("td")[2];
        if (td) {
          if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
            tr[i].style.display = "";
          } else {
            tr[i].style.display = "none";
          }
        }
      }
    }
    </script>

    <p><a href="<?php echo $ap_site.$_SERVER['REQUEST_URI'];?>&pdf=1"  target="_blank" title="<?php echo $rows['title']?>"><img src="<?php echo $ap_site; ?>/contents/images/pdf.png" width="50" height="50"></a></p>
    <meta name="citation_pdf_url" content="<?php echo $ap_site.$_SERVER['REQUEST_URI'];?>&pdf=1">
    </div>
    <p></p>
  </div><!-- /.container -->
  <?php
  include ('../../footText.php');
  include ('../../foot.php');
}

if($_GET['nu']=="downloads"){
  include('../../config.php');
  $sql = "select * from ap_edms2 where id='$_GET[id]'";
  $query = mysqli_query($conn,$sql);
  $rows = mysqli_fetch_array($query);
  $counter = $rows['counters']+1;
  mysqli_query($conn, "update ap_edms2 set counters='$counter' where id='$rows[id]'");

  header("Cache-Control: public");
  header('Content-Description: '.$rows['name']);
  if($_GET['type']=="pdf" || $_GET['type']=="PDF"){
    /*header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='."$_GET[apf]");*/
    header('Content-type: application/pdf');
    header('Pragma: no-cache');
    header('Expires: 0');
    header("Content-Transfer-Encoding: binary");
    readfile("../../contents/edms2/$rows[files]");
  }elseif($_GET['type']=="jpg" || $_GET['type']=="JPG" || $_GET['type']=="jpeg" || $_GET['type']=="JPEG"){
    /*header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='."$_GET[apf]");*/
    header('Content-type: image/jpeg');
    header('Pragma: no-cache');
    header('Expires: 0');
    header("Content-Transfer-Encoding: binary");
    readfile("../../contents/edms2/$rows[files]");
  }elseif($_GET['type']=="png" || $_GET['type']=="PNG"){
    /*header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='."$_GET[apf]");*/
    header('Content-type: image/png');
    header('Pragma: no-cache');
    header('Expires: 0');
    header("Content-Transfer-Encoding: binary");
    readfile("../../contents/edms2/$rows[files]");
  }elseif($_GET['type']=="gif" || $_GET['type']=="GIF"){
    /*header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='."$_GET[apf]");*/
    header('Content-type: image/gif');
    header('Pragma: no-cache');
    header('Expires: 0');
    header("Content-Transfer-Encoding: binary");
    readfile("../../contents/edms2/$rows[files]");
  }else{
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='."$rows[name]");
    header('Pragma: no-cache');
    header('Expires: 0');
    header("Content-Transfer-Encoding: binary");
    readfile("../../contents/edms2/$rows[files]");
  }

  include('../../logs.php');

  mysqli_close($conn);
}
?>