Update printer class

This commit is contained in:
2021-06-08 10:47:47 +07:00
parent 0868444713
commit 9d72965395
5 changed files with 518 additions and 453 deletions
+29 -2
View File
@@ -13,7 +13,7 @@
'use strict';
var FoniaJS = {
version: "3.0.0b",
version: "3.0.0",
APP_ID: 0,
APP_SID: "",
WEB_HOST: "",
@@ -886,7 +886,8 @@ Request.JSONF = function(options){//oke
strBody += '</tbody>';
$(divData).append(strTab + strHead + strBody + strFoot + '</table>');
var opsi = { responsive: true, columnDefs: [{responsivePriority:1,targets:0}], language: { url: FoniaJS.WEB_PATH+'assets/locale/datatables.id.json' }, dom: 'rt<"bottom"p>', autoWidth: false, processing: true, searching: false };
var opsi = { responsive: true, columnDefs: [{responsivePriority:1,targets:0}], dom: 'rt<"bottom"p>', autoWidth: false, processing: true, searching: false };
//language: { url: FoniaJS.WEB_PATH+'assets/locale/datatables.id.json' },
opsi.columns = aSortCol;
if (ini.option.length > 0) opsi.columnDefs = [{responsivePriority:1,targets:0}, {responsivePriority:2,targets:-1}, {orderable:false,targets:-1}];
if (ini.config.scrollbar == true) {
@@ -1117,4 +1118,30 @@ if (jQuery.fn.dataTable) {
return $('input', td).prop('checked') ? '1' : '0';
});
}
jQuery.extend(jQuery.fn.dataTable.defaults.oLanguage, {
"oAria": {
"sSortAscending": ": aktifkan urutan kolom keatas",
"sSortDescending": ": aktifkan urutan kolom kebawah"
},
"oPaginate": {
"sFirst": "<i class=\"cui-media-step-backward\"></i>",
"sPrevious": "<i class=\"cui-media-skip-backward\"></i>",
"sNext": "<i class=\"cui-media-skip-forward\"></i>",
"sLast": "<i class=\"cui-media-step-forward\"></i>"
},
"sEmptyTable": "Tidak ada data yang tersedia pada tabel ini",
"sProcessing": "Sedang memproses...",
"sLengthMenu": "Tampilkan _MENU_ entri",
"sZeroRecords": "Tidak ditemukan data yang sesuai",
"sInfo": "Menampilkan _START_ sampai _END_ dari _TOTAL_ entri",
"sInfoEmpty": "Menampilkan 0 sampai 0 dari 0 entri",
"sInfoFiltered": "(disaring dari _MAX_ entri keseluruhan)",
"sInfoPostFix": "",
"sSearch": "Cari:",
"sUrl": "",
"sLoadingRecords": "Memuat...",
"sSearchPlaceholder": "Cari Kata Kunci",
"sDecimal": ",",
"sThousands": "."
});
}
+179
View File
@@ -0,0 +1,179 @@
<?php
/*******************************************************************
Module : /Web/HTMLPrint.php
Desc. : v3 - Class cetak HTML
Created By : Siau Pheng ([email protected]).
Created Date : June 15th, 2008.
Last Modified : May 6th, 2021.
(c) 2008 - 2021, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
declare(strict_types=1);
namespace siaupheng\fonia3\Web;
final class HTMLPrint {
private $__avalue = array();
private $__astyle = array();
private $__atabel = array();
private $__css = "pnormal";
public function __construct() {//
}
public function set_css($style = "") {//
if ($style=="") return;
$this->__css = $style;
}
public function add_field($tnama="", $nlebar=0, $talign="L", $ffunc="", $nkol=1) {//up 2012-03-07
$this->__atabel[] = array($tnama, $nlebar, $ffunc, $talign, $nkol);
}
public function show_fields() {//
$tmp_out = "<tr>";
for ($i=0; $i<count($this->__atabel); $i++) {
if ($this->__atabel[$i][4]==0) continue;
$tmp_out .= $this->set_align($this->__atabel[$i][0], $this->__atabel[$i][1], "C", false, true, $this->__atabel[$i][4]);
}
$tmp_out .= "</tr>";
$this->__avalue[] = $tmp_out;
$this->__astyle[] = "L";
}
public function clear() {//
$this->__avalue = array();
$this->__astyle = array();
}
public function add_value() {//
$tmp_arr = func_get_args();
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0]; //up 2009-09-27
$tmp_out = "<tr>";
for ($i=0; $i<count($this->__atabel); $i++) {
$tmp_val = $tmp_arr[$i];
if (is_array($this->__atabel[$i][2]) && trim($tmp_val)<>"") { //up 2010-05-28
$tmp_val = $this->__atabel[$i][2][$tmp_val];
} else if (function_exists($this->__atabel[$i][2]) && trim($tmp_val)<>"") {
$tmp_val = call_user_func($this->__atabel[$i][2], $tmp_val);
}
$tmp_val = $this->set_align($tmp_val, $this->__atabel[$i][1], $this->__atabel[$i][3]);
$tmp_out .= $tmp_val;
}
$tmp_out .= "</tr>";
$this->__avalue[] = $tmp_out;
$this->__astyle[] = "L";
}
public function add_span() {
$tmp_arr = func_get_args();
$tmp_out = "<tr>";
for ($i=0; $i<count($tmp_arr); $i++) {
$tmp_val = $tmp_arr[$i];// CONTENT, COLSPAN=1, L, FUNC, EXTRA
if (!isset($tmp_val[1])) $tmp_val[1] = 1;
if (!isset($tmp_val[2])) $tmp_val[2] = "L";
if (!isset($tmp_val[4])) $tmp_val[4] = "";
if (isset($tmp_val[3])) {
if (function_exists($tmp_val[3]) && trim($tmp_val[0])<>"") {
$tmp_val[0] = call_user_func($tmp_val[3], $tmp_val[0]);
}
}
$tmp_val = $this->set_align($tmp_val[0], 0, $tmp_val[2], false, false, $tmp_val[1], $tmp_val[4]);
$tmp_out .= $tmp_val;
}
$tmp_out .= "</tr>";
$this->__avalue[] = $tmp_out;
$this->__astyle[] = "L";
}
public function add($ttext = "", $tstyle = "L") {//todo:delete
$this->__avalue[] = $ttext;
$this->__astyle[] = $tstyle;
}
public function addl($ttext = "") {//todo:delete
$this->add($ttext);
}
public function addr($ttext = "") {//todo:delete
$this->add($ttext, "R");
}
public function addc($ttext = "") {//todo:delete
$this->add($ttext, "C");
}
public function add_line() {//todo:delete
$this->add("__LINE ");
}
public function add_empty($nrep = 1) {//todo:delete
for ($i=0;$i<$nrep;$i++) $this->add("&nbsp;");
}
public function add_pagebreak() {//up 2012-10-11
$this->add("</tbody></table><p id=\"linebreak\">................ page break ................</p>", "PB");
$this->add("<p id=\"pagebreak\">&nbsp;</p><table class=\"".$this->__css."\" border=\"0\" width=\"100%\" cellspading=\"0\" cellspacing=\"0\"><tbody>", "PB");
}
public function show_pagebreak() {//del
echo "<p id=\"linebreak\">................ page break ................</p><p id=\"pagebreak\">&nbsp;</p>";
}
public function add_stamp($ctk_ke=1, $bnama=false) {//up 2011-03-25
$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):""), "NB");
}
public function get_stamp($ctk_ke=1, $bnama=false) {//up 2012-10-11
return $_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 show($jumlah_ctk=1) {//up 2012-10-11
$out = "<p id=\"autopage\">&nbsp;</p>";
$out .= "<table class=\"".$this->__css."\" width=\"100%\"><tbody>";
// content out
for ($i=0; $i<count($this->__avalue); $i++) {
$tmp_str = $this->__avalue[$i];
if ($this->__astyle[$i]=="PB") {
$out .= $tmp_str;
continue;
}
if (strpos($tmp_str, "_LINE")>0) $tmp_str = "<hr />";
$out .= $this->set_align($tmp_str, 0, $this->__astyle[$i], true);
}
$out .= "</tbody></table>";
for ($i=1; $i<=$jumlah_ctk; $i++) echo $out;
}
public function set_align($ttext, $nlen, $tdir="L", $bline=false, $bhead=false, $ncol=1, $textra="") {//up 2011-04-14
$tstyle = $this->create_style($tdir);
if (strpos(strtolower($ttext), "<tr>")===false) { //jika tidak ada <tr> up 2011-04-14
if ($bline===true) {
return "<tr><td colspan=\"".count($this->__atabel)."\" class=\"".$tstyle." ".$textra."\">".$ttext."</td></tr>";
} else {
return (($bhead===true)?"<th":"<td").(($ncol>1)?" colspan=\"".$ncol."\"":"")." class=\"".$tstyle." ".$textra."\" ".(($bhead===true)?"width=\"".$nlen."\"":"").">".$ttext.(($bhead===true)?"</th>":"</td>");
}
} else {
return (($bline===true) ? $ttext : (($bhead===true)?"<th":"<td").(($ncol>1)?" colspan=\"".$ncol."\"":"")." class=\"".$tstyle." ".$textra."\" ".(($bhead===true)?"width=\"".$nlen."\"":"").">".$ttext.(($bhead===true)?"</th>":"</td>"));
}
}
private function create_style($tstyle="L") { //up 2014-10-12
// style = Left Right Center No-Border No-Left No-Right Bold Italic
$apad = array("L"=>"left", "R"=>"right", "C"=>"center", "NB"=>"nb", "NL"=>"noleft", "NR"=>"noright", "B"=>"bold", "I"=>"italic");
$_astyle = explode(",", $tstyle);
$thasil = "";
foreach ($_astyle as $_key => $_val) {
$thasil .= " ".$apad[$_val];
}
return substr($thasil,1);
}
}
?>
+153
View File
@@ -0,0 +1,153 @@
<?php
/*******************************************************************
Module : /Web/POSPrint.php
Desc. : v3 - Class cetak POS
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : June 15th, 2008.
Last Modified : May 6th, 2021.
(c) 2008 - 2021, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
declare(strict_types=1);
namespace siaupheng\fonia3\Web;
/* VERSI BARU DENGAN MULTI SHEET */
class POSPrint {//up: 20180108
private $_header = array();
private $_avalue = array();
private $_astyle = array();
private $_ncont = 0;
private $_maxchr = 40;
private $_config = array(
'fontsize' => 1,
'nvlogo' => false,
'opendraw' => false,
'opendrawbegin' => true,
'cutpaper' => false,
'logo' => null );
public function __construct() {
}
public function set_opendrawer($bbegin = true) {
$this->_config['opendraw'] = true;
$this->_config['opendrawbegin'] = $bbegin;
}
public function set_cutpaper() {
$this->_config['cutpaper'] = true;
}
public function set_maxchr($nmax = 0) {//up: 2015-03-22
if ($nmax > 0) $this->_maxchr = $nmax;
}
public function set_fontsize($nsize = 1) {//up: 2015-09-30
if ($nsize > 0) $this->_config['fontsize'] = $nsize;
}
public function set_printnv_logo() {//up: 2015-03-23
$this->_config['nvlogo'] = true;
}
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 add_header($nvlogo = false, $extra = array()) {//up: 2018-12-25
$this->_config['nvlogo'] = $nvlogo;
if ($nvlogo==false && $this->_config['logo']==null) $this->_header[] = $_SESSION['__WEB_APP']['REG_NAME'];
if (count($extra) > 0) {
foreach ($extra as $_val) {
$this->_header[] = $_val;
}
}
$this->_header[] = $_SESSION['__WEB_APP']['REG_CITY'];
}
public function add_sheet() {//up: 20170321
$this->_ncont++;
}
public function add() {//up: 20180524
$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));
}
} else {
$ttext = (isset($val_arr[0])) ? $val_arr[0] : "";
$tstyle = (isset($val_arr[1])) ? $val_arr[1] : $tstyle;
}
$this->_avalue[$this->_ncont][] = $ttext;
$this->_astyle[$this->_ncont][] = $tstyle;
}
public function addl($ttext = "") {
$this->add($ttext);
}
public function addr($ttext = "") {
$this->add($ttext, "R");
}
public function addc($ttext = "") {
$this->add($ttext, "C");
}
public function add_line($tmp = "-") {
$this->add("__LINE ".$tmp);
}
public function add_empty($nrep = 1) {
for ($i=0;$i<$nrep;$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):""));
}
private function _json_out() {//up: 2016-11-12
$acontent = array();
$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]);
}
}
$aout = array('type' => "escp");
$aout['config'] = $this->_config;
$aout['header'] = $this->_header;
$aout['content'] = $acontent;
send_json($aout);
}
public function show($jumlah_ctk=1) {
$this->_config['times'] = $jumlah_ctk;
$this->_json_out();
}
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]);
}
}
?>
-451
View File
@@ -1,451 +0,0 @@
<?php
/*******************************************************************
Module : /Web/Printer.php
Desc. : v3 - Class cetak
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : June 15th, 2008.
Last Modified : May 6th, 2021.
(c) 2008 - 2021, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
declare(strict_types=1);
namespace siaupheng\fonia3\Web;
final class Print {
private $__avalue = array();
private $__astyle = array();
private $__atabel = array();
private $__css = "pnormal";
public function __construct() {//
}
public function set_css($style = "") {//
if ($style=="") return;
$this->__css = $style;
}
public function add_field($tnama="", $nlebar=0, $talign="L", $ffunc="", $nkol=1) {//up 2012-03-07
$this->__atabel[] = array($tnama, $nlebar, $ffunc, $talign, $nkol);
}
public function show_fields() {//
$tmp_out = "<tr>";
for ($i=0; $i<count($this->__atabel); $i++) {
if ($this->__atabel[$i][4]==0) continue;
$tmp_out .= $this->set_align($this->__atabel[$i][0], $this->__atabel[$i][1], "C", false, true, $this->__atabel[$i][4]);
}
$tmp_out .= "</tr>";
$this->__avalue[] = $tmp_out;
$this->__astyle[] = "L";
}
public function clear() {//
$this->__avalue = array();
$this->__astyle = array();
}
public function add_value() {//
$tmp_arr = func_get_args();
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0]; //up 2009-09-27
$tmp_out = "<tr>";
for ($i=0; $i<count($this->__atabel); $i++) {
$tmp_val = $tmp_arr[$i];
if (is_array($this->__atabel[$i][2]) && trim($tmp_val)<>"") { //up 2010-05-28
$tmp_val = $this->__atabel[$i][2][$tmp_val];
} else if (function_exists($this->__atabel[$i][2]) && trim($tmp_val)<>"") {
$tmp_val = call_user_func($this->__atabel[$i][2], $tmp_val);
}
$tmp_val = $this->set_align($tmp_val, $this->__atabel[$i][1], $this->__atabel[$i][3]);
$tmp_out .= $tmp_val;
}
$tmp_out .= "</tr>";
$this->__avalue[] = $tmp_out;
$this->__astyle[] = "L";
}
public function add_span() {
$tmp_arr = func_get_args();
$tmp_out = "<tr>";
for ($i=0; $i<count($tmp_arr); $i++) {
$tmp_val = $tmp_arr[$i];// CONTENT, COLSPAN=1, L, FUNC, EXTRA
if (!isset($tmp_val[1])) $tmp_val[1] = 1;
if (!isset($tmp_val[2])) $tmp_val[2] = "L";
if (!isset($tmp_val[4])) $tmp_val[4] = "";
if (isset($tmp_val[3])) {
if (function_exists($tmp_val[3]) && trim($tmp_val[0])<>"") {
$tmp_val[0] = call_user_func($tmp_val[3], $tmp_val[0]);
}
}
$tmp_val = $this->set_align($tmp_val[0], 0, $tmp_val[2], false, false, $tmp_val[1], $tmp_val[4]);
$tmp_out .= $tmp_val;
}
$tmp_out .= "</tr>";
$this->__avalue[] = $tmp_out;
$this->__astyle[] = "L";
}
public function add($ttext = "", $tstyle = "L") {//todo:delete
$this->__avalue[] = $ttext;
$this->__astyle[] = $tstyle;
}
public function addl($ttext = "") {//todo:delete
$this->add($ttext);
}
public function addr($ttext = "") {//todo:delete
$this->add($ttext, "R");
}
public function addc($ttext = "") {//todo:delete
$this->add($ttext, "C");
}
public function add_line() {//todo:delete
$this->add("__LINE ");
}
public function add_empty($nrep = 1) {//todo:delete
for ($i=0;$i<$nrep;$i++) $this->add("&nbsp;");
}
public function add_pagebreak() {//up 2012-10-11
$this->add("</tbody></table><p id=\"linebreak\">................ page break ................</p>", "PB");
$this->add("<p id=\"pagebreak\">&nbsp;</p><table class=\"".$this->__css."\" border=\"0\" width=\"100%\" cellspading=\"0\" cellspacing=\"0\"><tbody>", "PB");
}
public function show_pagebreak() {//del
echo "<p id=\"linebreak\">................ page break ................</p><p id=\"pagebreak\">&nbsp;</p>";
}
public function add_stamp($ctk_ke=1, $bnama=false) {//up 2011-03-25
$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):""), "NB");
}
public function get_stamp($ctk_ke=1, $bnama=false) {//up 2012-10-11
return $_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 show($jumlah_ctk=1) {//up 2012-10-11
$out = "<p id=\"autopage\">&nbsp;</p>";
$out .= "<table class=\"".$this->__css."\" width=\"100%\"><tbody>";
// content out
for ($i=0; $i<count($this->__avalue); $i++) {
$tmp_str = $this->__avalue[$i];
if ($this->__astyle[$i]=="PB") {
$out .= $tmp_str;
continue;
}
if (strpos($tmp_str, "_LINE")>0) $tmp_str = "<hr />";
$out .= $this->set_align($tmp_str, 0, $this->__astyle[$i], true);
}
$out .= "</tbody></table>";
for ($i=1; $i<=$jumlah_ctk; $i++) echo $out;
}
public function set_align($ttext, $nlen, $tdir="L", $bline=false, $bhead=false, $ncol=1, $textra="") {//up 2011-04-14
$tstyle = $this->create_style($tdir);
if (strpos(strtolower($ttext), "<tr>")===false) { //jika tidak ada <tr> up 2011-04-14
if ($bline===true) {
return "<tr><td colspan=\"".count($this->__atabel)."\" class=\"".$tstyle." ".$textra."\">".$ttext."</td></tr>";
} else {
return (($bhead===true)?"<th":"<td").(($ncol>1)?" colspan=\"".$ncol."\"":"")." class=\"".$tstyle." ".$textra."\" ".(($bhead===true)?"width=\"".$nlen."\"":"").">".$ttext.(($bhead===true)?"</th>":"</td>");
}
} else {
return (($bline===true) ? $ttext : (($bhead===true)?"<th":"<td").(($ncol>1)?" colspan=\"".$ncol."\"":"")." class=\"".$tstyle." ".$textra."\" ".(($bhead===true)?"width=\"".$nlen."\"":"").">".$ttext.(($bhead===true)?"</th>":"</td>"));
}
}
private function create_style($tstyle="L") { //up 2014-10-12
// style = Left Right Center No-Border No-Left No-Right Bold Italic
$apad = array("L"=>"left", "R"=>"right", "C"=>"center", "NB"=>"nb", "NL"=>"noleft", "NR"=>"noright", "B"=>"bold", "I"=>"italic");
$_astyle = explode(",", $tstyle);
$thasil = "";
foreach ($_astyle as $_key => $_val) {
$thasil .= " ".$apad[$_val];
}
return substr($thasil,1);
}
}
class RawPrint {
private $_header = array();
private $_avalue = array();
private $_atabel = array();
private $_ncont = 0;
private $_maxchr = 40;
private $_spacekol = " ";
private $_config = array(
'fontsize' => "01",
'nvlogo' => false,
'opendraw' => false,
'opendrawbegin' => false,
'cutpaper' => false );
public function __construct() {
}
public function set_opendrawer($bbegin = true) {
$this->_config['opendraw'] = true;
$this->_config['opendrawbegin'] = $bbegin;
}
public function set_cutpaper() {
$this->_config['cutpaper'] = true;
}
public function set_maxchr($nmax = 0) {//up: 2015-03-22
if ($nmax > 0) $this->_maxchr = $nmax;
}
public function set_fontsize($nsize = 1) {//up: 2015-09-30
if ($nsize > 0) $this->_config['fontsize'] = str_pad($nsize, 2, "0", STR_PAD_LEFT);
}
public function set_printnv_logo() {//up: 2015-03-23
$this->_config['nvlogo'] = true;
}
public function add_header($nvlogo = false, $extra = array()) {//up: 2016-11-12
$this->_config['nvlogo'] = $nvlogo;
$this->_header[] = $_SESSION['__WEB_APP']['REG_NAME'];
if (count($extra) > 0) {
foreach ($extra as $_val) {
$this->_header[] = $_val;
}
}
$this->_header[] = $_SESSION['__WEB_APP']['REG_CITY'];
}
public function add_sheet() {//up: 20170321
$this->_ncont++;
}
public function add_field($tnama="", $nlebar=0, $talign="L", $ffunc="") {
$this->_atabel[] = array($tnama, $nlebar, $ffunc, $talign);
}
public function show_fields() {
$tmp_out = "<b>";
for ($i=0; $i<count($this->_atabel); $i++) {
$tmp_out .= $this->set_align($this->_atabel[$i][0], $this->_atabel[$i][1], "C");
if ($i < (count($this->_atabel)-1)) $tmp_out .= $this->_spacekol;
}
$tmp_out .= "</b>";
$this->_avalue[$this->_ncont][] = "__LINE -";
$this->_avalue[$this->_ncont][] = $tmp_out;
$this->_avalue[$this->_ncont][] = "__LINE -";
}
public function add_value() {
$tmp_arr = func_get_args();
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0]; //up 2009-09-27
$tmp_out = "";
for ($i=0; $i<count($this->_atabel); $i++) {
$tmp_val = $tmp_arr[$i];
if (is_array($this->_atabel[$i][2]) && trim($tmp_val)<>"") { //up 2010-05-28
$tmp_val = $this->_atabel[$i][2][$tmp_val];
} else if (function_exists($this->_atabel[$i][2]) && trim($tmp_val)<>"") {
$tmp_val = call_user_func($this->_atabel[$i][2], $tmp_val);
}
$tmp_val = $this->set_align($tmp_val, $this->_atabel[$i][1], $this->_atabel[$i][3]);
if ($i < (count($this->_atabel)-1)) $tmp_val .= $this->_spacekol;
$tmp_out .= $tmp_val;
}
$this->_avalue[$this->_ncont][] = $tmp_out;
}
public function add($ttext = "") {
$this->_avalue[$this->_ncont][] = $ttext;
}
public function add_line($tmp = "-") {
$this->add("__LINE ".$tmp);
}
public function add_empty($nrep = 1) {
for ($i=0;$i<$nrep;$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):""));
}
private function _json_out() {//up: 2016-11-12
$acontent = array();
$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][] = $tmp_str;
}
}
$aout = array('type' => "escp");
$aout['config'] = $this->_config;
$aout['header'] = $this->_header;
$aout['content'] = $acontent;
send_json($aout);
}
public function show($jumlah_ctk=1) {
$this->_config['times'] = $jumlah_ctk;
$this->_json_out();
}
public function set_align($ttext, $nlen, $tdir="L") {
$apad = array("L"=>STR_PAD_RIGHT, "R"=>STR_PAD_LEFT, "C"=>STR_PAD_BOTH);
$ttext = (strlen($ttext)>$nlen) ? substr($ttext, 0, $nlen) : $ttext;
return str_pad($ttext, $nlen, " ", $apad[$tdir]);
}
}
/* VERSI BARU DENGAN MULTI SHEET */
class POSPrint {//up: 20180108
private $_header = array();
private $_avalue = array();
private $_astyle = array();
private $_ncont = 0;
private $_maxchr = 40;
private $_config = array(
'fontsize' => 1,
'nvlogo' => false,
'opendraw' => false,
'opendrawbegin' => true,
'cutpaper' => false,
'logo' => null );
public function __construct() {
}
public function set_opendrawer($bbegin = true) {
$this->_config['opendraw'] = true;
$this->_config['opendrawbegin'] = $bbegin;
}
public function set_cutpaper() {
$this->_config['cutpaper'] = true;
}
public function set_maxchr($nmax = 0) {//up: 2015-03-22
if ($nmax > 0) $this->_maxchr = $nmax;
}
public function set_fontsize($nsize = 1) {//up: 2015-09-30
if ($nsize > 0) $this->_config['fontsize'] = $nsize;
}
public function set_printnv_logo() {//up: 2015-03-23
$this->_config['nvlogo'] = true;
}
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 add_header($nvlogo = false, $extra = array()) {//up: 2018-12-25
$this->_config['nvlogo'] = $nvlogo;
if ($nvlogo==false && $this->_config['logo']==null) $this->_header[] = $_SESSION['__WEB_APP']['REG_NAME'];
if (count($extra) > 0) {
foreach ($extra as $_val) {
$this->_header[] = $_val;
}
}
$this->_header[] = $_SESSION['__WEB_APP']['REG_CITY'];
}
public function add_sheet() {//up: 20170321
$this->_ncont++;
}
public function add() {//up: 20180524
$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));
}
} else {
$ttext = (isset($val_arr[0])) ? $val_arr[0] : "";
$tstyle = (isset($val_arr[1])) ? $val_arr[1] : $tstyle;
}
$this->_avalue[$this->_ncont][] = $ttext;
$this->_astyle[$this->_ncont][] = $tstyle;
}
public function addl($ttext = "") {
$this->add($ttext);
}
public function addr($ttext = "") {
$this->add($ttext, "R");
}
public function addc($ttext = "") {
$this->add($ttext, "C");
}
public function add_line($tmp = "-") {
$this->add("__LINE ".$tmp);
}
public function add_empty($nrep = 1) {
for ($i=0;$i<$nrep;$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):""));
}
private function _json_out() {//up: 2016-11-12
$acontent = array();
$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]);
}
}
$aout = array('type' => "escp");
$aout['config'] = $this->_config;
$aout['header'] = $this->_header;
$aout['content'] = $acontent;
send_json($aout);
}
public function show($jumlah_ctk=1) {
$this->_config['times'] = $jumlah_ctk;
$this->_json_out();
}
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]);
}
}
?>
+157
View File
@@ -0,0 +1,157 @@
<?php
/*******************************************************************
Module : /Web/RAWPrint.php
Desc. : v3 - Class cetak RAW
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : June 15th, 2008.
Last Modified : May 6th, 2021.
(c) 2008 - 2021, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
declare(strict_types=1);
namespace siaupheng\fonia3\Web;
class RAWPrint {
private $_header = array();
private $_avalue = array();
private $_atabel = array();
private $_ncont = 0;
private $_maxchr = 40;
private $_spacekol = " ";
private $_config = array(
'fontsize' => "01",
'nvlogo' => false,
'opendraw' => false,
'opendrawbegin' => false,
'cutpaper' => false );
public function __construct() {
}
public function set_opendrawer($bbegin = true) {
$this->_config['opendraw'] = true;
$this->_config['opendrawbegin'] = $bbegin;
}
public function set_cutpaper() {
$this->_config['cutpaper'] = true;
}
public function set_maxchr($nmax = 0) {//up: 2015-03-22
if ($nmax > 0) $this->_maxchr = $nmax;
}
public function set_fontsize($nsize = 1) {//up: 2015-09-30
if ($nsize > 0) $this->_config['fontsize'] = str_pad($nsize, 2, "0", STR_PAD_LEFT);
}
public function set_printnv_logo() {//up: 2015-03-23
$this->_config['nvlogo'] = true;
}
public function add_header($nvlogo = false, $extra = array()) {//up: 2016-11-12
$this->_config['nvlogo'] = $nvlogo;
$this->_header[] = $_SESSION['__WEB_APP']['REG_NAME'];
if (count($extra) > 0) {
foreach ($extra as $_val) {
$this->_header[] = $_val;
}
}
$this->_header[] = $_SESSION['__WEB_APP']['REG_CITY'];
}
public function add_sheet() {//up: 20170321
$this->_ncont++;
}
public function add_field($tnama="", $nlebar=0, $talign="L", $ffunc="") {
$this->_atabel[] = array($tnama, $nlebar, $ffunc, $talign);
}
public function show_fields() {
$tmp_out = "<b>";
for ($i=0; $i<count($this->_atabel); $i++) {
$tmp_out .= $this->set_align($this->_atabel[$i][0], $this->_atabel[$i][1], "C");
if ($i < (count($this->_atabel)-1)) $tmp_out .= $this->_spacekol;
}
$tmp_out .= "</b>";
$this->_avalue[$this->_ncont][] = "__LINE -";
$this->_avalue[$this->_ncont][] = $tmp_out;
$this->_avalue[$this->_ncont][] = "__LINE -";
}
public function add_value() {
$tmp_arr = func_get_args();
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0]; //up 2009-09-27
$tmp_out = "";
for ($i=0; $i<count($this->_atabel); $i++) {
$tmp_val = $tmp_arr[$i];
if (is_array($this->_atabel[$i][2]) && trim($tmp_val)<>"") { //up 2010-05-28
$tmp_val = $this->_atabel[$i][2][$tmp_val];
} else if (function_exists($this->_atabel[$i][2]) && trim($tmp_val)<>"") {
$tmp_val = call_user_func($this->_atabel[$i][2], $tmp_val);
}
$tmp_val = $this->set_align($tmp_val, $this->_atabel[$i][1], $this->_atabel[$i][3]);
if ($i < (count($this->_atabel)-1)) $tmp_val .= $this->_spacekol;
$tmp_out .= $tmp_val;
}
$this->_avalue[$this->_ncont][] = $tmp_out;
}
public function add($ttext = "") {
$this->_avalue[$this->_ncont][] = $ttext;
}
public function add_line($tmp = "-") {
$this->add("__LINE ".$tmp);
}
public function add_empty($nrep = 1) {
for ($i=0;$i<$nrep;$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):""));
}
private function _json_out() {//up: 2016-11-12
$acontent = array();
$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][] = $tmp_str;
}
}
$aout = array('type' => "escp");
$aout['config'] = $this->_config;
$aout['header'] = $this->_header;
$aout['content'] = $acontent;
send_json($aout);
}
public function show($jumlah_ctk=1) {
$this->_config['times'] = $jumlah_ctk;
$this->_json_out();
}
public function set_align($ttext, $nlen, $tdir="L") {
$apad = array("L"=>STR_PAD_RIGHT, "R"=>STR_PAD_LEFT, "C"=>STR_PAD_BOTH);
$ttext = (strlen($ttext)>$nlen) ? substr($ttext, 0, $nlen) : $ttext;
return str_pad($ttext, $nlen, " ", $apad[$tdir]);
}
}
?>