function ptg8_view($q,$col,$q1,$col1,$q2,$col2,$q3,$col3,$q4,$col4,$sortby,$sort,$name,$page) {
  global $db,$db1,$ar;
  
  $sql = "select * from ptg_8 where id>0 ";

  if($name!='') {
    $sql .= " and `nama` like '%".$name."%' ";
  }

  if($col!='') {
    $sql .= " and `".$col."`='".$q."' ";
  }
  
  if($col1!='') {
    $sql .= " and `".$col1."`='".$q1."' ";
  }

  if($col2!='') {
    $sql .= " and `".$col2."`='".$q2."' ";
  }

  if($col3!='') {
    $sql .= " and `".$col3."`='".$q3."' ";
  }      

  if($col4!='') {
    $sql .= " and `".$col4."`='".$q4."' ";
  }      

  if($lcol!='') {
    $sql .= " and `".$lcol."` like '".$lq."%' ";
  }      

  if($ncol!='') {
    $sql .= " and `".$ncol."` like '%".$nq."%' ";
  }      
  
  if($lc!='') {
    $sql .= " and `".$lc."` like '%".$nq."%' ";
  }      
  $sql2=$sql;
  if($lc!='') {
    $sql .= " and `".$lc."`<='".$lv."' ";
    $sql2 .= " and `".$lc."`='".$lv."' ";
  }      

  $limit=12;
  $start=($page-1)*$limit;
  $sql .= " order by ".$sortby." $sort limit $start, $limit";
  //$sql .= " order by ".$sortby." desc limit ".$limit;
  $res = mysqli_query($db, $sql);
  $res2 = mysqli_query($db, $sql2);
  $total_records=mysqli_num_rows($res2);
  $total_pages=ceil($total_records/$limit);
  
  $page_url = "op=ptg8&op2=view&q=".$q."&col=".$col."&q1=".$q1."&col1=".$col1."&q2=".$q2."&col2=".$col2."&q3=".$q3."&col4=".$col4."&name=".$name."&sort=".$sort."&sortby=".$sortby;
      ?>
  <h3 class="fw-900">Pendaftar Petugas Haji 2027</h3>
  <div class="row">
    <div class="col-12 text-center">
      <?=$page."/".$total_pages;?>
    </div>
  </div>
  <div class="row">

      <?php

      //echo $sql;
      while($rw = mysqli_fetch_assoc($res)) {  
        if($rw['mcu_upload']>0) {
          $mmc='<a href="?op=p8docmcu&op2=list&col=petugas&q='.$rw['id'].'" target="_blank" class="btn btn-xs btn-info">'.$rw['nama'].'</a>';
        } else {
          $mmc=$rw['nama'];
        }
      ?>      
        <div class="col-lg-1 col-sm-3 col-xs-6">
          <a href="#">
            <div class="centered-image cropped" style="background-image: url(https://api-petugas.haji.go.id/ptgsapi/petugashaji/files/img/<?=$rw['photo_filename'];?>);">
              <img src="https://api-petugas.haji.go.id/ptgsapi/petugashaji/files/img/<?=$rw['photo_filename'];?>" width="100%" class="img img-responsive" alt="<?=$rw['nama'];?>">
            </div>
          </a>
          <div class="small">
            <p><?=$mmc;?>, <?=substr($rw['jenis_kelamin'],4);?>, <?=hitung_usia($rw['tgl_lahir']);?>th, <?=substr($rw['pekerjaan'],4);?>,
            <?php if($rw['pernikahan']!='') { echo substr($rw['pernikahan'],4).", ";} ?>
            <?php if($rw['instansi']!='') { echo $rw['instansi'].", ";} ?>
            <?php if($rw['jabatan']!='') { echo $rw['jabatan'].", ";} ?>
            <?php if($rw['instansi_swasta']!='') { echo $rw['instansi_swasta'].", ";} ?>
            <br><a href="?op=ptg8&op2=list&col1=mcu_upload&q1=<?=$rw['mcu_upload'];?>&col=status&q=stp-3.4" class="btn btn-xs btn-success"><?=$rw['mcu_upload'];?></a> | 
<a href="?op=p8doc&op2=list&col=petugas&q=<?=$rw['id'];?>" target="_blank" class="btn btn-xs btn-warning">doc</a><br><?=$rw['id'];?>, Pl: <?=$rw['is_pl'];?>

            </p>
          </div>
        </div>
      <?php
      }
      ?>        
    </div>
    <?php 
      echo paginate($limit, $page, $total_records, $total_pages, $page_url);
    ?>
  <hr><?=$sql;?>; total: <?=$total_records;?> items<br>
  <?php   
}