upgrade all with dice compatible

This commit is contained in:
2026-08-22 12:53:04 +07:00
parent 27ebdca49b
commit e7bb9a6c90
34 changed files with 546 additions and 486 deletions
+55 -50
View File
@@ -2,13 +2,13 @@
/*******************************************************************
Module : /Printing/PrintPOS.php
Module : /Printer/PrintPOS.php
Desc. : Class cetak POS
Created By : Siau Pheng ([email protected]).
Created Date : June 15th, 2008.
Last Modified : December 3rd, 2025.
Last Modified : August 21st, 2026.
(c) 2008 - 2025, 3FONIA Software; WWW.3FONIA.COM.
(c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
@@ -16,48 +16,54 @@ declare(strict_types=1);
namespace siaupheng\webapp\Printer;
/* VERSI BARU DENGAN MULTI SHEET */
class PrintPOS {//up: 20251203
use \flight\Engine;
use \flight\Session;
class PrintPOS {
private $_header = [];
private $_avalue = [];
private $_astyle = [];
private $_ncont = 0;
private $_maxchr = 40;
private $_config = [
'fontsize' => 1,
'opendraw' => false,
'cutpaper' => false,
'logo' => null ];
'fontsize' => 1,
'opendraw' => false,
'cutpaper' => false,
'logo' => null,
];
private array $webapp;
private array $webuser;
protected Engine $app;
public function __construct() {
public function __construct(Engine $app, Session $session) {
$this->app = $app;
$this->webapp = $session->get('__WEB_APP', ['APP_NAME'=>'', 'APP_VER'=>'', 'REAL_PATH'=>'']);
$this->webuser = $session->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
}
public function set_opendrawer() {
public function set_opendrawer(): void {
$this->_config['opendraw'] = true;
}
public function set_cutpaper() {
public function set_cutpaper(): void {
$this->_config['cutpaper'] = true;
}
public function set_maxchr($nmax = 0) {//up: 2015-03-22
if ($nmax > 0) $this->_maxchr = $nmax;
public function set_maxchr(int $max = 0): void {
if ($max > 0) $this->_maxchr = $max;
}
public function set_fontsize($nsize = 1) {//up: 2015-09-30
if ($nsize > 0) $this->_config['fontsize'] = $nsize;
public function set_fontsize(int $size = 1): void {
if ($size > 0) $this->_config['fontsize'] = $size;
}
public function set_printnv_logo() {}//delete
public function set_header_logo($logo_file = "") {//up: 2019-01-08
if ($logo_file=="") return;
if (file_exists($_SESSION['__WEB_APP']['REAL_PATH']."assets/images/".$logo_file)) {
$this->_config['logo'] = $_SESSION['__WEB_APP']['WEB_PATH']."assets/images/".$logo_file;
public function set_header_logo(string $logo_file = ""): void {
if (!empty($logo_file) && file_exists($this->webapp['REAL_PATH']."assets/images/".$logo_file)) {
$this->_config['logo'] = $this->webapp['WEB_PATH']."assets/images/".$logo_file;
}
}
public function add_header() {//up: 2025-12-03
public function add_header(): void {
$extra = func_get_args();
if (count($extra) > 0) {
foreach ($extra as $_val) {
@@ -66,11 +72,11 @@ class PrintPOS {//up: 20251203
}
}
public function add_sheet() {//up: 20170321
public function add_sheet(): void {
$this->_ncont++;
}
public function add() {//up: 20180524
public function add(): void {
$val_arr = func_get_args(); $ttext = ""; $tstyle = "L";
if (is_array($val_arr[0])) {
foreach($val_arr as $aval) {
@@ -84,32 +90,32 @@ class PrintPOS {//up: 20251203
$this->_astyle[$this->_ncont][] = $tstyle;
}
public function addl($ttext = "") {
$this->add($ttext);
public function addl(string $text = ""): void {
$this->add($text);
}
public function addr($ttext = "") {
$this->add($ttext, "R");
public function addr(string $text = ""): void {
$this->add($text, "R");
}
public function addc($ttext = "") {
$this->add($ttext, "C");
public function addc(string $text = ""): void {
$this->add($text, "C");
}
public function add_line($tmp = "-") {
$this->add("__LINE ".$tmp);
public function add_line(string $line = "-"): void {
$this->add("__LINE ".$line);
}
public function add_empty($nrep = 1) {
for ($i=0;$i<$nrep;$i++) $this->add("");
public function add_empty(int $baris = 1): void {
for ($i=0; $i<$baris; $i++) $this->add("");
}
public function add_stamp($ctk_ke=1, $bnama=false) {
$this->add($_SESSION['__WEB_APP']['APP_NAME']."v".$_SESSION['__WEB_APP']['APP_VER'].date("\@ymd.His")."-".user_id(3).(($bnama==true)?"/".strtoupper(user_user()):"").(($ctk_ke>0)?"#".isi_nol($ctk_ke,2):""));
public function add_stamp(int $ctk_ke=1, bool $cetak_nama=false): void {
$this->add($this->webapp['APP_NAME']."v".$this->webapp['APP_VER'].date("\@ymd.His")."-".isi_nol($this->webuser['UserID'], 3).(($cetak_nama)?"/".strtoupper($this->webuser['Username']):"").(($ctk_ke>0)?"#".isi_nol($ctk_ke,2):""));
}
private function _json_out() {//up: 2016-11-12
$acontent = array();
public function show(int $jumlah_ctk=1): void {
$acontent = [];
$nmax = $this->_maxchr;
for ($s=0; $s<count($this->_avalue); $s++) {
@@ -123,24 +129,23 @@ class PrintPOS {//up: 20251203
}
}
$aout = array('type' => "escp");
$this->_config['times'] = $jumlah_ctk;
$aout = ['type' => "escp"];
$aout['config'] = $this->_config;
$aout['header'] = $this->_header;
$aout['content'] = $acontent;
send_json($aout);
$this->app->json($aout);
}
public function show($jumlah_ctk=1) {
$this->_config['times'] = $jumlah_ctk;
$this->_json_out();
public function set_align(string $text, int $len=0, string $dir="L"): string {
$apad = ["L"=>STR_PAD_RIGHT, "R"=>STR_PAD_LEFT, "C"=>STR_PAD_BOTH];
$nlen = ($len==0) ? strlen($text) : $len;
$ttext = (strlen($text)>$len) ? substr($text, 0, $len) : $text;
return str_pad($text, $len, " ", $apad[$dir]);
}
public function set_align($ttext, $nlen=0, $tdir="L") {//up: 20180524
$apad = array("L"=>STR_PAD_RIGHT, "R"=>STR_PAD_LEFT, "C"=>STR_PAD_BOTH);
$nlen = ($nlen==0) ? strlen($ttext) : $nlen;
$ttext = (strlen($ttext)>$nlen) ? substr($ttext, 0, $nlen) : $ttext;
return str_pad($ttext, $nlen, " ", $apad[$tdir]);
}
//todo: deprecated
public function set_printnv_logo() {}//delete
}
?>