reorganize class name
This commit is contained in:
+27
-45
@@ -5,7 +5,7 @@
|
||||
Module : /Printer/PrintPOS.php
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : June 15th, 2008.
|
||||
Last Modified : September 21st, 2026.
|
||||
Last Modified : October 3rd, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
@@ -29,12 +29,11 @@ use \flight\Engine;
|
||||
*/
|
||||
|
||||
class PrintPOS {
|
||||
private $_header = [];
|
||||
private $_avalue = [];
|
||||
private $_astyle = [];
|
||||
private $_ncont = 0;
|
||||
private $_maxchr = 40;
|
||||
private $_config = [
|
||||
private int $sheet = 0;
|
||||
private int $maxchr = 40;
|
||||
private array $header = [];
|
||||
private array $acontent = [];
|
||||
private array $config = [
|
||||
'fontsize' => 1,
|
||||
'opendraw' => false,
|
||||
'cutpaper' => false,
|
||||
@@ -54,53 +53,52 @@ class PrintPOS {
|
||||
}
|
||||
|
||||
public function set_opendrawer(): void {
|
||||
$this->_config['opendraw'] = true;
|
||||
$this->config['opendraw'] = true;
|
||||
}
|
||||
|
||||
public function set_cutpaper(): void {
|
||||
$this->_config['cutpaper'] = true;
|
||||
$this->config['cutpaper'] = true;
|
||||
}
|
||||
|
||||
public function set_maxchr(int $max = 0): void {
|
||||
if ($max > 0) $this->_maxchr = $max;
|
||||
if ($max > 0) $this->maxchr = $max;
|
||||
}
|
||||
|
||||
public function set_fontsize(int $size = 1): void {
|
||||
if ($size > 0) $this->_config['fontsize'] = $size;
|
||||
if ($size > 0) $this->config['fontsize'] = $size;
|
||||
}
|
||||
|
||||
public function set_header_logo(string $logo_file = ""): void {
|
||||
if (!empty($logo_file) && file_exists(PROJECT_ROOT."public/assets/images/".$logo_file)) {
|
||||
//$this->_config['logo'] = PROJECT_BASE."assets/images/".$logo_file;
|
||||
$this->_config['logo'] = base64_encode(file_get_contents(PROJECT_ROOT."public/assets/images/".$logo_file));
|
||||
//$this->config['logo'] = PROJECT_BASE."assets/images/".$logo_file;
|
||||
$this->config['logo'] = base64_encode(file_get_contents(PROJECT_ROOT."public/assets/images/".$logo_file));
|
||||
}
|
||||
}
|
||||
|
||||
public function add_header(): void {
|
||||
$extra = func_get_args();
|
||||
if (count($extra) > 0) {
|
||||
foreach ($extra as $_val) {
|
||||
$this->_header[] = $_val;
|
||||
}
|
||||
}
|
||||
if (count($extra) > 0) $this->header = $extra;
|
||||
}
|
||||
|
||||
public function add_sheet(): void {
|
||||
$this->_ncont++;
|
||||
$this->sheet++;
|
||||
}
|
||||
|
||||
public function add(): void {
|
||||
$val_arr = func_get_args(); $ttext = ""; $tstyle = "L";
|
||||
if (is_array($val_arr[0])) {
|
||||
foreach($val_arr as $aval) {
|
||||
$ttext .= $this->set_align((isset($aval[0])?$aval[0]:""), (isset($aval[1])?$aval[1]:0), (isset($aval[2])?$aval[2]:$tstyle));
|
||||
foreach ($val_arr as $aval) {
|
||||
$ttext .= $this->set_align(($aval[0] ?? ""), ($aval[1] ?? 0), ($aval[2] ?? $tstyle));
|
||||
}
|
||||
} else {
|
||||
$ttext = (isset($val_arr[0])) ? $val_arr[0] : "";
|
||||
$tstyle = (isset($val_arr[1])) ? $val_arr[1] : $tstyle;
|
||||
$ttext = $val_arr[0] ?? "";
|
||||
$tstyle = $val_arr[1] ?? $tstyle;
|
||||
}
|
||||
$this->_avalue[$this->_ncont][] = $ttext;
|
||||
$this->_astyle[$this->_ncont][] = $tstyle;
|
||||
if (str_contains($ttext, "_LINE")) {
|
||||
$tmp_arr = explode(" ", $ttext);
|
||||
$ttext = str_pad($tmp_arr[1], $this->maxchr, $tmp_arr[1]);
|
||||
}
|
||||
$this->acontent[$this->sheet][] = ($tstyle === "X") ? $ttext : $this->set_align($ttext, $this->maxchr, $tstyle);
|
||||
}
|
||||
|
||||
public function addl(string $text = ""): void {
|
||||
@@ -128,25 +126,11 @@ class PrintPOS {
|
||||
}
|
||||
|
||||
public function show(int $jumlah_ctk=1): void {
|
||||
$acontent = [];
|
||||
$nmax = $this->_maxchr;
|
||||
|
||||
for ($s=0; $s<count($this->_avalue); $s++) {
|
||||
for ($i=0; $i<count($this->_avalue[$s]); $i++) {
|
||||
$tmp_str = $this->_avalue[$s][$i];
|
||||
if (strpos($tmp_str, "_LINE")>0) {
|
||||
$tmp_arr = explode(" ", $tmp_str);
|
||||
$tmp_str = str_pad($tmp_arr[1], $nmax, $tmp_arr[1]);
|
||||
}
|
||||
$acontent[$s][] = ($this->_astyle[$s][$i]=="X") ? $tmp_str : $this->set_align($tmp_str, $nmax, $this->_astyle[$s][$i]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_config['times'] = $jumlah_ctk;
|
||||
$this->config['times'] = $jumlah_ctk;
|
||||
$aout = ['type' => "escp"];
|
||||
$aout['config'] = $this->_config;
|
||||
$aout['header'] = $this->_header;
|
||||
$aout['content'] = $acontent;
|
||||
$aout['config'] = $this->config;
|
||||
$aout['header'] = $this->header;
|
||||
$aout['content'] = $this->acontent;
|
||||
$this->app->json($aout);
|
||||
}
|
||||
|
||||
@@ -157,8 +141,6 @@ class PrintPOS {
|
||||
return str_pad($text, $len, " ", $apad[$dir]);
|
||||
}
|
||||
|
||||
//todo: deprecated
|
||||
public function set_printnv_logo() {}//delete
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user