 |
|
Code (PHP)
$receiptNote_k = FomatCode::select('keyname_fomat_code')->where('name_fomat_code', '=', 'ใบส่งสินค้า')->first();
$receiptNote_key = isset($receiptNote_k->keyname_fomat_code)?$receiptNote_k->keyname_fomat_code:'กรุณากำหนดรูปแบบรหัส';
$seqReceipt = ProductInvoice::select('seq')->latest()->first();
if ($seqReceipt == '' || $seqReceipt == null) {
$seqReceipt = 0;
} else {
$seqReceipt = $seqReceipt->seq;
}
$seqID = ($seqReceipt + 1);
$maxId = ($seqReceipt + 1);
$date_k = FomatCode::select('val_fomat_code')->where('name_fomat_code', '=', 'ใบส่งสินค้า')->first();
switch (isset($date_k->val_fomat_code)?$date_k->val_fomat_code:null) {
case "เดือน":
$year = date('y')+43;
$date = date('m');
$maxId = substr('00000'.$maxId, -5);
break;
case "ปี":
$year = date('y')+43;
$date = $year;
$maxId = substr('00000'.$maxId, -5);
break;
case "ปี-เดือน":
$year = date('y')+43;
$date = $year.''.date('m');
$maxId = substr('00000'.$maxId, -5);
break;
case "อัตโนมัติ":
$date = '';
$maxId = substr('00000'.$maxId, -5);
break;
default:
$date = '';
$maxId = "";
}
$nextId = $receiptNote_key.$date.'-'.$maxId;
ผลลัพธ์
IVER01-00001
IVER01-00002
IVER01-00003
...
IVER12-00012
พอเริ่มเดือนใหม่
IVER02-00001
IVER02-00002
IVER02-00003
ประมาณนี้ครับ รบกวนหน่อยนะครับพี่ๆ
Tag : PHP, MySQL, Laravel Framework, Bootstrap Framework, XAMPP, Windows
|
|
 |
 |
 |
 |
Date :
2019-12-11 16:14:18 |
By :
Topsci2016 |
View :
650 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |