178 lines
5.5 KiB
PHP
178 lines
5.5 KiB
PHP
<?php
|
|
|
|
/*******************************************************************
|
|
|
|
PHP Class : /Utils/Invesa
|
|
Description : Class umum untuk Aplikasi Invesa
|
|
Created By : Siau Pheng ([email protected]).
|
|
Created Date : February 10th, 2012.
|
|
Last Modified : November 4th, 2026.
|
|
|
|
(c) 3FONIA Software; WWW.3FONIA.COM.
|
|
|
|
*******************************************************************/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Utils;
|
|
|
|
final class Invesa {
|
|
|
|
public const ppn = [
|
|
1 => "PPN",
|
|
2 => "Spesial 1", //Non PPN
|
|
3 => "Spesial 2", //Sembako
|
|
4 => "Spesial 3", //Rokok Legal
|
|
5 => "Spesial 4", //Rokok Ilegal
|
|
];
|
|
public const old_printer = [ "TM-U220" ];
|
|
|
|
public function __construct() {
|
|
}
|
|
|
|
public static function PPN_Array(int $item = -1): mixed {
|
|
return ($item === -1) ? self::ppn : self::ppn[$item];
|
|
}
|
|
|
|
public static function Form_Info(string $pesan=""): string {
|
|
return '<button class="btn btn-outline-secondary shadow-none text-info" data-toggle="tooltip" title="'.$pesan.'"><i class="bi-lightbulb"></i></button>';
|
|
}
|
|
|
|
/************************* BARANG / PRODUK *************************/
|
|
|
|
public static function genEAN8(string $pref = '0', int $numb = 1): string {
|
|
$code = str_pad($pref, 5, '0', STR_PAD_LEFT) . str_pad((string) $numb, 2, '0', STR_PAD_LEFT);
|
|
$bflag = true;
|
|
$sum = 0;
|
|
for ($i = strlen($code) - 1; $i >= 0; $i--) {
|
|
$sum += (int) $code[$i] * ($bflag?3:1);
|
|
$bflag = !$bflag;
|
|
}
|
|
$code .= (string) (10 - ($sum % 10)) % 10;
|
|
return $code;
|
|
}
|
|
|
|
public static function genEAN13(string $pref = "98000", int $numb = 1): string {
|
|
$code = str_pad($pref, 5, '0', STR_PAD_LEFT) . str_pad((string) $numb, 7, '0', STR_PAD_LEFT);
|
|
$weightflag = true;
|
|
$sum = 0;
|
|
for ($i = strlen($code) - 1; $i >= 0; $i--) {
|
|
$sum += (int) $code[$i] * ($weightflag?3:1);
|
|
$weightflag = !$weightflag;
|
|
}
|
|
$code .= (string) (10 - ($sum % 10)) % 10;
|
|
return $code;
|
|
}
|
|
|
|
/************************* DEFAULT ARRAY TABLE *************************/
|
|
|
|
public static function A_Iklan(): array {
|
|
return [
|
|
'PromoID' => 0,
|
|
'CabID' => 0,
|
|
'Tanggal' => tgl_ymd(),
|
|
'Info' => "",
|
|
'Warna' => "#FFFFFF",
|
|
'Font' => 40,
|
|
'Aktif' => 1,
|
|
];
|
|
}
|
|
|
|
public static function A_Member_Member(): array {
|
|
return [
|
|
'MemberID' => 0,
|
|
'Grup_MemberID' => 0,
|
|
'Kode_Member' => "",
|
|
'Nama_Member' => "",
|
|
'Alamat_Member' => "",
|
|
'Kota_Member' => "",
|
|
'Telp_Member' => "",
|
|
'KTP_Member' => "",
|
|
'Tgl_Lahir' => "0000-00-00",
|
|
'Tgl_Daftar' => tgl_ymd(),
|
|
'IM' => true,
|
|
'Aktif' => 1,
|
|
];
|
|
}
|
|
|
|
public static function A_Member_Grup(): array {
|
|
return [
|
|
'Grup_MemberID' => 0,
|
|
'Kode_Grup' => "",
|
|
'Nama_Grup' => "",
|
|
'Aktif' => 1,
|
|
];
|
|
}
|
|
|
|
public static function A_Promo(int $tipe_promo = 1): array {
|
|
return [
|
|
'PromoID' => 0,
|
|
'Nama_Promo' => "",
|
|
'InvID' => 0,
|
|
'SatuanID' => 0,
|
|
'CabID' => 0,
|
|
'Grup_MemberID' => 0,
|
|
'Pilih_Qty' => 1,
|
|
'Tipe_Promo' => $tipe_promo,
|
|
'Promo_InvID' => 0,
|
|
'Promo_SatuanID' => 0,
|
|
'Promo_Qty' => 0,
|
|
'Promo_Disc' => 0,
|
|
'Nama_Produk' => "",
|
|
'Promo_Produk' => "",
|
|
'Jual_Min' => 0,
|
|
'Jual_Grup' => "",
|
|
'Promo_Jual' => 0,
|
|
'Qty_Min' => 0,
|
|
'Qty_Kali' => 0,
|
|
'Jumlah_Promo' => 0,
|
|
'Tgl_Mulai' => tgl_ymd(),
|
|
'Tgl_Akhir' => tgl_sql2str(tgl_operasi(tgl_dmy(),0,1,0)),
|
|
'Aktif' => 1,
|
|
];
|
|
}
|
|
|
|
/************************* VOUCHER *************************/
|
|
|
|
public static function getVoucherBG(string $root_dir): array {
|
|
$voudir = $root_dir . DIRECTORY_SEPARATOR . "public" . DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . "images" . DIRECTORY_SEPARATOR . "voucher";
|
|
$afile = [];
|
|
$iterator = new \FilesystemIterator($voudir, \FilesystemIterator::SKIP_DOTS);
|
|
foreach ($iterator as $_file) {
|
|
if ($_file->isFile() && str_contains($_file->getFilename(), "vou")) {
|
|
$afile[] = $_file->getFilename();
|
|
}
|
|
}
|
|
return $afile;
|
|
}
|
|
|
|
/************************* FORMAT TAMPILAN DATA *************************/
|
|
|
|
public static function Format_Stok(int|float $total=0, int $kali=1, string $sat_norm="", string $sat_stok=""): string {
|
|
if ($kali > 0) {
|
|
$norm = floor($total / $kali);
|
|
$sisa = $total - ($norm * $kali);
|
|
} else {
|
|
$norm = 0;
|
|
$sisa = $total;
|
|
}
|
|
$stok = rupiah($norm,0)." ".$sat_norm;
|
|
if ($sat_norm !== $sat_stok) $stok .= ", ".rupiah($sisa,0)." ".$sat_stok;
|
|
return $stok;
|
|
}
|
|
|
|
/************************* PRINTER THERMAL *************************/
|
|
|
|
public static function Printer_Thermal(string $printer): bool {
|
|
$is_thermal = true;
|
|
foreach (self::old_printer as $old) {
|
|
if (str_contains($printer, $old)) {
|
|
$is_thermal = false;
|
|
break;
|
|
}
|
|
}
|
|
return $is_thermal;
|
|
}
|
|
|
|
}
|