185 lines
9.2 KiB
PHP
185 lines
9.2 KiB
PHP
<?php
|
|
|
|
/*******************************************************************
|
|
|
|
PHP Class : /Controller/MonitorController
|
|
Description : Halaman Utama Display Monitor
|
|
Created By : Siau Pheng ([email protected]).
|
|
Created Date : May 24th, 2010.
|
|
Last Modified : October 20th, 2026.
|
|
|
|
(c) 3FONIA Software; WWW.3FONIA.COM.
|
|
|
|
*******************************************************************/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Controller;
|
|
|
|
use flight\Engine;
|
|
use flight\Session;
|
|
use flight\database\SimplePdo;
|
|
|
|
class MonitorController {
|
|
|
|
private array $web_app;
|
|
private int $id_cab;
|
|
protected Engine $app;
|
|
protected SimplePdo $db;
|
|
|
|
public function __construct(Engine $app, Session $session, SimplePdo $db) {
|
|
$this->app = $app;
|
|
$this->db = $db;
|
|
$this->web_app = $session->get('WEB_APP');
|
|
$this->id_cab = (int) $session->get('APP_INV')['CABANGID'];
|
|
}
|
|
|
|
public function info_iklan() {
|
|
$info_iklan = '<div class="carousel-inner">'; $iklan = 0;
|
|
$query = $this->db->runQuery("SELECT * FROM disp_promo WHERE Aktif=1 AND Tipe=2 AND CabID IN (?) AND Image IS NOT NULL ORDER BY Tanggal", [[0,$this->id_cab]]);
|
|
while ($row = $query->fetch(SimplePdo::FETCH_ASSOC)) {
|
|
$info_iklan .= '<div class="carousel-item'.($iklan==0?' active':'').'"><img src="data:'.$row['Mime'].';base64,'.base64_encode($row['Image']).'" class="m-auto d-block"></div>';
|
|
$iklan++;
|
|
}
|
|
if ($iklan == 0) $info_iklan .= '<div class="carousel-item active"><img src="'.PROJECT_BASE.'/assets/images/logo600.png" class="m-auto d-block"></div>';
|
|
$info_iklan .= '</div>';
|
|
$this->app->json([ 'html' => $info_iklan ]);
|
|
}
|
|
|
|
public function info_promo() {
|
|
$info_promo = '<div class="carousel-inner">'; $promo = 0;
|
|
$query = $this->db->runQuery("SELECT * FROM disp_promo WHERE Aktif=1 AND Tipe=1 AND CabID IN (?) ORDER BY Tanggal, PromoID", [[0, $this->id_cab]]);
|
|
while ($row = $query->fetch(SimplePdo::FETCH_ASSOC)) {
|
|
$_text = str_replace(["[br]","[i]","[/i]","[b]","[/b]"], ["<br/>","<i>","</i>","<b>","</b>"], $row['Info']);
|
|
$_text = '<span style="color:'.$row['Warna'].';font-size:'.$row['Font'].'pt;">' . $_text . '</span>';
|
|
if (!empty($row['Image'])) {
|
|
$_text = '<div class="row h-100 align-items-center"><div class="col-2 text-center"><img src="data:'.$row['Mime'].';base64,'.base64_encode($row['Image']).'" class="pt-2"></div><div class="col-10">' . $_text ."</div></div>";
|
|
}
|
|
$info_promo .= '<div class="carousel-item'.($promo==0?' active':'').'">'.$_text."</div>";
|
|
$promo++;
|
|
}
|
|
$info_promo .= "</div>";
|
|
$this->app->json([ 'html' => $info_promo ]);
|
|
}
|
|
|
|
public function count_delay() { //todo: ganti ke socket-io
|
|
$apos = $this->get_pos();
|
|
$ajson = [];
|
|
$ajson['total'] = $this->db->fetchField("SELECT SUM(-Qty*(Harga_Jual-Disk_Rupiah)) Total FROM tmp_inv_detail WHERE No_Ref=? AND Unix=?", [$apos['No_Pos'], $apos['Unix']]) ?? 0;
|
|
$ajson['thank'] = $this->db->fetchField("SELECT IF(No_Cetak='',0,1) Ada FROM disp_login WHERE UserID=? AND Unix=?", [$apos['UserID'], $apos['Unix']]) ?? 0;
|
|
$this->app->json($ajson);
|
|
}
|
|
|
|
public function shop() {
|
|
$this->app->json(['html' => '
|
|
<div class="row g-0 my-2">
|
|
<div class="col-7 pe-3 text-end" id="Info_Barang">
|
|
</div>
|
|
<div class="col-5 pe-2">
|
|
<div class="border border-success border-opacity-75 rounded rounded-4 bg-warning bg-gradient" style="--bs-bg-opacity:.75;">
|
|
<div class="row pe-2">
|
|
<div class="col-4 fs-3 d-flex align-items-center justify-content-end" id="Info_Qty"></div>
|
|
<div class="col-8 display-1 fw-light d-flex align-items-center justify-content-end border-light border-start" id="Total_Harga">0</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>'
|
|
]);
|
|
}
|
|
|
|
public function info_shop() {
|
|
$apos = $this->get_pos();
|
|
$ashop = ['Total'=>0, 'Item'=>0, 'Qty'=>0];
|
|
$row = $this->db->fetchRow("SELECT SUM(-Qty*(Harga_Jual-Disk_Rupiah)) Total,COUNT(*) Item, SUM(-Qty) Qty FROM tmp_inv_detail WHERE No_Ref=? AND Unix=?", [$apos['No_Pos'], $apos['Unix']]);
|
|
if ($row) $ashop = $row->getData();
|
|
|
|
$info_barang = '<img src="'.PROJECT_BASE.'assets/images/logo60.png">';
|
|
if ($ashop['Item'] > 0) {
|
|
$row = $this->db->fetchRow("SELECT * FROM (SELECT -D.Qty Qty2,D.Harga_Jual,P.Nama_Lengkap FROM tmp_inv_detail D LEFT JOIN vi_inv_produk P ON (D.InvID=P.InvID AND D.SatuanID=P.SatuanID) WHERE D.No_Ref=? AND D.Unix=? AND D.Promo<2 ORDER BY D.ID DESC LIMIT 1) A", [$apos['No_Pos'], $apos['Unix']]);
|
|
if ($row) {
|
|
$info_barang = '<div class="display-4 fw-light">'.substr($row['Nama_Lengkap'], 0, 26).'</div><div class="fs-4">Qty : '.rupiah($row['Qty2']).' / Rp. '.rupiah($row['Harga_Jual']).'</div>';
|
|
}
|
|
}
|
|
|
|
$ajson['Info_Barang'] = $info_barang;
|
|
$ajson['Total_Harga'] = rupiah($ashop['Total']);
|
|
$ajson['Info_Qty'] = rupiah($ashop['Item'])." Items<br>".rupiah($ashop['Qty'])." Qty";
|
|
$this->app->json($ajson);
|
|
}
|
|
|
|
public function thank() {
|
|
$apos = $this->get_pos();
|
|
$anota = $this->db->fetchRow("SELECT J.*,(J.Total_Bayar-J.Total_Jual+J.Total_Diskon+J.Total_Potong) Total_Sisa,UCASE(LEFT(B.Nama_Kartu,23)) Kode_Kartu2,UCASE(J.Nama_Kartu) Nama_Kartu2,RIGHT(J.No_Kartu,4) No_Kartu2 FROM inv_jual J LEFT JOIN para_rek_pos B ON (J.KartuID=B.KartuID) WHERE J.No_Jual=?", [$apos['No_Cetak']]);
|
|
$html = '
|
|
<div class="row">
|
|
<div class="col-6 text-center">
|
|
<img class="img-fluid mt-5" src="'.PROJECT_BASE.'assets/images/logo300.png" alt="'.$this->web_app['REG_NAME'].'">
|
|
</div>
|
|
<div class="col-6 fs-2 text-center">
|
|
';
|
|
if ($anota) {
|
|
$nhemat = $anota['Total_Diskon'] + $anota['Total_Potong'];
|
|
|
|
$html .= 'Jumlah Belanja Anda Rp. '.rupiah($anota['Total_Jual']-$anota['Total_Diskon']).'<br>';
|
|
if ($anota['Total_Diskon'] > 0) $html .= '<i>Anda Mendapatkan Diskon Rp. '.rupiah($anota['Total_Diskon']).'</i><br>';
|
|
if ($anota['Total_Potong'] > 0) $html .= '<i>Anda Mendapatkan Potongan Promo Rp. '.rupiah($anota['Total_Potong']).'</i><br>';
|
|
|
|
$html .= 'Jumlah Pembayaran Anda Rp. '.rupiah($anota['Total_Bayar']).'<br><br>';
|
|
|
|
if ($anota['KartuID'] === 0) {
|
|
$html .= '<span style="font-size:23pt;color:red;">Sisa Pembayaran Rp. '.rupiah($anota['Total_Sisa']).'</span><br>';
|
|
} else {
|
|
$html .= '<b>Anda Melakukan Pembayaran Dengan : <br>'.$anota['Kode_Kartu2']." - ".$anota['No_Kartu2'].'</b><br>';
|
|
}
|
|
|
|
if ($nhemat > 0) $html .= '<span style="font-size:18pt;color:orange;"><i>Anda Mendapatkan Penghematan Sebesar Rp. '.rupiah($nhemat).'</span></i><br>';
|
|
}
|
|
$html .= '<br>Terima Kasih Telah Berbelanja di Toko Kami<br>Selamat Berbelanja Kembali :)</div></div>';
|
|
$this->app->json([ 'html' => $html ]);
|
|
}
|
|
|
|
public function close_thank() {
|
|
$apos = $this->get_pos();
|
|
$this->db->runQuery("UPDATE disp_login SET No_Cetak='' WHERE UserID=? AND Unix=?", [$apos['UserID'], $apos['Unix']]);
|
|
}
|
|
|
|
public function config() {
|
|
$ajson = ['BANNER_TEXT' => "", 'PROMO_IDLE' => 0, 'PROMO_DURASI' => 1000];
|
|
$ainfo = $this->db->fetchRow("SELECT * FROM disp_config WHERE REG_ID=?", [$this->web_app['REG_ID']]);
|
|
if ($ainfo) {
|
|
$ajson['BANNER_TEXT'] = '<div class="marquee-content" style="color:'.$ainfo['Warna'].';font-size:'.$ainfo['Font'].'pt;">'.$ainfo['Text_Run'].'</div>';
|
|
$ajson['PROMO_IDLE'] = $ainfo['Promo_Idle'];
|
|
$ajson['PROMO_DURASI'] = (int) $ainfo['Promo_Durasi'] * 1000;
|
|
$ajson['ID_CABANG'] = $this->id_cab;
|
|
}
|
|
$this->app->json($ajson);
|
|
}
|
|
|
|
public function index() {
|
|
$this->app->json(['html' => '
|
|
<div class="disp-atas overflow-hidden fixed-top">
|
|
<div class="marquee-container overflow-hidden bg-light shadow-sm d-flex align-items-center" id="divBanner"></div>
|
|
<div id="divShop"> </div>
|
|
</div>
|
|
|
|
<div class="disp-tengah overflow-hidden">
|
|
<div id="divBlur" class="bg-white bg-opacity-75 d-none"> </div>
|
|
<div id="divIklan" class="carousel slide" data-bs-ride="carousel"> </div>
|
|
<div id="divThank"> </div>
|
|
</div>
|
|
|
|
<div class="disp-bawah overflow-hidden fixed-bottom border-top border-warning">
|
|
<div id="divPromo" class="carousel slide carousel-fade" data-bs-ride="carousel"> </div>
|
|
</div>'
|
|
]);
|
|
}
|
|
|
|
private function get_pos(): array {
|
|
$pos = ['No_Pos' => "", 'UserID' => 0, 'Unix' => ""];
|
|
$row = $this->db->fetchRow("SELECT * FROM disp_login WHERE IP=? AND CabID=? ORDER BY Date DESC", [$this->app->request()->ip, $this->id_cab]);
|
|
if ($row) $pos = $row->getData();
|
|
return $pos;
|
|
}
|
|
|
|
}
|