<?php
$dt=tool_noken_kelas_armada();
echo json_encode($dt);

function tool_noken_kelas_armada(){
  global $ar,$db;
  $dt=array();
  //$dt['param']=$js;
  $a=0;
  $sql="SELECT 
    `noken`,kelas_armada,lambung_last
  FROM `noken` where `kelas_armada`=0 and lambung_last!=''";
  $res=mysqli_query($db,$sql);
  //$dt['count']=mysqli_num_rows($res);
  while($r=mysqli_fetch_assoc($res)) {
    $sql1="SELECT armada_kelas from daily_rute_price where lambung='".$r['lambung_last']."' and nopol='".$r['noken']."' and armada_kelas>0 order by tgl desc limit 1";
    //echo $sql1."<br>";
    $res1=mysqli_query($db,$sql1);
    if(mysqli_num_rows($res1)>0) {
      $r1=mysqli_fetch_assoc($res1);
      $udt=array(
        'kelas_armada'=>$r1['armada_kelas'],
      );
      Update($db,"noken",$udt,"noken='".$r['noken']."'",0);
      $dt[$a]['udt']=$udt;
      $dt[$a]['sql']=$sql1;
      $a++;
    }    
  }
  $dt['count']=$a;
  $dt['status']=true;
  return $dt;
  $db->close();
}


function tool_noken_th_rakit_by_ujino(){
  global $ar,$db;
  $dt=array();
  //$dt['param']=$js;
  $a=0;
  $sql="SELECT 
    `noken`,uji_no
  FROM `noken` where `own`=2 and spionam_st=1 and th_rakit='0'";
  $res=mysqli_query($db,$sql);
  $dt['count']=mysqli_num_rows($res);
  while($r=mysqli_fetch_assoc($res)) {
    $sql1="SELECT th_rakit from car_uji where no_uji='".$r['uji_no']."' limit 1";
    //echo $sql1."<br>";
    $res1=mysqli_query($db,$sql1);
    if(mysqli_num_rows($res1)>0) {
      $udt=array(
        'th_rakit'=>$r1['th_rakit'],
      );
      Update($db,"noken",$udt,"noken='".$r['noken']."'",0);
      $dt[$a]['udt']=$udt;
      $dt[$a]['nk']=$r['noken'];
      $a++;
    }    
  }
  $dt['status']=true;
  return $dt;
  $db->close();
}


function tool_noken3(){
  global $ar,$db;
  $dt=array();
  //$dt['param']=$js;
  $a=0;
  $sql="SELECT 
    `noken`
  FROM `noken` where `own`=2 and spionam_st=1 and lambung_last='0'";
  $res=mysqli_query($db,$sql);
  $dt['count']=mysqli_num_rows($res);
  while($r=mysqli_fetch_assoc($res)) {
    $sql1="SELECT lambung,nopol,armada_id,count(*) as jum from daily_rute_price where nopol='".$r['noken']."' and armada_id>0 and lambung!='' group by lambung,nopol,armada_id order by jum desc limit 1";
    //echo $sql1."<br>";
    $res1=mysqli_query($db,$sql1);
    if(mysqli_num_rows($res1)>0) {
      while($r1=mysqli_fetch_assoc($res1)) {

      $sql2="SELECT tgl,kelas_id,armada_kelas from daily_rute_price where nopol='".$r1['nopol']."' and armada_id='".$r1['armada_id']."' and lambung=".$r1['lambung']." order by tgl desc limit 1";
      $res2=mysqli_query($db,$sql2);
      if(mysqli_num_rows($res2)>0) {
        $r2=mysqli_fetch_assoc($res2);
          $udt=array(
            'lambung_last'=>$r1['lambung'],
            'lambung_tgl'=>$r2['tgl'],
            'kelas_armada'=>$r2['armada_kelas'],
          );
          Update($db,"noken",$udt,"noken='".$r['noken']."'",0);
          $dt['udt'][$a]=$udt;
          $a++;
        }
      }
    }    

  }
  $dt['status']=true;
  return $dt;
  $db->close();
}

function tool_noken2(){
  global $ar,$db;
  $dt=array();
  //$dt['param']=$js;
  $sql="SELECT 
    `nopol`
  FROM `daily_rute_price` where nopol!='' and nopol !='00000' and nopol!='000000' group by nopol";
  $res=mysqli_query($db,$sql);
  $dt['count']=mysqli_num_rows($res);
  while($r=mysqli_fetch_assoc($res)) {
      $idt=array(
        'noken'=>$r['nopol'],
      );
      $udt=array(
        'update_at'=>time(),
      );
      InsertUpdate($db,"noken",$idt,$udt,0);
  }
  $dt['status']=true;
  return $dt;
  $db->close();
}


function tool_noken(){
  global $ar,$db;
  $dt=array();
  //$dt['param']=$js;
  $sql="SELECT 
    `noken`
  FROM `armada_v2` group by noken";
  $res=mysqli_query($db,$sql);
  $dt['count']=mysqli_num_rows($res);
  while($r=mysqli_fetch_assoc($res)) {
      $idt=array(
        'noken'=>$r['noken'],
      );
      $udt=array(
        'update_at'=>time(),
      );
      InsertUpdate($db,"noken",$idt,$udt,0);
  }
  $dt['status']=true;
  return $dt;
  $db->close();
}
?>
/home/u902783705/domains/azkapersada.com/public_html/sub/
rs2/api/v2/php/tool_noken.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