Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getNomorPO(date) {
  2.   var LastNoPOHdr;
  3.   var LastNoPOTmp;
  4.   var LastNo;
  5.   var NewNo;
  6.  
  7.   db.executeSql("SELECT IFNULL(MAX(SUBSTR(po_no,10,5)),0) AS last_no FROM po_hdr WHERE strftime('%Y', po_date)=? AND strftime('%m', po_date)=?", [moment(date).format('YYYY'), moment(date).format('MM')], function(rs) {
  8.     this.LastNoPOHdr = parseInt(rs.rows.item(0).last_no);
  9.     console.log('No terakhir dari po_hdr : ' + this.LastNoPOHdr);
  10.  
  11.     db.executeSql("SELECT IFNULL(MAX(SUBSTR(po_no,10,5)),0) AS last_no FROM tmp_po_hdr WHERE strftime('%Y', po_date)=? AND strftime('%m', po_date)=?", [moment(date).format('YYYY'), moment(date).format('MM')], function(rs) {
  12.       this.LastNoPOTmp = parseInt(rs.rows.item(0).last_no);
  13.       console.log('No terakhir dari tmp_po_hdr : ' + this.LastNoPOTmp);
  14.  
  15.       if (this.LastNoPOHdr > this.LastNoPOTmp){
  16.         this.LastNo = this.LastNoPOHdr + 1;
  17.       } else {
  18.         this.LastNo = this.LastNoPOTmp + 1;
  19.       }
  20.  
  21.       console.log('this.LastNo : ' + this.LastNo);
  22.       this.NewNo = CfgMDID + "-" + moment(date).format('YYYY') + moment(date).format('MM') + Lpad(this.LastNo, 5, 0);
  23.     }, function(err) {
  24.       alert(err.message);
  25.     });
  26.  
  27.   }, function(err) {
  28.     alert(err.message);
  29.   });
  30.  
  31.   console.log('Nomor PO Baru : ' + this.NewNo);
  32.  
  33.   return this.NewNo;
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement