upgrade htmlprint

This commit is contained in:
2023-10-13 16:07:05 +07:00
parent 06e524f9b3
commit a6ce730088
+26 -38
View File
@@ -6,9 +6,9 @@
Desc. : v4 - Class cetak HTML Desc. : v4 - Class cetak HTML
Created By : Siau Pheng ([email protected]). Created By : Siau Pheng ([email protected]).
Created Date : June 15th, 2008. Created Date : June 15th, 2008.
Last Modified : May 6th, 2021. Last Modified : October 13th, 2023.
(c) 2008 - 2021, 3FONIA Software; WWW.3FONIA.COM. (c) 2008 - 2023, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/ *******************************************************************/
@@ -17,24 +17,24 @@ declare(strict_types=1);
namespace siaupheng\fonia3\Web; namespace siaupheng\fonia3\Web;
final class HTMLPrint { final class HTMLPrint {
private $__avalue = array(); private $__avalue = [];
private $__astyle = array(); private $__atabel = [];
private $__atabel = array();
private $__css = "table"; private $__css = "table";
private $__tstamp = "";
public function __construct() {// public function __construct() {
} }
public function set_css($style = "") {// public function set_css($style = "") {
if ($style=="") return; if ($style=="") return;
$this->__css = $style; $this->__css = $style;
} }
public function add_field($tnama="", $nlebar=0, $talign="L", $ffunc="", $nkol=1) {//up 2012-03-07 public function add_field($tnama="", $nlebar=0, $talign="L", $ffunc="", $nkol=1) {//up 2012-03-07
$this->__atabel[] = array($tnama, $nlebar, $ffunc, $talign, $nkol); $this->__atabel[] = [$tnama, $nlebar, $ffunc, $talign, $nkol];
} }
public function show_fields() {// public function show_fields() {
$tmp_out = "<tr>"; $tmp_out = "<tr>";
for ($i=0; $i<count($this->__atabel); $i++) { for ($i=0; $i<count($this->__atabel); $i++) {
if ($this->__atabel[$i][4]==0) continue; if ($this->__atabel[$i][4]==0) continue;
@@ -42,15 +42,13 @@ final class HTMLPrint {
} }
$tmp_out .= "</tr>"; $tmp_out .= "</tr>";
$this->__avalue[] = $tmp_out; $this->__avalue[] = $tmp_out;
$this->__astyle[] = "L";
} }
public function clear() {// public function clear() {
$this->__avalue = array(); $this->__avalue = [];
$this->__astyle = array();
} }
public function add_value() {// public function add_value() {
$tmp_arr = func_get_args(); $tmp_arr = func_get_args();
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0]; //up 2009-09-27 if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0]; //up 2009-09-27
$tmp_out = "<tr>"; $tmp_out = "<tr>";
@@ -66,7 +64,6 @@ final class HTMLPrint {
} }
$tmp_out .= "</tr>"; $tmp_out .= "</tr>";
$this->__avalue[] = $tmp_out; $this->__avalue[] = $tmp_out;
$this->__astyle[] = "L";
} }
public function add_span() { public function add_span() {
@@ -87,16 +84,10 @@ final class HTMLPrint {
} }
$tmp_out .= "</tr>"; $tmp_out .= "</tr>";
$this->__avalue[] = $tmp_out; $this->__avalue[] = $tmp_out;
$this->__astyle[] = "L";
} }
public function add_pagebreak() {//up 2012-10-11 public function add_stamp($ctk_ke=1, $bnama=false) {//up 2023-10-13
$this->add("</tbody></table><p id=\"linebreak\">................ page break ................</p>", "PB"); $this->__tstamp = $this->get_stamp($ctk_ke, $bnama);
$this->add("<p id=\"pagebreak\">&nbsp;</p><table class=\"".$this->__css."\" border=\"0\" width=\"100%\" cellspading=\"0\" cellspacing=\"0\"><tbody>", "PB");
}
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 public function get_stamp($ctk_ke=1, $bnama=false) {//up 2012-10-11
@@ -104,40 +95,35 @@ final class HTMLPrint {
} }
public function show($jumlah_ctk=1) {//up 2012-10-11 public function show($jumlah_ctk=1) {//up 2012-10-11
$out = "<p id=\"autopage\">&nbsp;</p>"; $out = "<table class=\"".$this->__css."\"><tbody>";
$out .= "<table class=\"".$this->__css."\" width=\"100%\"><tbody>";
// header out
// not yet !!
// content out // content out
for ($i=0; $i<count($this->__avalue); $i++) { for ($i=0; $i<count($this->__avalue); $i++) {
$tmp_str = $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 />"; if (strpos($tmp_str, "_LINE")>0) $tmp_str = "<hr />";
$out .= $this->set_align($tmp_str, 0, $this->__astyle[$i], true); $out .= $tmp_str;
} }
$out .= "</tbody></table>"; $out .= "</tbody></table>";
$out .= $this->__tstamp;
for ($i=1; $i<=$jumlah_ctk; $i++) echo $out; 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 public function set_align($ttext, $nlen, $tdir="L", $bline=false, $bhead=false, $ncol=1, $textra="") {//up 2011-04-14
$tstyle = $this->create_style($tdir); $tstyle = $this->create_style($tdir);
if (strpos(strtolower("".$ttext), "<tr>")===false) { //jika tidak ada <tr> up 2011-04-14 if ($bline===true) {
if ($bline===true) { return "<tr><td colspan=\"".count($this->__atabel)."\" class=\"".$tstyle." ".$textra."\">".$ttext."</td></tr>";
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 { } 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>")); return (($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 private function create_style($tstyle="L") { //up 2014-10-12
// style = Left Right Center No-Border No-Left No-Right Bold Italic // style = Left Right Center No-Border No-Left No-Right Bold Italic
$apad = array("L"=>"l", "R"=>"r", "C"=>"c", "NB"=>"nb", "NL"=>"noleft", "NR"=>"noright", "B"=>"b", "I"=>"i"); $apad = ["L"=>"l", "R"=>"r", "C"=>"c", "NB"=>"nb", "NL"=>"noleft", "NR"=>"noright", "B"=>"b", "I"=>"i"];
$_astyle = explode(",", $tstyle); $_astyle = explode(",", $tstyle);
$thasil = ""; $thasil = "";
foreach ($_astyle as $_key => $_val) { foreach ($_astyle as $_key => $_val) {
@@ -145,6 +131,8 @@ final class HTMLPrint {
} }
return substr($thasil,1); return substr($thasil,1);
} }
public function add_pagebreak() {}//delete: not used anymore
} }
?> ?>