<main>
  <div class="container-fluid">
    <div class="row align-items-center justify-content-between pt-2">
        <div class="col-auto mb-3">
            <h4>
                <b>job_kebid</b>
            </h4>
        </div>
        <div class="col-12 col-xl-auto mb-3">
          <?php 
          $tgl=$ftgl=date("Y-m-d");

          $today=date("Y-m-d");
          $tday=date("d-D");
          $yesterday=date("Y-m-d", strtotime($tgl)-86400);
          $yday=date("d-D", strtotime($tgl)-86400);
          $y2esterday=date("Y-m-d", strtotime($tgl)-(86400*2));
          $y2day=date("d-D", strtotime($tgl)-(86400*2));
            echo ' <a class="btn btn-xs btn-color-yellow mr-1" href="?op=job_kebid&col=tgl&q='.$y2esterday.'">'.$y2day.'</a> ';
            echo ' <a class="btn btn-xs btn-color-yellow mr-1" href="?op=job_kebid&col=tgl&q='.$yesterday.'">'.$yday.'</a> ';   
            echo ' <a class="btn btn-xs btn-color-yellow mr-1" href="?op=job_kebid&col=tgl&q='.$tgl.'">'.$tday.'</a> ';        
          ?>            
          <a class="btn btn-xs btn-color-lime mr-1 mt-1" href="?op=job_kebid&op2=tool">Tool</a>
<a class="btn btn-xs btn-color-lime mr-1 mt-1" href="?op=job_kebid&op2=js4">Js4</a>
        </div>
    </div>            
          

    <?php
    switch($op2) {
      case "js4";
        fjs4("");
          break;
      case "js42";
          fjs4($_POST['json']);
          $js=json_decode($_POST['json']);
  foreach ($js->naik->kebid as $k => $v) {
    $udt=array(
      'st_naik'=>2,
    );
    Update($db,"daily_rute_price",$udt,"`berangkat_id`=".$v,1);
  }
  
  foreach ($js->turun->kebid as $k => $v) {
    $udt=array(
      'st_turun'=>2,
    );
    Update($db,"daily_rute_price",$udt,"`berangkat_id`=".$v,0);
  }
  foreach ($js->bagasi->kebid as $k => $v) {
    $udt=array(
      'st_bagasi'=>2,
    );
    Update($db,"daily_rute_price",$udt,"`berangkat_id`=".$v,0);
  }
  foreach ($js->penumpang->kebid as $k => $v) {
    $udt=array(
      'st_penumpang'=>2,
    );
    Update($db,"daily_rute_price",$udt,"`berangkat_id`=".$v,0);
  }

/*
          foreach ($js as $k => $v) {
            if($v->to_time!='') {
              $udt=array(
                'dr_time'=>$v->dr_time,
                'to_time'=>$v->to_time,
                'hplus'=>$v->hplus,
                'cek_time'=>1,
                'update_at'=>time(),
              );
              Update($db,"trayek",$udt,"kode_pergi='".$v->kode_rute."' and dr_agen=".$v->dr_agen." and to_agen=".$v->to_agen,1);
            }
          }
*/
          echo "<pre>"; print_r($js); echo "</pre>";
        break;
      case "tool";
          $sql2="SELECT * from `daily_rute_price` where tgl='".date("Y-m-d")."' or tgl='".date("Y-m-d",strtotime('-1 days'))."'";
          //echo $sql.";<br>";
          $res2=mysqli_query($db,$sql2);
          while($r2=mysqli_fetch_assoc($res2)) {
            $idt=array(
              'id'=>$r2['berangkat_id'],
              'kd_armada'=>$r2['kode_rute_armada'],
              'kelas_id'=>$r2['kelas_id'],
              'kelas_item_id'=>$r2['kelas_item_id'],
              'lambung'=>$r2['lambung'],
              'tgl'=>$r2['tgl'],
              'jalan'=>$r2['jalan'],
            );
            $udt=array(
              'kd_armada'=>$r2['kode_rute_armada'],
              'kelas_id'=>$r2['kelas_id'],
              'kelas_item_id'=>$r2['kelas_item_id'],
              'lambung'=>$r2['lambung'],
              'tgl'=>$r2['tgl'],
              'jalan'=>$r2['jalan'],
            );
            InsertUpdate($db,"job_kebid",$idt,$udt,1);
          }
          $url='https://rs2.azkapersada.com/js/kd_armada_dr_time.json';
          echo $url."<br>";
          $js_pergi=file_get_contents($url);
          $jsp=json_decode($js_pergi);  
          foreach ($jsp->dr_time as $k => $v) {
            $udt=array(
              'dr_time'=>$v,
            );
            Update($db,"job_kebid",$udt,"kd_armada='".$k."'",1);
          }              
        break;            


      case "list";
        default;
        list_job_kebid($q,$col,$q1,$col1,$q2,$col2,$lq,$lcol);
    }

    ?>


    
  </div>
</main>

<?php

function list_job_kebid($q,$col,$q1,$col1,$q2,$col2,$lq,$lcol) {
  global $db,$ar;
  $today=date("Y-m-d");
  if($col=='') {
    $col='tgl';
    $q=date("Y-m-d", strtotime("+0 day"));
  }

  ?>
  <table class="table table-bordered" id="dataTable_2d" width="100%" cellspacing="0">
    <thead>
      <tr>
        <th></th>
        <th>tgl</th>
        <th>time</th>
        <th>kd</th>
        <th>kelas</th>
        <th>nl</th>
        <th>jalan</th>                
        <th>step</th>
        <th>pnp</th>
        <th>baga</th>
        <th>naik</th>
        <th>turun</th>
        <th>uAt</th>
        <th>Menu</th>
      </tr>
    </thead>
    <tbody>
        <?php
        $sql = "select * from job_kebid where id>0 ";

        if($col!='' && $q!='') {
            $sql .= " and ".$col."='".$q."'";
        }
        if($col1!='' && $q1!='') {
            $sql .= " and ".$col1."='".$q1."'";
        }
        if($col2!='' && $q2!='') {
            $sql .= " and ".$col2."='".$q2."'";
        }
        if($lcol!='') {
            $sql .= " and ".$lcol." like '%".$lq."%'";
        }
        //$sql .= " order by update_at,job_kebid desc";

        //echo $sql;
        $res = mysqli_query($db, $sql);
        if(mysqli_num_rows($res)>0) {
        while($rw = mysqli_fetch_assoc($res)) {
          if($rw['update_at']>0) {
            $u_at=date("Y-m-d H:i:s",$rw['update_at']);
          } else {
            $u_at="";
          }            
        ?>

      <tr id="row-<?=$rw['id'];?>">
        <td><?=$rw['id'];?></td>
        <td><a href="?op=job_kebid&col=tgl&q=<?=$rw['tgl'];?>"><?=$rw['tgl'];?></a></td>
        <td><?=$rw['dr_time'];?></td>
        <td><a href="?op=job_kebid&col=kd_armada&q=<?=$rw['kd_armada'];?>"><?=$rw['kd_armada'];?></a></td>
        <td><a href="?op=job_kebid&col=kelas_id&q=<?=$rw['kelas_id'];?>"><?=$rw['kelas_id'];?></a></td>
        <td><a href="?op=job_kebid&col=lambung&q=<?=$rw['lambung'];?>"><?=$rw['lambung'];?></a></td>
        <td><a href="?op=job_kebid&col=<?=$col;?>&q=<?=$q;?>&col1=jalan&q1=<?=$rw['jalan'];?>"><?=$rw['jalan'];?></a></td>
        <td><a href="?op=job_kebid&col=step&q=<?=$rw['step'];?>"><?=$rw['step'];?></a></td>
        <td><?=$rw['st_penumpang'];?></td>                
        <td><?=$rw['st_bagasi'];?></td>                
        <td><?=$rw['st_naik'];?></td>                
        <td><?=$rw['st_turun'];?></td>                
        <td><?=$u_at;?></td>
        <td nowrap>                            
        </td>
      </tr>
    <?php
    }
    ?>
    </tbody>
  <?php 
    }      
  ?>   
  </table>
  <?=$sql;?><br><br>  
  <?php
}

function fjs4($json) {
  ?>
  <form action="index.php?op=job_kebid&op2=js42" method="post">
    <div class="form-group row">
        <label for="json" class="col-sm-1 col-form-label">JSON</label>
        <div class="col-sm-11">
          <textarea class="form-control" rows="10" name="json"><?=$json;?></textarea>
        </div>
    </div>

    <div class="form-group row">
        <div class="col-sm-10 offset-sm-2 text-right">
            <button type="submit" name="submit" class="btn btn-primary">Submit</button>
        </div>
    </div>      
  </form>
  <?php
}
?>
/home/u902783705/domains/azkapersada.com/public_html/sub/
rs2/inc/inc.job_kebid.php
si/common.function
si/dom/get.img
si/api/post_location
si/api/post_loc_v3
si/api/post_tag_v2
si/api/post_tag_v3
common.function
common.function-
footer
header
inc.app.function
inc.ar.app
index
tes_curl
ucol
api/v2/api.function
api/v2/inc.mail
api/v2/index
api/v2/php/agen
api/v2/php/armada_jalan_byday
api/v2/php/armada_perpal_byday
api/v2/php/armada_perpal_byday-
api/v2/php/beda_byday
api/v2/php/cek_rute_baru
api/v2/php/cek_rute_time
api/v2/php/cek_rute_time_v1
api/v2/php/cek_rute_time_v2
api/v2/php/city
api/v2/php/dr_time_byday
api/v2/php/dr_time_jalan_byday
api/v2/php/email_cek
api/v2/php/get_nl_byday
api/v2/php/get_nl_kelas_armada
api/v2/php/js_armada_tax_expire
api/v2/php/js_blue_armada
api/v2/php/js_blue_expire
api/v2/php/js_car_srut_blank
api/v2/php/js_img_todl
api/v2/php/js_jalurnew
api/v2/php/js_kebid
api/v2/php/js_nl_latest
api/v2/php/js_nl_min
api/v2/php/js_noken
api/v2/php/js_noken_mesin_blank
api/v2/php/js_noken_no_lambung
api/v2/php/js_noken_spionam_cek
api/v2/php/js_noken_tax_cek
api/v2/php/js_rute
api/v2/php/js_rute_bycity
api/v2/php/js_rute_min
api/v2/php/js_spionam_id
api/v2/php/js_spionam_kps
api/v2/php/kd_armada
api/v2/php/kd_armada_dr_time
api/v2/php/kd_armada_to_time
api/v2/php/naik_byday
api/v2/php/nk_pilih
api/v2/php/nl_noken_bytgl
api/v2/php/nl_pilih
api/v2/php/nl_reset
api/v2/php/noken_koreksi
api/v2/php/otw
api/v2/php/otw_not_full
api/v2/php/password_forgot
api/v2/php/post_1naik
api/v2/php/post_1turun
api/v2/php/post_blue
api/v2/php/post_dr_time_byday_local
api/v2/php/post_kebid_byday
api/v2/php/post_noken_mesin
api/v2/php/post_noken_no_lambung
api/v2/php/post_sakpol
api/v2/php/post_spionam
api/v2/php/post_spionam_cek
api/v2/php/post_spionam_update
api/v2/php/post_spnm_noken
api/v2/php/ricar
api/v2/php/rute_price
api/v2/php/selisih_bagasi
api/v2/php/signin
api/v2/php/tool
api/v2/php/tool_armada
api/v2/php/tool_lambung
api/v2/php/tool_noken
api/v2/php/turun_byday
api/v2/php/ucol
api/v2/php/uji_no
api/v2/php/update_agen
api/v2/php/update_armada_byday
api/v2/php/update_armada_v2_byday
api/v2/php/update_bagasi_byday
api/v2/php/update_bagasi_city
api/v2/php/update_jalan_byday
api/v2/php/update_penumpang_byday
api/v2/php/update_trayek_dr_time
api/v2/php/update_trayek_to_time
daily/10_tool_seq
daily/14_update_kd_armada
daily/15_update_rute_dr_to_ccd
daily/16_kdagen_to_id
daily/16_kdagen_to_id-
daily/17_update_dr_to_time
inc/inc.cp_sphp
inc/inc.filephp
inc/inc.job_kebid
inc/inc.js_pergi
inc/inc.rs4_css
inc/inc.rs4_html
inc/inc.rs4_h_page
inc/inc.rs4_h_tab
inc/inc.rs4_js
inc/inc.rs4_jsf
inc/inc.t1_css
inc/inc.t1_html
inc/inc.t1_h_page
inc/inc.t1_h_tab
inc/inc.t1_js
inc/inc.t1_jsf
xhr/inc.xhr