Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getNomorPO(date) {
- var LastNoPOHdr;
- var LastNoPOTmp;
- var LastNo;
- var NewNo;
- 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) {
- this.LastNoPOHdr = parseInt(rs.rows.item(0).last_no);
- console.log('No terakhir dari po_hdr : ' + this.LastNoPOHdr);
- 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) {
- this.LastNoPOTmp = parseInt(rs.rows.item(0).last_no);
- console.log('No terakhir dari tmp_po_hdr : ' + this.LastNoPOTmp);
- if (this.LastNoPOHdr > this.LastNoPOTmp){
- this.LastNo = this.LastNoPOHdr + 1;
- } else {
- this.LastNo = this.LastNoPOTmp + 1;
- }
- console.log('this.LastNo : ' + this.LastNo);
- this.NewNo = CfgMDID + "-" + moment(date).format('YYYY') + moment(date).format('MM') + Lpad(this.LastNo, 5, 0);
- }, function(err) {
- alert(err.message);
- });
- }, function(err) {
- alert(err.message);
- });
- console.log('Nomor PO Baru : ' + this.NewNo);
- return this.NewNo;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement