function ptg7_list($q,$col,$q1,$col1,$q2,$col2,$q3,$col3,$q4,$col4,$lcol,$lq,$ncol,$nq,$lc,$lv) {
  global $db,$db1,$ar;
  ?>
  <h3 class="fw-900">Petugas Haji 2026</h3>
  <table class="table table-bordered table-hover" id="dataTable_1d" width="100%" cellspacing="0">
    <thead>
      <tr class="small">
        <th>#</th>
        <th>#</th>
        <th>nama</th>
        <th>nik</th>
        <th>pkj</th>
        <th>usia</th>
        <th>lp</th>
        <th>inst</th>
        <th>jp</th>
        <th>jt</th>
        <th>ins</th>
        <th>kanwil</th>
        <th>kokab</th>
        <th>jabatan</th>
        <th>study</th>
        <th>minat</th>
        <th>kerja</th>
        <th>status</th>
        <th>n_admin</th>
        <th>cat</th>
        <th>daftar</th>
        <th>dc</th>
      </tr>
    </thead>
    <tbody>
    <?php
      $dt=[];
      $sql = "select * from ptg_7 where id>0 ";

      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."' ";
      }      
      //$sql .= " order by sisa_waktu_ujian desc,cat_nilai desc";
      $res = mysqli_query($db, $sql);
      $res2 = mysqli_query($db, $sql2);
      //echo $sql;
      $a=0;
      while($rw = mysqli_fetch_assoc($res)) {  
        if($rw['doc_upload']>0) {
          $mdc='<a href="?op=ptg7_doc&op2=list&col=petugas&q='.$rw['id'].'" target="_blank">'.$rw['daftar'].'</a>';
        } else {
          $mdc=$rw['daftar'];
        }
        $dt[$a]=$rw;
      ?>      
      <tr class="small">
        <td><?=$rw['id'];?></td>          
        <td><?=$mdc;?></td>          
        <td><?=$rw['nama'];?></td>          
        <td><?=$rw['nik'];?></td>          
        <td><?=substr($rw['pekerjaan'],4);?></td>          
        <td><?=hitung_usia($rw['tgl_lahir']);?></td>          
        <td><a href="?op=ptg7&op2=list&col=jenis_kelamin&q=<?=$rw['jenis_kelamin'];?>&col1=status&q1=<?=$rw['status'];?>"><?=substr($rw['jenis_kelamin'],4);?></a></td>
        <td><?=$rw['instansi_swasta'];?></td>          
        <td><?=$rw['jenis_petugas'];?></td>          
        <td><?=$rw['jenis_tugas'];?></td>          
        <td><a href="?op=ptg7&op2=list&col=instansi&q=<?=$rw['instansi'];?>&col1=status&q1=<?=$rw['status'];?>"><?=$rw['instansi'];?></a></td>          
        <td><a href="?op=ptg7&op2=list&col=is_kes&q=<?=$rw['is_kes'];?>&col2=provinsi&q2=<?=$rw['provinsi'];?>&col1=status&q1=<?=$rw['status'];?>"><?=$rw['provinsi'];?></a></td>          
        <td><?=$rw['kota'];?></td>          
        <td><?=$rw['jabatan'];?></td>          
        <td><?=$rw['last_study'];?></td>          
        <td><a href="?op=ptg7&op2=list&col=peminatan&q=<?=$rw['peminatan'];?>"><?=$rw['peminatan'];?></a></td>
        <td><?=$rw['tempat_kerja'];?></td>
        <td><a href="?op=ptg7&op2=list&col=status&q=<?=$rw['status'];?>"><?=$rw['status'];?></a></td>
        <td class="text-right"><?=$rw['n_admin'];?></td>          
        <td class="text-right"><?=$rw['n_test'];?></td>          
        <td><?=$rw['tgl_daftar'];?></td>          
        <td><a href="?op=ptg7&op2=list&col1=doc_upload&q1=<?=$rw['doc_upload'];?>&col=status&q=stp-3.4"><?=$rw['doc_upload'];?></a></td>
      </tr>
      <?php
        $a++;
      }
      ?>        
    </tbody>
  </table><?=$sql;?><br>
  <?php
$bylp=$bypek=$bystudy=$byprov=[];
foreach ($dt as $i) {
  $key = $i['provinsi'];     
    if (!isset($byprov[$key])) {
      $byprov[$key] = 0;
    }    
  $byprov[$key]++;
}
foreach ($dt as $i) {
  $key = $i['last_study'];     
    if (!isset($bystudy[$key])) {
      $bystudy[$key] = 0;
    }    
  $bystudy[$key]++;
}

foreach ($dt as $i) {
  $key = $i['jenis_kelamin'];     
    if (!isset($bylp[$key])) {
      $bylp[$key] = 0;
    }    
  $bylp[$key]++;
}
foreach ($dt as $i) {
  $key = $i['pekerjaan'];     
    if (!isset($bypek[$key])) {
      $bypek[$key] = 0;
    }    
  $bypek[$key]++;
}

  ?>
  <div class="row">
    <div class="col-2">
      <?php 
      chart_pie("bylp","Jenis Kelamin",$bylp);
      ?>
    </div>
    <div class="col-2">
      <?php 
      chart_pie("bypek","Pekerjaan",$bypek);
      ?>
    </div>
    <div class="col-2">
      <?php 
      chart_pie("bystudy","Pendidikan Terakhir",$bystudy);
      ?>
    </div>
    <div class="col-4">
      <?php 
      chart_bar("byprov","Provinsi",$byprov);
      ?>
    </div>
    <div class="col-2">

    </div>
  </div>
<p><br></p>
  <?php
}