|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/* |
| 6 | + * @copyright © 2019 Dxvn, Inc. |
| 7 | + * |
| 8 | + * @author Tran Ngoc Duc <ductn@diepxuan.com> |
| 9 | + * @author Tran Ngoc Duc <caothu91@gmail.com> |
| 10 | + * |
| 11 | + * @lastupdate 2026-06-05 20:58:00 |
| 12 | + */ |
| 13 | + |
| 14 | +namespace Diepxuan\Simba\Models; |
| 15 | + |
| 16 | +use Diepxuan\Simba\SModel\SModel; |
| 17 | + |
| 18 | +/** |
| 19 | + * Model SiDmCt - Khai báo màn hình nhập chứng từ. |
| 20 | + * |
| 21 | + * Source: simba-docs/tables/SiDmCt.md. |
| 22 | + */ |
| 23 | +class SiDmCt extends SModel |
| 24 | +{ |
| 25 | + public $incrementing = false; |
| 26 | + public $timestamps = false; |
| 27 | + protected $table = 'SiDmCt'; |
| 28 | + protected $primaryKey = 'ma_ct'; |
| 29 | + protected $keyType = 'string'; |
| 30 | + |
| 31 | + protected $fillable = [ |
| 32 | + 'ma_cty', |
| 33 | + 'ma_ct', |
| 34 | + 'phan_he', |
| 35 | + 'ma_ct_me', |
| 36 | + 'ten_ct', |
| 37 | + 'tk_no', |
| 38 | + 'tk_co', |
| 39 | + 'ma_nt', |
| 40 | + 'so_lien', |
| 41 | + 'stt_nkc', |
| 42 | + 'stt_ntxt', |
| 43 | + 'ct_dc', |
| 44 | + 'loc_nsd', |
| 45 | + 'vv', |
| 46 | + 'spct', |
| 47 | + 'phi', |
| 48 | + 'bp', |
| 49 | + 'lo', |
| 50 | + 'sp_post', |
| 51 | + 'sp_process', |
| 52 | + 'ph', |
| 53 | + 'ct', |
| 54 | + 'sd', |
| 55 | + 'nxt', |
| 56 | + 'menuid', |
| 57 | + 'vn_prefix', |
| 58 | + 'vn_postfix', |
| 59 | + 'vn_sequence', |
| 60 | + 'vn_pattern', |
| 61 | + 'vn_width', |
| 62 | + 'PhFieldlist2IN', |
| 63 | + 'CtFieldlist2IN', |
| 64 | + 'kieu_trung_so_ct', |
| 65 | + 'VoucherGetWhenOpenForm', |
| 66 | + ]; |
| 67 | + |
| 68 | + protected $casts = [ |
| 69 | + 'so_lien' => 'integer', |
| 70 | + 'stt_nkc' => 'integer', |
| 71 | + 'stt_ntxt' => 'integer', |
| 72 | + 'ct_dc' => 'boolean', |
| 73 | + 'loc_nsd' => 'boolean', |
| 74 | + 'vv' => 'boolean', |
| 75 | + 'spct' => 'boolean', |
| 76 | + 'phi' => 'boolean', |
| 77 | + 'bp' => 'boolean', |
| 78 | + 'lo' => 'boolean', |
| 79 | + 'sd' => 'boolean', |
| 80 | + 'vn_sequence' => 'integer', |
| 81 | + 'vn_width' => 'integer', |
| 82 | + 'kieu_trung_so_ct' => 'integer', |
| 83 | + 'VoucherGetWhenOpenForm' => 'boolean', |
| 84 | + ]; |
| 85 | + |
| 86 | + /** |
| 87 | + * Scope: find voucher metadata by company and voucher code. |
| 88 | + * |
| 89 | + * @param mixed $query |
| 90 | + */ |
| 91 | + public function scopeVoucher($query, string $maCt, string $maCty = SModel::CTY) |
| 92 | + { |
| 93 | + return $query->where('ma_cty', $maCty)->where('ma_ct', $maCt); |
| 94 | + } |
| 95 | + |
| 96 | + /** |
| 97 | + * Scope: find voucher metadata by Simba menuid. |
| 98 | + * |
| 99 | + * @param mixed $query |
| 100 | + */ |
| 101 | + public function scopeMenuId($query, string $menuId) |
| 102 | + { |
| 103 | + return $query->where('menuid', $menuId); |
| 104 | + } |
| 105 | + |
| 106 | + /** |
| 107 | + * @return list<string> |
| 108 | + */ |
| 109 | + public function headerFieldsForInventory(): array |
| 110 | + { |
| 111 | + return array_values(array_filter(array_map('trim', explode(',', (string) $this->PhFieldlist2IN)))); |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * @return list<string> |
| 116 | + */ |
| 117 | + public function detailFieldsForInventory(): array |
| 118 | + { |
| 119 | + return array_values(array_filter(array_map('trim', explode(',', (string) $this->CtFieldlist2IN)))); |
| 120 | + } |
| 121 | +} |
0 commit comments