Advertisement
auliakhilmirizgi

Controller My

Apr 19th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.49 KB | None | 0 0
  1. function getIKKID() {
  2.      global $cfg;
  3.      $objDB = new Database();
  4.      try {
  5.          $query="SELECT max(substr(no_invoice_keluar,8,5)) as no_invoice_keluar FROM invoice_keluar_kontrak where substr(no_invoice_keluar,2,6)='".date('ymd')."'";
  6.          //call select methods to retreive max id Order 00001
  7.          $data=$objDB->select($query);
  8.          foreach($data as $item):
  9.              $xid=$item['no_invoice_keluar'];
  10.              if(!isset($item['no_invoice_keluar'])) {
  11.                  $maxid="V".date('ymd')."00001";
  12.              }
  13.              else if(substr($xid,0,4)=="0000") {
  14.                     if(substr($xid,0,5)=="0009")
  15.                      $maxid = "V".date('ymd')."000".(intval(substr($xid,4,1))+1);
  16.                     else
  17.                      $maxid = "V".date('ymd')."0000".(intval(substr($xid,4,1))+1);
  18.              } else if(substr($xid,0,3)=="000" && substr($xid,0,4)!="0000") {
  19.                  if(substr($xid,0,5)=="0099")
  20.                      $maxid = "V".date('ymd')."00".(intval(substr($xid,3,2))+1);
  21.                  else
  22.                      $maxid = "V".date('ymd')."000".(intval(substr($xid,3,2))+1);
  23.                  } else if(substr($xid,0,2)=="00" && substr($xid,0,3)!="000") {
  24.                  if(substr($xid,0,5)=="0999")
  25.                      $maxid = "V".date('ymd')."0".(intval(substr($xid,2,3))+1);
  26.                  else
  27.                      $maxid = "V".date('ymd')."00".(intval(substr($xid,2,3))+1);
  28.                  } else if(substr($xid,0,1)=="0" && substr($xid,0,2)!="00") {
  29.                     $maxid = "V".date('ymd')."0".(intval(substr($xid,1,4))+1);
  30.                  } else
  31.                  $maxid = "V".date('ymd').substr($xid,0,5)+1;
  32.          endforeach;
  33.      } catch (Exception $e) {
  34.          echo "Query failure" . NL;
  35.          echo $e->getMessage();
  36.      }
  37.      return $maxid;
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement